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/AddAlarmTargetTypeListForm.cs | 369 +++++++++++++++++++++++++++------------------------- 1 files changed, 192 insertions(+), 177 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Safety/AddAlarmTargetTypeListForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Safety/AddAlarmTargetTypeListForm.cs index 1e0626e..a798f83 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Safety/AddAlarmTargetTypeListForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Safety/AddAlarmTargetTypeListForm.cs @@ -1,83 +1,95 @@ -锘縰sing System; -using System.Collections.Generic; -using ZigBee.Device; - -namespace Shared.Phone.UserCenter.Safety -{ - /// <summary> - /// 娣诲姞鎶ヨ鐩爣鑿滃崟鍒楄〃鐨勭敾闈� - /// </summary> - public class AddAlarmTargetTypeListForm : UserCenterCommonForm +锘縰sing System; +using System.Collections.Generic; +using ZigBee.Device; + +namespace Shared.Phone.UserCenter.Safety +{ + /// <summary> + /// 娣诲姞鎶ヨ鐩爣鑿滃崟鍒楄〃鐨勭敾闈� + /// </summary> + public class AddAlarmTargetTypeListForm : EditorCommonForm { #region 鈻� 鍙橀噺澹版槑___________________________ - /// <summary> - /// 闃插尯ID(杩欎釜涓滆タ浼间箮鏄敮涓�鐨�) - /// </summary> - private int zoonID = 0; - /// <summary> - /// 鍒楄〃鎺т欢 - /// </summary> - private VerticalScrolViewLayout listView = null; - /// <summary> - /// 鍏ㄩ儴璁惧淇℃伅 - /// </summary> + /// <summary> + /// 闃插尯ID(杩欎釜涓滆タ浼间箮鏄敮涓�鐨�) + /// </summary> + private int zoonID = 0; + /// <summary> + /// 鍒楄〃鎺т欢 + /// </summary> + private VerticalListControl listView = null; + /// <summary> + /// 鍏ㄩ儴璁惧淇℃伅 + /// </summary> private List<uRowInformation> listAllDeviceInfo = new List<uRowInformation>(); #endregion #region 鈻� 鍒濆鍖朹____________________________ - /// <summary> - /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) - /// </summary> - /// <param name="i_zoonID">闃插尯ID</param> - public void ShowForm(int i_zoonID) - { - this.zoonID = i_zoonID; - - //璁剧疆澶撮儴淇℃伅 - base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddAlarmTarget)); - - //鍒濆鍖栦腑閮ㄤ俊鎭� - this.InitMiddleFrame(); - } - - /// <summary> - /// 鍒濆鍖栦腑閮ㄤ俊鎭� - /// </summary> - private void InitMiddleFrame() - { - bodyFrameLayout.RemoveAll(); - - this.listView = new VerticalScrolViewLayout(); - this.listView.Height = bodyFrameLayout.Height; - bodyFrameLayout.AddChidren(this.listView); - - //璁剧疆涓棿閮ㄥ垎淇℃伅 - this.SetMiddleInfo(); - } - - /// <summary> - /// 璁剧疆涓棿閮ㄥ垎淇℃伅 - /// </summary> - private void SetMiddleInfo() + /// <summary> + /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) + /// </summary> + /// <param name="i_zoonID">闃插尯ID</param> + public void ShowForm(int i_zoonID) + { + this.zoonID = i_zoonID; + + //璁剧疆澶撮儴淇℃伅 + base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddAlarmTarget)); + + //鍒濆鍖栦腑閮ㄤ俊鎭� + this.InitMiddleFrame(); + } + + /// <summary> + /// 鍒濆鍖栦腑閮ㄤ俊鎭� + /// </summary> + private void InitMiddleFrame() + { + //娓呯┖bodyFrame + this.ClearBodyFrame(); + + //璁剧疆涓棿閮ㄥ垎淇℃伅 + this.SetMiddleInfo(); + } + + /// <summary> + /// 璁剧疆涓棿閮ㄥ垎淇℃伅 + /// </summary> + private void SetMiddleInfo() { new System.Threading.Thread(() => { - System.Threading.Thread.Sleep(100); - //鑾峰彇璁惧鐨勬墍鏈夌被鍨嬶紝骞舵暣鐞嗘垚姣忎竴琛岀殑鏁版嵁 this.GetAllListData(); - - //娣诲姞璁惧鐨勮 - foreach (uRowInformation info in listAllDeviceInfo) + if (listAllDeviceInfo.Count == 0) { - Application.RunOnMainThread(() => - { - this.AddRowLaout(info); - }); + return; } + + Application.RunOnMainThread(() => + { + int realHeight = (ControlCommonResourse.ListViewRowHeight + Application.GetRealHeight(29)) * listAllDeviceInfo.Count + Application.GetRealHeight(23); + if (realHeight > bodyFrameLayout.Height + Application.GetRealHeight(6)) + { + //璁$畻鐪熷疄楂樺害 + realHeight = bodyFrameLayout.Height + Application.GetRealHeight(6); + } + this.listView = new VerticalListControl(29); + listView.Y = Application.GetRealHeight(-6); + listView.Height = realHeight; + listView.BackgroundColor = UserCenterColor.Current.White; + bodyFrameLayout.AddChidren(this.listView); + + //娣诲姞璁惧鐨勮 + int count = listAllDeviceInfo.Count - 1; + for (int i = 0; i < listAllDeviceInfo.Count; i++) + { + this.AddRowLaout(listAllDeviceInfo[i], i != count); + } + }); }) { IsBackground = true }.Start(); } @@ -86,103 +98,107 @@ #region 鈻� 娣诲姞琛宊____________________________ - /// <summary> - /// 娣诲姞琛� - /// </summary> - /// <param name="uRow"></param> - private void AddRowLaout(uRowInformation uRow) - { - var rowlayout = new StatuRowLayout(this.listView); - //鍥炬爣 - var btnIcon = new RowLeftIconView(); - btnIcon.UnSelectedImagePath = uRow.IconUnSelectPath; - btnIcon.SelectedImagePath = uRow.IconSelectPath; - rowlayout.AddChidren(btnIcon); - - //璁惧鍚� - var txtDevice = new RowCenterView(); - txtDevice.Text = uRow.TextName; - rowlayout.AddChidren(txtDevice); - - //鍚戝彸鍥炬爣 - rowlayout.AddRightIconControl(); - - //鍗曞嚮浜嬩欢 - rowlayout.MouseUpEvent += (sender, e) => - { + /// <summary> + /// 娣诲姞琛� + /// </summary> + /// <param name="uRow"></param> + /// <param name="addLine"></param> + private void AddRowLaout(uRowInformation uRow, bool addLine) + { + var rowlayout = new FrameRowControl(listView.rowSpace / 2); + listView.AddChidren(rowlayout); + //鍥炬爣 + var btnIcon = rowlayout.AddLeftIcon(81); + btnIcon.UnSelectedImagePath = uRow.IconUnSelectPath; + + //璁惧鍚� + var txtDevice = rowlayout.AddLeftCaption(uRow.TextName, 750); + txtDevice.Text = uRow.TextName; + txtDevice.TextSize = 15; + //鍚戝彸鍥炬爣 + rowlayout.AddRightArrow(); + if (addLine == true) + { + //搴曠嚎 + rowlayout.AddBottomLine(); + } + + //鍗曞嚮浜嬩欢 + rowlayout.ButtonClickEvent += (sender, e) => + { if (uRow.listScene == null) { //璁惧鐨勪竴瑙� var form = new AddDeviceAlarmTargetListForm(); - this.AddForm(form, this.zoonID, uRow.TextName, uRow.listDevice); - } + form.AddForm(this.zoonID, uRow.TextName, uRow.listDevice); + } else { //鍦烘櫙鐨勪竴瑙� var form = new AddSceneAlarmTargetListForm(); - this.AddForm(form, this.zoonID, uRow.listScene); - } - }; + form.AddForm(this.zoonID, uRow.listScene); + } + }; } #endregion #region 鈻� 涓�鑸柟娉昣__________________________ - /// <summary> - /// 鑾峰彇璁惧鐨勬墍鏈夌被鍨嬶紝骞舵暣鐞嗘垚姣忎竴琛岀殑鏁版嵁 - /// </summary> - private void GetAllListData() - { - Dictionary<string, uRowInformation> dic = new Dictionary<string, uRowInformation>(); - this.listAllDeviceInfo.Clear(); - - var listDevice = Common.LocalDevice.Current.listAllDevice; - foreach (CommonDevice device in listDevice) + /// <summary> + /// 鑾峰彇璁惧鐨勬墍鏈夌被鍨嬶紝骞舵暣鐞嗘垚姣忎竴琛岀殑鏁版嵁 + /// </summary> + private void GetAllListData() + { + Dictionary<string, uRowInformation> dic = new Dictionary<string, uRowInformation>(); + this.listAllDeviceInfo.Clear(); + + var listDevice = Common.LocalDevice.Current.listAllDevice; + foreach (CommonDevice device in listDevice) { //濡傛灉閭d釜璁惧宸茬粡娣诲姞浜嗭紝鍒欎笉鍐嶆樉绀� - if (Common.LocalSafeguard.Current.IsAlarmDeviceExist(this.zoonID, device) == true) - { - continue; - } - if (device.Type == DeviceType.IASZone//浼犳劅鍣� - || device.Type == DeviceType.OnOffSwitch//闈㈡澘 - ) + if (HdlSafeguardLogic.Current.IsAlarmDeviceExist(this.zoonID, device) == true) { continue; } + if (device.Type == DeviceType.AirSwitch//绌烘皵寮�鍏� + || device.Type == DeviceType.DimmableLight//璋冨厜鍣� + || device.Type == DeviceType.ColorDimmableLight//褰╃伅 + || device.Type == DeviceType.OnOffOutput//缁х數鍣� + || device.Type == DeviceType.WindowCoveringDevice)//绐楀笜 + { + //鏄剧ず鏂囨湰 + string KeysName = Common.LocalDevice.Current.GetDeviceObjectText(new List<CommonDevice>() { device }); - //鏄剧ず鏂囨湰 - string KeysName = Common.LocalDevice.Current.GetDeviceObjectText(new List<CommonDevice>() { device }); - //鍥炬爣鍦板潃:鐐逛寒 - string IconSelect = string.Empty; - //鍥炬爣鍦板潃:鏈偣浜� - string IconUnSelect = string.Empty; + uRowInformation infoRow = null; + if (dic.ContainsKey(KeysName) == false) + { + //鍥炬爣鍦板潃:鐐逛寒 + string IconSelect = string.Empty; + //鍥炬爣鍦板潃:鏈偣浜� + string IconUnSelect = string.Empty; + Common.LocalDevice.Current.GetDeviceBeloneIcon(new List<CommonDevice>() { device }, ref IconUnSelect, ref IconSelect); - Common.LocalDevice.Current.GetDeviceBeloneIcon(new List<CommonDevice>() { device }, ref IconUnSelect, ref IconSelect); - - uRowInformation infoRow = null; - if (dic.ContainsKey(KeysName) == false) - { - //绗竴娆℃椂锛岃缃畠鐨勬樉绀烘枃鏈強璁剧疆瀹冪殑鍥炬爣 - infoRow = new uRowInformation(); - dic[KeysName] = infoRow; - infoRow.TextName = KeysName; - infoRow.IconSelectPath = IconSelect; - infoRow.IconUnSelectPath = IconUnSelect; - - this.listAllDeviceInfo.Add(infoRow); - } - infoRow = dic[KeysName]; - - //璁惧鏀堕泦 - var info = new uDeviceInfo - { - listRoomName = Shared.Common.Room.CurrentRoom.GetRoomListNameByDevice(device), - Device = device, - MainKeys = device.DeviceAddr + device.DeviceEpoint.ToString() - }; - infoRow.listDevice.Add(info); + //绗竴娆℃椂锛岃缃畠鐨勬樉绀烘枃鏈強璁剧疆瀹冪殑鍥炬爣 + infoRow = new uRowInformation(); + dic[KeysName] = infoRow; + infoRow.TextName = KeysName; + infoRow.IconSelectPath = IconSelect; + infoRow.IconUnSelectPath = IconUnSelect; + + this.listAllDeviceInfo.Add(infoRow); + } + infoRow = dic[KeysName]; + + //璁惧鏀堕泦 + var info = new uDeviceInfo + { + listRoomName = Shared.Common.Room.CurrentRoom.GetRoomListNameByDevice(device), + Device = device, + MainKeys = device.DeviceAddr + device.DeviceEpoint.ToString() + }; + infoRow.listDevice.Add(info); + } } //鑾峰彇鍦烘櫙 @@ -193,7 +209,7 @@ return; } //鑾峰彇鏈湴瀹夐槻鐨勫満鏅� - Dictionary<int, string> dicScene = Common.LocalSafeguard.Current.GetLocalSceneByZoneID(this.zoonID); + Dictionary<int, string> dicScene = HdlSafeguardLogic.Current.GetLocalSceneByZoneID(this.zoonID); var SceneInfo = new uRowInformation(); SceneInfo.listScene = new List<Common.SceneRoomUI>(); @@ -209,55 +225,54 @@ if (SceneInfo.listScene.Count > 0) { SceneInfo.TextName = Language.StringByID(R.MyInternationalizationString.uScence); - SceneInfo.IconSelectPath = "Item/SceneSelected.png"; SceneInfo.IconUnSelectPath = "Item/Scene.png"; this.listAllDeviceInfo.Add(SceneInfo); - } + } } - #endregion + #endregion - #region 鈻� 鐣岄潰閲嶆柊婵�娲讳簨浠禵__________________ + #region 鈻� 鐣岄潰閲嶆柊婵�娲讳簨浠禵__________________ /// <summary> /// 鑷韩鐨勪笂灞傜晫闈㈠叧闂悗,瀹冭嚜韬浜庢渶涓婂眰鏃�,瑙﹀彂鐨勪簨浠� - /// </summary> + /// </summary> public override void FormActionAgainEvent() { //閲嶆柊鍒锋柊鐣岄潰 - this.ShowForm(zoonID); + this.InitMiddleFrame(); } - #endregion - - #region 鈻� 鑷畾涔夌粨鏋勪綋_______________________ - - /// <summary> - /// 姣忎竴琛岀殑琛屾暟鎹� - /// </summary> - private class uRowInformation - { - /// <summary> - /// 鍥炬爣鍦板潃:鏈偣浜� - /// </summary> - public string IconUnSelectPath = string.Empty; - /// <summary> - /// 鍥炬爣鍦板潃:鐐逛寒 - /// </summary> - public string IconSelectPath = string.Empty; - /// <summary> - /// 鏄剧ず鐨勫唴瀹� - /// </summary> - public string TextName = string.Empty; - /// <summary> - /// 璁惧鍒楄〃淇℃伅 - /// </summary> - public List<uDeviceInfo> listDevice = new List<uDeviceInfo>(); + #endregion + + #region 鈻� 鑷畾涔夌粨鏋勪綋_______________________ + + /// <summary> + /// 姣忎竴琛岀殑琛屾暟鎹� + /// </summary> + private class uRowInformation + { + /// <summary> + /// 鍥炬爣鍦板潃:鏈偣浜� + /// </summary> + public string IconUnSelectPath = string.Empty; + /// <summary> + /// 鍥炬爣鍦板潃:鐐逛寒 + /// </summary> + public string IconSelectPath = string.Empty; + /// <summary> + /// 鏄剧ず鐨勫唴瀹� + /// </summary> + public string TextName = string.Empty; + /// <summary> + /// 璁惧鍒楄〃淇℃伅 + /// </summary> + public List<uDeviceInfo> listDevice = new List<uDeviceInfo>(); /// <summary> /// 鍦烘櫙 - /// </summary> - public List<Common.SceneRoomUI> listScene = null; + /// </summary> + public List<Common.SceneRoomUI> listScene = null; } - #endregion - } -} + #endregion + } +} -- Gitblit v1.8.0