From 944b87b6bcccb095cd73f13f4410fb20faf48f74 Mon Sep 17 00:00:00 2001 From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local> Date: 星期三, 25 十二月 2019 11:21:06 +0800 Subject: [PATCH] 2019.12.25 --- ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs | 349 ++++++++++++++++++++++++++++++++++++--------------------- 1 files changed, 221 insertions(+), 128 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs index 6d2082c..1d82707 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; @@ -19,7 +20,7 @@ /// <summary> /// 鍒楄〃鎺т欢 /// </summary> - private VerticalListControl listView = null; + private VerticalListRefreshControl listView = null; /// <summary> /// 琛屾帶浠剁殑淇℃伅(Keys锛歁ac鍦板潃) /// </summary> @@ -89,8 +90,6 @@ this.gatewayViewRow = new MyGatewayControl(GatewayResourse.NowSelectGateway); bodyFrameLayout.AddChidren(gatewayViewRow); gatewayViewRow.InitControl(); - //璁剧疆缃戝叧鎺ュ彈鍦ㄧ嚎鐘舵�佹帹閫� - this.AddGatewayOnlinePush(); //鍒濆鍖栨悳绱㈡帶浠� this.InitSearchControl(); @@ -127,10 +126,29 @@ txtSearchControl.BindEvent(this.SetRowDataBySearchKeys); //鍒楄〃鎺т欢 - listView = new VerticalListControl(29); + listView = new VerticalListRefreshControl(29); listView.Y = txtSearchControl.Bottom + Application.GetRealHeight(29); listView.Height = frame.Height - txtSearchControl.Bottom - Application.GetRealHeight(29); frame.AddChidren(listView); + listView.BeginHeaderRefreshingAction += () => + { + //涓嬫媺鍒锋柊 + HdlThreadLogic.Current.RunThread(() => + { + //鑾峰彇鍏ㄩ儴璁惧 + bool result = LocalDevice.Current.SetDeviceToMemmoryByGateway(GatewayResourse.NowSelectGateway); + HdlThreadLogic.Current.RunMain(() => + { + //闅愯棌涓嬫媺鍒锋柊鐗规晥 + listView.EndHeaderRefreshing(); + if (result == true) + { + //閲嶆柊鍒锋柊鐣岄潰 + this.InitMiddleFrame(false); + } + }); + }); + }; } #endregion @@ -157,12 +175,8 @@ //鏍规嵁MAC鍚堝苟璁惧鍒楄〃 this.MargeAllDeviceByMac(listDevice); - Application.RunOnMainThread(() => + HdlThreadLogic.Current.RunMain(() => { - if (this.Parent == null) - { - return; - } var listOta = new List<OTADevice>(); foreach (var macAddress in this.dicRowInfo.Keys) { @@ -175,13 +189,7 @@ //娣诲姞璁惧鐨勮彍鍗曡 this.AddDeviceMenuRow(macAddress); } - //娣诲姞搴曢儴闂撮殭 - var frameTemp = new FrameLayout(); - frameTemp.Height = Application.GetRealHeight(23); - listView.AddChidren(frameTemp); - //寮�鍚澶囧睘鎬у彉鏇寸洃鍚� - this.AddDeviceAttributePush(); //寮�鍚綉鍏冲湪绾跨洃娴嬬殑绾跨▼ this.StartGatewayOnlieCheckThread(); //妫�娴嬭澶囨柊鐗堟湰 @@ -213,8 +221,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 +251,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 +305,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,7 +323,8 @@ /// </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]; if (rowInfo.dicDetailRow == null) @@ -344,11 +368,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 @@ -465,29 +577,7 @@ #endregion - #region 鈻� 璁惧灞炴�у彉鏇存帹閫乢__________________ - - /// <summary> - /// 璁惧灞炴�у彉鏇存帹閫� - /// </summary> - /// <param name="device"></param> - public override void DeviceAttributePush(CommonDevice device) - { - if (dicRowInfo.ContainsKey(device.DeviceAddr) == false) - { - return; - } - var rowInfo = dicRowInfo[device.DeviceAddr]; - Application.RunOnMainThread(() => - { - //鍒锋柊鑿滃崟 - rowInfo.MenuRow?.RefreshControlInfo(false); - }); - } - - #endregion - - #region 鈻� 寮�鍚澶囧湪绾跨嚎绋媉__________________ + #region 鈻� 璁惧鍦ㄧ嚎妫�娴媉______________________ /// <summary> /// 寮�鍚澶囧湪绾跨嚎绋� @@ -507,10 +597,6 @@ this.StartCheckDeviceOnline(); } - #endregion - - #region 鈻� 璁惧鍦ㄧ嚎___________________________ - /// <summary> /// 寮�鍚澶囧湪绾跨洃娴� /// </summary> @@ -521,20 +607,24 @@ { return; } + + //娣诲姞鎺ユ敹璁惧鍦ㄧ嚎涓婃姤鐨勭洃鍚� + HdlGatewayReceiveLogic.Current.AddAttributeEvent("DeviceListFormReceivePushOnline", ReceiveComandDiv.A璁惧鍦ㄧ嚎涓婃姤, this.ReceiveDeviceStatu); + 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, false, this.ReceiveDeviceStatuPush, ShowErrorMode.NO); + var result = Common.LocalDevice.Current.GetDeviceListFromGateway(zbway, false, this.ReceiveDeviceStatu, ShowErrorMode.NO); }); } /// <summary> - /// 鎺ュ彈璁惧鍦ㄧ嚎鎺ㄩ�� + /// 鎺ュ彈璁惧鐘舵�� /// </summary> /// <param name="device"></param> - private void ReceiveDeviceStatuPush(CommonDevice device) + private void ReceiveDeviceStatu(CommonDevice device) { lock (dicRowInfo) { @@ -605,6 +695,29 @@ #endregion + #region 鈻� 浼犳劅鍣ㄦ姤璀________________________ + + /// <summary> + /// 寮�鍚紶鎰熷櫒鎶ヨ鐩戣 + /// </summary> + private void StartCheckDeviceAlarm() + { + HdlGatewayReceiveLogic.Current.AddAttributeEvent("DeviceListFormSensor", ReceiveComandDiv.A浼犳劅鍣ㄤ笂鎶�, (device) => + { + Application.RunOnMainThread(() => + { + if (this.dicRowInfo.ContainsKey(device.DeviceAddr) == false) + { + return; + } + //鏄剧ず浼犳劅鍣ㄤ笂鎶ョ殑鐗规晥 + this.dicRowInfo[device.DeviceAddr].MenuRow?.StartSensorPushAppeal(); + }); + }); + } + + #endregion + #region 鈻� 璁惧鏂扮増鏈琠________________________ /// <summary> @@ -658,32 +771,6 @@ #endregion - #region 鈻� 浼犳劅鍣ㄦ姤璀________________________ - - /// <summary> - /// 寮�鍚紶鎰熷櫒鎶ヨ鐩戣 - /// </summary> - private void StartCheckDeviceAlarm() - { - HdlDeviceAttributeLogic.Current.AddAttributeEvent("DeviceListFormSensor", "IASInfoReport", (device) => - { - Application.RunOnMainThread(() => - { - if (this.dicRowInfo.ContainsKey(device.DeviceAddr) == false) - { - return; - } - var row = this.dicRowInfo[device.DeviceAddr].MenuRow; - if (row != null) - { - row.frameTable.StartSelectStatuAppeal(3000); - } - }); - }); - } - - #endregion - #region 鈻� 瀹炵幇澶栭儴璋冪敤_______________________ /// <summary> @@ -696,6 +783,11 @@ if (this.dicRowInfo.ContainsKey(deviceAddr) == false) { var localDevice = Common.LocalDevice.Current.GetDevicesByMac(deviceAddr); + if (localDevice.Count == 0) + { + //鍏ョ綉涔嬪悗锛屽張鎶婂畠鍒犱簡 + return; + } var rowNewInfo = new DeviceObjRowInfo(); rowNewInfo.DeviceMac = deviceAddr; rowNewInfo.MacName = Common.LocalDevice.Current.GetDeviceMacName(localDevice[0]); @@ -704,8 +796,6 @@ //鍒涘缓鏂扮殑琛� this.AddDeviceMenuRow(deviceAddr); - - return; } } @@ -746,23 +836,6 @@ #endregion - #region 鈻� 鍏抽棴鐣岄潰___________________________ - - /// <summary> - /// 鐢婚潰鍏抽棴 - /// </summary> - public override void CloseForm() - { - HdlDeviceAttributeLogic.Current.RemoveEvent("DeviceListFormSensor"); - HdlDeviceAttributeLogic.Current.RemoveEvent("DeviceListFormReceivePushOnline"); - - GatewayResourse.NowSelectGateway = null; - - base.CloseForm(); - } - - #endregion - #region 鈻� 鐣岄潰閲嶆柊婵�娲讳簨浠禵__________________ /// <summary> @@ -770,30 +843,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(); + } } } } @@ -803,6 +875,23 @@ this.gatewayViewRow.RefreshControl(); return 1; + } + + #endregion + + #region 鈻� 鍏抽棴鐣岄潰___________________________ + + /// <summary> + /// 鐢婚潰鍏抽棴 + /// </summary> + public override void CloseFormBefore() + { + HdlGatewayReceiveLogic.Current.RemoveEvent("DeviceListFormSensor"); + HdlGatewayReceiveLogic.Current.RemoveEvent("DeviceListFormReceivePushOnline"); + + GatewayResourse.NowSelectGateway = null; + + base.CloseFormBefore(); } #endregion @@ -923,6 +1012,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