From 404cdc88627f942df7944af04ee05b9d527752d6 Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期一, 30 九月 2019 13:22:40 +0800 Subject: [PATCH] 合并了徐梅的按键面板绑定 --- ZigbeeApp/Shared/Phone/UserCenter/Safety/SensorDeviceSettionListForm.cs | 145 ++++++++++++++++++++++++++++++++---------------- 1 files changed, 97 insertions(+), 48 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Safety/SensorDeviceSettionListForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Safety/SensorDeviceSettionListForm.cs index 739b466..373d26f 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Safety/SensorDeviceSettionListForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Safety/SensorDeviceSettionListForm.cs @@ -8,14 +8,14 @@ /// <summary> /// 宸茬粡璁剧疆浜嗙殑浼犳劅鍣ㄧ殑涓�瑙堢敾闈� /// </summary> - public class SensorDeviceSettionListForm : UserCenterCommonForm + public class SensorDeviceSettionListForm : EditorCommonForm { #region 鈻� 鍙橀噺澹版槑___________________________ /// <summary> /// 鍒楄〃鎺т欢 /// </summary> - private VerticalScrolViewLayout listView = null; + private VerticalListControl listView = null; /// <summary> /// 闃插尯ID /// </summary> @@ -38,18 +38,20 @@ base.SetTitleText(SectorsName + Language.StringByID(R.MyInternationalizationString.uSettion)); //鍙充笂瑙掔殑鈥滐紜鈥濆浘鏍� - var btnTopIcon = new TopLayoutMostRightView(); + var btnTopIcon = new MostRightIconControl(69, 69); btnTopIcon.UnSelectedImagePath = "Item/Add.png"; - btnTopIcon.SelectedImagePath = "Item/AddSelected.png"; topFrameLayout.AddChidren(btnTopIcon); - btnTopIcon.MouseUpEventHandler += (sender, e) => + btnTopIcon.InitControl(); + btnTopIcon.ButtonClickEvent += (sender, e) => { //娣诲姞鏂扮殑浼犳劅鍣� this.AddNewSensorDevice(); }; - listView = new VerticalScrolViewLayout(); - listView.Height = bodyFrameLayout.Height; + listView = new VerticalListControl(29); + listView.Y = Application.GetRealHeight(-6); + listView.Height = bodyFrameLayout.Height + Application.GetRealHeight(6); + listView.BackgroundColor = UserCenterColor.Current.White; bodyFrameLayout.AddChidren(listView); //鍒濆鍖栦紶鎰熷櫒鍒楄〃淇℃伅 @@ -62,18 +64,34 @@ private void InitSensorDevicesListInfo() { this.listView.RemoveAll(); + listView.Height = bodyFrameLayout.Height + Application.GetRealHeight(6); //鑾峰彇鎸囧畾闃插尯鍏ㄩ儴鐨勪紶鎰熷櫒璁惧鐨勪俊鎭� - var listInfo = Common.LocalSafeguard.Current.GetSensorDevicesInfoByZoonID(this.zoonID); + var listInfo = HdlSafeguardLogic.Current.GetSensorDevicesInfoByZoonID(this.zoonID); + if (listInfo.Count == 0) + { + return; + } new System.Threading.Thread(() => { - foreach (var info in listInfo) + Application.RunOnMainThread(() => { - Application.RunOnMainThread(() => + int count = listInfo.Count - 1; + for (int i = 0; i < listInfo.Count; i++) { - this.AddRowLayout(info); - }); - } + if (this.Parent != null) + { + this.AddRowLayout(listInfo[i], i != count); + } + } + if (listView.ChildrenCount == 0) + { + //娌℃湁鍚堟硶鐨勪紶鎰熷櫒 + return; + } + //璋冩暣鍒楄〃鎺т欢鐨勯珮搴� + this.AdjustListviewHeight(); + }); }) { IsBackground = true }.Start(); } @@ -86,40 +104,35 @@ /// 娣诲姞琛� /// </summary> /// <param name="sensorInfo">浼犳劅鍣ㄤ俊鎭�</param> - private void AddRowLayout(Safeguard.ZoneDeviceListData sensorInfo) + /// <param name="addLine">鏄惁娣诲姞搴曠嚎</param> + private void AddRowLayout(Safeguard.ZoneDeviceListData sensorInfo, bool addLine) { CommonDevice device = Common.LocalDevice.Current.GetDevice(sensorInfo.MacAddr, sensorInfo.Epoint); if (device == null) { return; } - - var rowLayout = new RowLayout(); - rowLayout.Height = ControlCommonResourse.ListViewRowHeight; + //鑷畾涔夋帶浠� + var rowLayout = new DeviceRoomControl(device, listView.rowSpace / 2); listView.AddChidren(rowLayout); - - //鍥炬爣 - var btnIcon = new RowLeftIconView(); - Common.LocalDevice.Current.SetDeviceIconToControl(btnIcon, device); - rowLayout.AddChidren(btnIcon); - - //璁惧鍚� - var btnDevice = new RowTopBlackView(); - btnDevice.Text = Common.LocalDevice.Current.GetDeviceEpointName(device); - rowLayout.AddChidren(btnDevice); - - //鎴块棿 - var btnRoom = new RowBottomGrayView(); - btnRoom.Text = Common.Room.CurrentRoom.GetRoomNameByDevice(device); - rowLayout.AddChidren(btnRoom); - + rowLayout.InitControl(); + rowLayout.frameTable.UseClickStatu = false; + if (addLine == true) + { + //搴曠嚎 + rowLayout.frameTable.AddBottomLine(); + } //鏃佽矾鐘舵�� - var txtStatu = new RowMostRightTextView(); - txtStatu.TextColor = UserCenterColor.Current.Red; - rowLayout.AddChidren(txtStatu); + var txtStatu = rowLayout.frameTable.AddMostRightView("", 350); + txtStatu.TextColor = UserCenterColor.Current.TextGrayColor1; //鏃佽矾璁剧疆 - var btnBypass = new RowBypassButton(); + var btnBypass = new NormalViewControl(Application.GetRealWidth(184), rowLayout.Height, false); + btnBypass.TextID = R.MyInternationalizationString.uBypass; + btnBypass.BackgroundColor = 0xff4a4a4a; + btnBypass.TextColor = UserCenterColor.Current.TextColor3; + btnBypass.TextAlignment = TextAlignment.Center; + btnBypass.TextSize = 12; if (sensorInfo.IsBypass == 1) { //宸茶缃梺璺� @@ -128,19 +141,29 @@ btnBypass.TextID = R.MyInternationalizationString.uCancelBypass; } rowLayout.AddLeftView(btnBypass); - btnBypass.MouseUpEventHandler += (sender, e) => + btnBypass.ButtonClickEvent += (sender, e) => { //璁剧疆鏃佽矾鐘舵�� this.SetBypassStatu(sensorInfo, device); }; //鍒犻櫎 - var btnDelete = new RowDeleteButton(); + var btnDelete = new NormalViewControl(Application.GetRealWidth(184), rowLayout.Height, false); + btnDelete.TextID = R.MyInternationalizationString.uDelete; + btnDelete.BackgroundColor = 0xfff75858; + btnDelete.TextColor = UserCenterColor.Current.TextColor3; + btnDelete.TextAlignment = TextAlignment.Center; + btnDelete.TextSize = 12; rowLayout.AddRightView(btnDelete); - btnDelete.MouseUpEventHandler += (sender, e) => + btnDelete.ButtonClickEvent += (sender, e) => { + //纭鏄惁瑕佸垹闄�? string msg = Language.StringByID(R.MyInternationalizationString.uShowDoDeleteMsg); - this.ShowConfirmMsg(msg, "DeleteRow", rowLayout, device); + this.ShowMassage(ShowMsgType.Confirm, msg, () => + { + //鍒犻櫎浼犳劅鍣ㄨ + this.DeleteRow(rowLayout, device); + }); }; } @@ -153,12 +176,12 @@ /// </summary> /// <param name="rowLayout"></param> /// <param name="device"></param> - public async void DeleteRow(RowLayout rowLayout, CommonDevice device) + private async void DeleteRow(DeviceRoomControl rowLayout, CommonDevice device) { //寮�鍚繘搴︽潯 this.ShowProgressBar(); - bool result = await Common.LocalSafeguard.Current.DeleteSensorDevice(this.zoonID, new List<CommonDevice>() { device }); + bool result = await HdlSafeguardLogic.Current.DeleteSensorDevice(this.zoonID, new List<CommonDevice>() { device }); //鍏抽棴杩涘害鏉� this.CloseProgressBar(); @@ -169,7 +192,9 @@ Application.RunOnMainThread(() => { //浠庣敾闈腑绉婚櫎 - rowLayout.RemoveFromParent(); + rowLayout?.RemoveFromParent(); + //璋冭妭鍒楄〃鎺т欢鐨勯珮搴� + this.AdjustListviewHeight(); }); } @@ -187,7 +212,7 @@ //鍙樻洿鐘舵�� int statu = sensorInfo.IsBypass == 1 ? 0 : 1; - bool result = await Common.LocalSafeguard.Current.SetByPassStatuToSafety(this.zoonID, device, statu); + bool result = await HdlSafeguardLogic.Current.SetByPassStatuToSafety(this.zoonID, device, statu); if (result == false) { return; @@ -212,7 +237,7 @@ //鏄剧ず閫夋嫨鐣岄潰 var form = new SelectDeviceForm(); - this.AddForm(form, list, new List<string>(), true); + form.AddForm(list, new List<string>(), true); form.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddSensor)); //璁惧閫夋嫨纭畾 @@ -230,7 +255,7 @@ //寮�鍚繘搴︽潯 this.ShowProgressBar(); //娣诲姞璁惧鍒板畨闃� - bool success = await Common.LocalSafeguard.Current.AddSensorDevice(this.zoonID, listDevice); + bool success = await HdlSafeguardLogic.Current.AddSensorDevice(this.zoonID, listDevice); //鍏抽棴杩涘害鏉� this.CloseProgressBar(); @@ -263,7 +288,7 @@ continue; } //濡傛灉閭d釜璁惧宸茬粡娣诲姞浜嗭紝鍒欎笉鍐嶆樉绀� - if (Common.LocalSafeguard.Current.IsSensorDeviceExist(device) == true) + if (HdlSafeguardLogic.Current.IsSensorDeviceExist(device) == true) { continue; } @@ -273,5 +298,29 @@ } #endregion + + #region 鈻� 涓�鑸柟娉昣__________________________ + + /// <summary> + /// 璋冭妭鍒楄〃鎺т欢鐨勯珮搴� + /// </summary> + private void AdjustListviewHeight() + { + if (listView.ChildrenCount == 0) + { + //鐩存帴鎷夋弧灞忓箷 + listView.Height = bodyFrameLayout.Height + Application.GetRealHeight(6); + return; + } + var realHeight = listView.ChildrenCount * listView.GetChildren(listView.ChildrenCount - 1).Height; + realHeight += listView.rowSpace; + if (realHeight < listView.Height) + { + //缂╁皬鎺т欢楂樺害 + listView.Height = realHeight; + } + } + + #endregion } } -- Gitblit v1.8.0