From 5727cf0b9b54da0a191dd1e23cb5abf21320fbff Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期一, 25 十一月 2019 10:34:17 +0800 Subject: [PATCH] IOS使用新的项目名称 --- ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs | 220 ++++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 169 insertions(+), 51 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs index f86a187..db02ddd 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs @@ -1,4 +1,5 @@ -锘縰sing System; +锘縰sing Shared.Common; +using System; using System.Collections.Generic; using System.Text; using ZigBee.Device; @@ -213,8 +214,10 @@ rowMenu.InitControl(); rowInfo.MenuRow = rowMenu; //鍚戝彸鍥炬爣 - var btnRight = rowMenu.frameTable.AddRightArrow(); + var btnRight = rowMenu.frameTable.AddMostRightEmptyIcon(58, 58); + btnRight.UnSelectedImagePath = "Item/Next.png"; btnRight.SelectedImagePath = "Item/Down.png"; + rowMenu.frameTable.ChangedChidrenBindMode(btnRight, ChidrenBindMode.NotBind); //鎻愮ず鏂扮増鏈� var btnNew = new InformationTipView(rowMenu.btnIcon); @@ -241,22 +244,33 @@ }; } - rowMenu.frameTable.ButtonClickEvent += (sender, e) => + //灞曞紑,鎶樺彔 + btnRight.ButtonClickEvent += (sender, e) => { - //澶氬洖璺殑鎯呭喌涓嬶紝鎵嶄細灞曞紑 - if (Common.LocalDevice.Current.GetDevicesByMac(deviceMac).Count == 1) - { - var form = new DeviceMacInfoEditorForm(); - form.AddForm(deviceMac); - //鐣岄潰璺宠浆,璁板綍褰撳墠鐨勬鍦ㄦ搷浣滅殑璁惧鐨凪ac鍦板潃 - this.nowActionDeviceMac = deviceMac; - } - else + //鍥炶矾鏁板ぇ浜�1鎵嶅睍寮� + if (Common.LocalDevice.Current.GetDevicesCountByMac(deviceMac) > 1) { btnRight.IsSelected = !btnRight.IsSelected; //灞曞紑鎴栬�呮姌鍙犳槑缁嗗垪琛� this.ShowDetailList(deviceMac, btnRight.IsSelected); } + else + { + btnNew.Visible = false; + var form = new DeviceMacInfoEditorForm(); + form.AddForm(deviceMac); + //鐣岄潰璺宠浆,璁板綍褰撳墠鐨勬鍦ㄦ搷浣滅殑璁惧鐨凪ac鍦板潃 + this.nowActionDeviceMac = deviceMac; + } + }; + + rowMenu.frameTable.ButtonClickEvent += (sender, e) => + { + btnNew.Visible = false; + var form = new DeviceMacInfoEditorForm(); + form.AddForm(deviceMac); + //鐣岄潰璺宠浆,璁板綍褰撳墠鐨勬鍦ㄦ搷浣滅殑璁惧鐨凪ac鍦板潃 + this.nowActionDeviceMac = deviceMac; }; } @@ -284,10 +298,12 @@ //鏍囬鑷繁灏辨槸涓�涓瓙鎺т欢 if (rowInfo.frameTable.ChildrenCount == 1) { + //鑾峰彇杩欎竴鍫嗚澶囨椂灞炰簬浠�涔堢被鍨嬬殑 + var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(listDevice); foreach (CommonDevice info in listDevice) { //鍔犺浇瀹冪殑鍒楄〃 - this.AddDeviceDetailRow(rowInfo.frameTable, info); + this.AddDeviceDetailRow(rowInfo.frameTable, info, deviceEnumInfo); } } } @@ -300,10 +316,14 @@ /// </summary> /// <param name="frame">瀹瑰櫒</param> /// <param name="device"></param> - private void AddDeviceDetailRow(FrameListControl frame, CommonDevice device) + /// <param name="deviceEnumInfo"></param> + private void AddDeviceDetailRow(FrameListControl frame, CommonDevice device, DeviceEnumInfo deviceEnumInfo) { var rowInfo = this.dicRowInfo[device.DeviceAddr]; - rowInfo.dicDetailRow = new Dictionary<string, DeviceRoomControl>(); + if (rowInfo.dicDetailRow == null) + { + rowInfo.dicDetailRow = new Dictionary<string, DeviceRoomControl>(); + } //琛屾帶浠� var rowDevice = new DeviceRoomControl(device, frame.rowSpace / 2); @@ -314,6 +334,8 @@ rowDevice.frameTable.AddBottomLine(); //鍙崇澶� rowDevice.frameTable.AddRightArrow(); + //鍦ㄧ嚎鐘舵�� + rowDevice.isOnline = device.IsOnline == 1; //淇濆瓨鎺т欢 string maikey = Common.LocalDevice.Current.GetDeviceMainKeys(device); @@ -339,11 +361,99 @@ rowDevice.frameTable.ButtonClickEvent += (sender, e) => { - var form = new DeviceMacInfoEditorForm(); - form.AddForm(device.DeviceAddr); //鐣岄潰璺宠浆,璁板綍褰撳墠鐨勬鍦ㄦ搷浣滅殑璁惧鐨凪ac鍦板潃 this.nowActionDeviceMac = device.DeviceAddr; + //鏄剧ず璁惧鍔熻兘閰嶇疆鐣岄潰 + this.ShowDeviceFunctionSettionForm(device, deviceEnumInfo); }; + } + + /// <summary> + /// 鏄剧ず璁惧鍔熻兘閰嶇疆鐣岄潰 + /// </summary> + /// <param name="device"></param> + /// <param name="deviceEnumInfo"></param> + private void ShowDeviceFunctionSettionForm(CommonDevice device, DeviceEnumInfo deviceEnumInfo) + { + //鏅鸿兘闂ㄩ攣 + if (deviceEnumInfo.BeloneType == DeviceBeloneType.A鏅鸿兘闂ㄩ攣) + { + var form = new DeviceMacInfoEditorForm(); + form.AddForm(device.DeviceAddr); + } + else if (deviceEnumInfo.BeloneType == DeviceBeloneType.A绐楀笜) + { + var form = new DeviceMacInfoEditorForm(); + form.AddForm(device.DeviceAddr); + } + //pir浼犳劅鍣� + else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.Sensor_Pir) + { + var form = new DevicePirSensor.PirSensorBindTargetSettionForm(); + form.AddForm((IASZone)device); + } + //涓ぎ绌鸿皟 + else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.AirConditioner_ZbGateway) + { + var form = new DeviceAirConditioner.IndoorUnitSettionForm(); + form.AddForm((AC)device); + } + //闈㈡澘璁惧 + else if (deviceEnumInfo.BeloneType == DeviceBeloneType.A鎸夐敭闈㈡澘) + { + //骞叉帴鐐� + if (device.Type == DeviceType.OnOffSwitch) + { + //娌充笢璁惧 + if (deviceEnumInfo.IsHdlDevice == true) + { + var form = new DevicePanel.PanelButtonSettionForm(); + form.AddForm(device); + } + else + { + var form = new DeviceDryContactSettionForm(); + form.AddForm(device); + } + } + //缁х數鍣� + else if (device.Type == DeviceType.OnOffOutput) + { + //娌充笢璁惧 + if (deviceEnumInfo.IsHdlDevice == true) + { + var form = new DevicePanel.PanelFunctionSettionForm(); + form.AddForm(device); + } + else + { + var form = new DeviceFunctionSettionForm(); + form.AddForm(device, true); + } + } + //娓╂箍搴� + else if (device.Type == DeviceType.TemperatureSensor) + { + var form = new DeviceFunctionSettionForm(); + form.AddForm(device, true); + } + else + { + var form = new DeviceFunctionSettionForm(); + form.AddForm(device, true); + } + } + //濡傛灉鏄共鎺ョ偣 + else if (device.Type == DeviceType.OnOffSwitch) + { + var form = new DeviceDryContactSettionForm(); + form.AddForm(device); + } + else + { + var form = new DeviceFunctionSettionForm(); + form.AddForm(device, true); + } } #endregion @@ -517,32 +627,32 @@ return; } string gwId = HdlGatewayLogic.Current.GetGatewayId(GatewayResourse.NowSelectGateway); - HdlThreadLogic.Current.RunThread(async () => + HdlThreadLogic.Current.RunThread(() => { //杩欓噷涓昏鍙槸鑾峰彇鍦ㄧ嚎鐘舵�� var zbway = HdlGatewayLogic.Current.GetLocalGateway(gwId); - var result = await Common.LocalDevice.Current.GetDeviceListFromGateway(zbway, this.ReceiveDeviceStatuPush); + var result = Common.LocalDevice.Current.GetDeviceListFromGateway(zbway, false, this.ReceiveDeviceStatuPush, ShowErrorMode.NO); }); } /// <summary> - /// 鎺ュ彈璁惧鍦ㄧ嚎鎺ㄩ�侊紙缃戝叧鍦ㄧ嚎鎺ㄩ�佸嵆鍦ㄧ嚎锛� + /// 鎺ュ彈璁惧鍦ㄧ嚎鎺ㄩ�� /// </summary> /// <param name="device"></param> private void ReceiveDeviceStatuPush(CommonDevice device) { lock (dicRowInfo) { - if (device == null || this.Parent == null) + if (this.Parent == null) { return; } - DeviceObjectControl row = null; + DeviceObjRowInfo rowInfo = null; if (this.dicRowInfo.ContainsKey(device.DeviceAddr) == true) { - row = this.dicRowInfo[device.DeviceAddr].MenuRow; + rowInfo = this.dicRowInfo[device.DeviceAddr]; } - if (row == null) + if (rowInfo == null || rowInfo.MenuRow == null) { return; } @@ -561,11 +671,18 @@ localDevice.ReSave(); } - Application.RunOnMainThread(() => + HdlThreadLogic.Current.RunMain(() => { - if (row != null) + if (rowInfo != null) { - row.isOnline = device.IsOnline == 1; + rowInfo.MenuRow.isOnline = device.IsOnline == 1; + if (rowInfo.dicDetailRow != null) + { + foreach (var detailRow in rowInfo.dicDetailRow.Values) + { + detailRow.isOnline = rowInfo.MenuRow.isOnline; + } + } } }); } @@ -707,11 +824,9 @@ /// <param name="listDevice"></param> private void MargeAllDeviceByMac(List<CommonDevice> listDevice) { - //璁惧鎺掑簭 - List<CommonDevice> listSort = Common.LocalDevice.Current.SortDeviceList(listDevice); //鏍规嵁Mac鍏ㄩ儴鍒嗙粍 var dic = new Dictionary<string, List<CommonDevice>>(); - foreach (CommonDevice device in listSort) + foreach (CommonDevice device in listDevice) { if (device == null || device.DeviceAddr == null) { @@ -760,30 +875,29 @@ /// </summary> public override int FormActionAgainEvent() { - if (this.nowActionDeviceMac == null) + if (this.nowActionDeviceMac != null) { - return 1; - } - var rowInfo = this.dicRowInfo[nowActionDeviceMac]; - //妫�娴嬭繖涓澶囨槸鍚﹁鍒犻櫎 - if (Common.LocalDevice.Current.GetDevicesByMac(nowActionDeviceMac).Count == 0) - { - //绉婚櫎鎺т欢 - rowInfo.dicDetailRow = null; - rowInfo.frameTable.RemoveFromParent(); - - this.dicRowInfo.Remove(nowActionDeviceMac); - rowInfo = null; - } - else - { - //鍒锋柊璁惧淇℃伅 - rowInfo.MenuRow?.RefreshControlInfo(true); - if (rowInfo.dicDetailRow != null) + var rowInfo = this.dicRowInfo[nowActionDeviceMac]; + //妫�娴嬭繖涓澶囨槸鍚﹁鍒犻櫎 + if (Common.LocalDevice.Current.GetDevicesByMac(nowActionDeviceMac).Count == 0) { - foreach (var contr in rowInfo.dicDetailRow.Values) + //绉婚櫎鎺т欢 + rowInfo.dicDetailRow = null; + rowInfo.frameTable.RemoveFromParent(); + + this.dicRowInfo.Remove(nowActionDeviceMac); + rowInfo = null; + } + else + { + //鍒锋柊璁惧淇℃伅 + rowInfo.MenuRow?.RefreshControlInfo(true); + if (rowInfo.dicDetailRow != null) { - contr?.RefreshControlInfo(); + foreach (var contr in rowInfo.dicDetailRow.Values) + { + contr?.RefreshControlInfo(); + } } } } @@ -913,6 +1027,10 @@ { //鑾峰彇鏈湴缃戝叧瀵硅薄 ZbGateway zbway = HdlGatewayLogic.Current.GetLocalGateway(zbGatewayId); + if (zbway == null) + { + return; + } btnName.Text = HdlGatewayLogic.Current.GetGatewayName(zbway); if (HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(zbway) == false) { -- Gitblit v1.8.0