From b9cb076fe6127160c96c35bf9c8cebcffe1d5ccd Mon Sep 17 00:00:00 2001 From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local> Date: 星期五, 10 一月 2020 17:35:23 +0800 Subject: [PATCH] 2020.1.10 --- ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs | 301 ++++++++++++++++++++++++++++--------------------- 1 files changed, 173 insertions(+), 128 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs index db02ddd..227534e 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs @@ -20,7 +20,7 @@ /// <summary> /// 鍒楄〃鎺т欢 /// </summary> - private VerticalListControl listView = null; + private VerticalListRefreshControl listView = null; /// <summary> /// 琛屾帶浠剁殑淇℃伅(Keys锛歁ac鍦板潃) /// </summary> @@ -43,6 +43,8 @@ /// </summary> public void ShowForm() { + this.ScrollEnabled = false; + //璁剧疆鏍囬淇℃伅 base.SetTitleText(Language.StringByID(R.MyInternationalizationString.DeviceManagement)); @@ -90,8 +92,6 @@ this.gatewayViewRow = new MyGatewayControl(GatewayResourse.NowSelectGateway); bodyFrameLayout.AddChidren(gatewayViewRow); gatewayViewRow.InitControl(); - //璁剧疆缃戝叧鎺ュ彈鍦ㄧ嚎鐘舵�佹帹閫� - this.AddGatewayOnlinePush(); //鍒濆鍖栨悳绱㈡帶浠� this.InitSearchControl(); @@ -128,10 +128,18 @@ 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(() => + { + //涓嬫媺鍒锋柊 + this.ListViewBeginHeaderRefreshing(); + }); + }; } #endregion @@ -158,12 +166,12 @@ //鏍规嵁MAC鍚堝苟璁惧鍒楄〃 this.MargeAllDeviceByMac(listDevice); - Application.RunOnMainThread(() => + if (this.Parent == null) { - if (this.Parent == null) - { - return; - } + return; + } + HdlThreadLogic.Current.RunMain(() => + { var listOta = new List<OTADevice>(); foreach (var macAddress in this.dicRowInfo.Keys) { @@ -176,13 +184,7 @@ //娣诲姞璁惧鐨勮彍鍗曡 this.AddDeviceMenuRow(macAddress); } - //娣诲姞搴曢儴闂撮殭 - var frameTemp = new FrameLayout(); - frameTemp.Height = Application.GetRealHeight(23); - listView.AddChidren(frameTemp); - //寮�鍚澶囧睘鎬у彉鏇寸洃鍚� - this.AddDeviceAttributePush(); //寮�鍚綉鍏冲湪绾跨洃娴嬬殑绾跨▼ this.StartGatewayOnlieCheckThread(); //妫�娴嬭澶囨柊鐗堟湰 @@ -215,7 +217,7 @@ rowInfo.MenuRow = rowMenu; //鍚戝彸鍥炬爣 var btnRight = rowMenu.frameTable.AddMostRightEmptyIcon(58, 58); - btnRight.UnSelectedImagePath = "Item/Next.png"; + btnRight.UnSelectedImagePath = "Item/RightNext.png"; btnRight.SelectedImagePath = "Item/Down.png"; rowMenu.frameTable.ChangedChidrenBindMode(btnRight, ChidrenBindMode.NotBind); @@ -389,8 +391,17 @@ //pir浼犳劅鍣� else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.Sensor_Pir) { - var form = new DevicePirSensor.PirSensorBindTargetSettionForm(); - form.AddForm((IASZone)device); + if (device is IASZone) + { + var form = new DevicePirSensor.PirSensorBindTargetSettionForm(); + form.AddForm((IASZone)device); + } + else + { + //pir浼犳劅鍣�,浠栦滑鍙堟悶浜嗕釜缁х數鍣ㄥ湪閲岄潰 + var form = new DeviceFunctionSettionForm(); + form.AddForm(device, true); + } } //涓ぎ绌鸿皟 else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.AirConditioner_ZbGateway) @@ -512,6 +523,60 @@ #endregion + #region 鈻� 涓嬫媺鍒锋柊___________________________ + + /// <summary> + /// 婊戝姩鎺т欢涓嬫媺鍒锋柊 + /// </summary> + private async void ListViewBeginHeaderRefreshing() + { + //濡傛灉鏄湪绾跨殑 + if (HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(GatewayResourse.NowSelectGateway) == true) + { + //妫�娴嬪箍鎾埌鐨勮繖涓綉鍏虫槸鍚︽嫢鏈変綇瀹匢D + ZbGateway realWay = null; + if (HdlGatewayLogic.Current.GetRealGateway(ref realWay, GatewayResourse.NowSelectGateway) == true) + { + //閲嶆柊璁剧疆浣忓畢ID(杩欎釜搴旇鏄笉缁忚繃APP,鐩存帴鎶婄綉鍏虫仮澶嶄簡鍑哄巶璁剧疆) + if (HdlGatewayLogic.Current.HomeIdIsEmpty(realWay.getGatewayBaseInfo.HomeId) == true) + { + //鏄剧ず杩涘害鏉� + ProgressBar.Show(); + int result2 = await HdlGatewayLogic.Current.ReBindNewGateway(realWay); + //鍏抽棴杩涘害鏉� + ProgressBar.Close(); + if (result2 == -1) + { + return; + } + } + } + } + if (this.Parent == null) + { + return; + } + + //鑾峰彇鍏ㄩ儴璁惧 + int result = LocalDevice.Current.SetDeviceToMemmoryByGateway(GatewayResourse.NowSelectGateway); + if (this.Parent == null) + { + return; + } + HdlThreadLogic.Current.RunMain(() => + { + //闅愯棌涓嬫媺鍒锋柊鐗规晥 + listView.EndHeaderRefreshing(); + if (result != -1) + { + //閲嶆柊鍒锋柊鐣岄潰 + this.InitMiddleFrame(false); + } + }); + } + + #endregion + #region 鈻� 缃戝叧鍦ㄧ嚎妫�娴媉______________________ /// <summary> @@ -570,29 +635,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> /// 寮�鍚澶囧湪绾跨嚎绋� @@ -612,10 +655,6 @@ this.StartCheckDeviceOnline(); } - #endregion - - #region 鈻� 璁惧鍦ㄧ嚎___________________________ - /// <summary> /// 寮�鍚澶囧湪绾跨洃娴� /// </summary> @@ -626,66 +665,72 @@ { return; } + + //娣诲姞鎺ユ敹璁惧鍦ㄧ嚎涓婃姤鐨勭洃鍚� + HdlGatewayReceiveLogic.Current.AddAttributeEvent("DeviceListFormReceivePushOnline", ReceiveComandDiv.A璁惧鍦ㄧ嚎涓婃姤, this.ReceiveDeviceStatu); + string gwId = HdlGatewayLogic.Current.GetGatewayId(GatewayResourse.NowSelectGateway); HdlThreadLogic.Current.RunThread(() => { //杩欓噷涓昏鍙槸鑾峰彇鍦ㄧ嚎鐘舵�� var zbway = HdlGatewayLogic.Current.GetLocalGateway(gwId); - var result = Common.LocalDevice.Current.GetDeviceListFromGateway(zbway, false, this.ReceiveDeviceStatuPush, ShowErrorMode.NO); + int statu = 0; + var list = LocalDevice.Current.GetDeviceListFromGateway(zbway, ref statu, false, ShowErrorMode.NO); + if (statu != -1) + { + for (int i = 0; i < list.Count; i++) + { + //璁剧疆璁惧鍦ㄧ嚎鐘舵�� + this.ReceiveDeviceStatu(list[i]); + } + } }); } /// <summary> - /// 鎺ュ彈璁惧鍦ㄧ嚎鎺ㄩ�� + /// 鎺ュ彈璁惧鐘舵�� /// </summary> /// <param name="device"></param> - private void ReceiveDeviceStatuPush(CommonDevice device) + private void ReceiveDeviceStatu(CommonDevice device) { - lock (dicRowInfo) + DeviceObjRowInfo rowInfo = null; + if (this.dicRowInfo.ContainsKey(device.DeviceAddr) == true) { - if (this.Parent == null) + rowInfo = this.dicRowInfo[device.DeviceAddr]; + } + if (rowInfo == null || rowInfo.MenuRow == null) + { + return; + } + //鍒锋柊璁惧鐨勫湪绾跨姸鎬� + string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(device); + var localDevice = Common.LocalDevice.Current.GetDevice(mainkeys); + if (localDevice != null) + { + //鍦ㄧ嚎鐘舵�佷竴鏍风殑璇濓紝涓嶉渶瑕佸埛鏂� + if (localDevice.IsOnline == device.IsOnline) { return; } - DeviceObjRowInfo rowInfo = null; - if (this.dicRowInfo.ContainsKey(device.DeviceAddr) == true) - { - rowInfo = this.dicRowInfo[device.DeviceAddr]; - } - if (rowInfo == null || rowInfo.MenuRow == null) - { - return; - } - //鍒锋柊璁惧鐨勫湪绾跨姸鎬� - string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(device); - var localDevice = Common.LocalDevice.Current.GetDevice(mainkeys); - if (localDevice != null) - { - //鍦ㄧ嚎鐘舵�佷竴鏍风殑璇濓紝涓嶉渶瑕佸埛鏂� - if (localDevice.IsOnline == device.IsOnline) - { - return; - } - //淇濆瓨鐘舵�� - localDevice.IsOnline = device.IsOnline; - localDevice.ReSave(); - } + //淇濆瓨鐘舵�� + localDevice.IsOnline = device.IsOnline; + localDevice.ReSave(); + } - HdlThreadLogic.Current.RunMain(() => + HdlThreadLogic.Current.RunMain(() => + { + if (rowInfo != null) { - if (rowInfo != null) + rowInfo.MenuRow.isOnline = device.IsOnline == 1; + if (rowInfo.dicDetailRow != null) { - rowInfo.MenuRow.isOnline = device.IsOnline == 1; - if (rowInfo.dicDetailRow != null) + foreach (var detailRow in rowInfo.dicDetailRow.Values) { - foreach (var detailRow in rowInfo.dicDetailRow.Values) - { - detailRow.isOnline = rowInfo.MenuRow.isOnline; - } + detailRow.isOnline = rowInfo.MenuRow.isOnline; } } - }); - } + } + }); } /// <summary> @@ -706,6 +751,29 @@ }); } } + } + + #endregion + + #region 鈻� 浼犳劅鍣ㄦ姤璀________________________ + + /// <summary> + /// 寮�鍚紶鎰熷櫒鎶ヨ鐩戣 + /// </summary> + private void StartCheckDeviceAlarm() + { + HdlGatewayReceiveLogic.Current.AddAttributeEvent("DeviceListFormSensor", ReceiveComandDiv.A浼犳劅鍣ㄤ笂鎶�, (device) => + { + HdlThreadLogic.Current.RunMain(() => + { + if (this.dicRowInfo.ContainsKey(device.DeviceAddr) == false) + { + return; + } + //鏄剧ず浼犳劅鍣ㄤ笂鎶ョ殑鐗规晥 + this.dicRowInfo[device.DeviceAddr].MenuRow?.StartSensorPushAppeal(); + }); + }); } #endregion @@ -763,32 +831,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> @@ -801,6 +843,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]); @@ -809,8 +856,6 @@ //鍒涘缓鏂扮殑琛� this.AddDeviceMenuRow(deviceAddr); - - return; } } @@ -847,23 +892,6 @@ info.DeviveTypeName = Common.LocalDevice.Current.GetDeviceObjectText(dic[mac]); this.dicRowInfo[mac] = info; } - } - - #endregion - - #region 鈻� 鍏抽棴鐣岄潰___________________________ - - /// <summary> - /// 鐢婚潰鍏抽棴 - /// </summary> - public override void CloseForm() - { - HdlDeviceAttributeLogic.Current.RemoveEvent("DeviceListFormSensor"); - HdlDeviceAttributeLogic.Current.RemoveEvent("DeviceListFormReceivePushOnline"); - - GatewayResourse.NowSelectGateway = null; - - base.CloseForm(); } #endregion @@ -911,6 +939,23 @@ #endregion + #region 鈻� 鍏抽棴鐣岄潰___________________________ + + /// <summary> + /// 鐢婚潰鍏抽棴 + /// </summary> + public override void CloseFormBefore() + { + HdlGatewayReceiveLogic.Current.RemoveEvent("DeviceListFormSensor"); + HdlGatewayReceiveLogic.Current.RemoveEvent("DeviceListFormReceivePushOnline"); + + GatewayResourse.NowSelectGateway = null; + + base.CloseFormBefore(); + } + + #endregion + #region 鈻� 缁撴瀯浣撶被___________________________ /// <summary> -- Gitblit v1.8.0