From 25429f085093d89d543a0b90e30d0d62d1b7dac9 Mon Sep 17 00:00:00 2001
From: hxb <hxb@hdlchina.com.cn>
Date: 星期二, 30 八月 2022 09:37:38 +0800
Subject: [PATCH] 合并了IOS的代码

---
 ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs |  176 ++++++++++++++++++++++++++++++++++++----------------------
 1 files changed, 108 insertions(+), 68 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs
index 4e36633..2a36e2c 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs
@@ -151,7 +151,7 @@
             listView.BeginHeaderRefreshingAction += () =>
             {
                 //鍒锋柊璁惧鐨勮瘽,涓婚〉闇�瑕侀噸鏂板埛鏂�
-                UserView.UserPage.Instance.RefreshForm = true;
+                UserView.UserPage.Instance.RefreshAllForm = true;
 
                 HdlThreadLogic.Current.RunThread(() =>
                 {
@@ -261,7 +261,7 @@
                 btnPosition.ButtonClickEvent += (sender, e) =>
                 {
                     //瀹氫綅
-                    Common.LocalDevice.Current.SetFixedPositionCommand(listdevice[0]);
+                    Common.LocalDevice.Current.SetFixedPositionCommand(listdevice[0], true);
                 };
             }
 
@@ -269,7 +269,8 @@
             btnRight.ButtonClickEvent += (sender, e) =>
             {
                 //鍥炶矾鏁板ぇ浜�1鎵嶅睍寮�
-                if (Common.LocalDevice.Current.GetDevicesCountByMac(deviceMac) > 1)
+                var listMacDevice = LocalDevice.Current.GetDevicesByMac(deviceMac, false);
+                if (listMacDevice.Count > 1)
                 {
                     btnRight.IsSelected = !btnRight.IsSelected;
                     //灞曞紑鎴栬�呮姌鍙犳槑缁嗗垪琛�
@@ -277,9 +278,20 @@
                 }
                 else
                 {
+                    if (LocalDevice.Current.IsMiniLight(listMacDevice[0]) == true)
+                    {
+                        //mini澶滅伅鐨勫姛鑳借缃晫闈�
+                        var room = HdlRoomLogic.Current.GetRoomByDevice(listMacDevice[0]);
+                        var form = new MainPage.DeviceDetailInfoForm();
+                        form.AddForm(listMacDevice[0], room);
+                    }
+                    else
+                    {
+                        //璁惧淇℃伅鐣岄潰
+                        var form = new DeviceMacInfoEditorForm();
+                        form.AddForm(deviceMac);
+                    }
                     btnNew.Visible = false;
-                    var form = new DeviceMacInfoEditorForm();
-                    form.AddForm(deviceMac);
                     //鐣岄潰璺宠浆,璁板綍褰撳墠鐨勬鍦ㄦ搷浣滅殑璁惧鐨凪ac鍦板潃
                     this.nowActionDeviceMac = deviceMac;
                 }
@@ -296,9 +308,22 @@
                     form2.AddForm(deviceMac);
                     return;
                 }
+                var listMacDevice = LocalDevice.Current.GetDevicesByMac(deviceMac, false);
+                if (listMacDevice.Count > 0 && LocalDevice.Current.IsMiniLight(listMacDevice[0]) == true)
+                {
+                    //mini澶滅伅鐨勫姛鑳借缃晫闈�
+                    var room = HdlRoomLogic.Current.GetRoomByDevice(listMacDevice[0]);
+                    var form = new MainPage.DeviceDetailInfoForm();
+                    form.AddForm(listMacDevice[0], room);
+                }
+                else
+                {
+                    //璁惧淇℃伅鐣岄潰
+                    var form = new DeviceMacInfoEditorForm();
+                    form.AddForm(deviceMac);
+                }
+
                 btnNew.Visible = false;
-                var form = new DeviceMacInfoEditorForm();
-                form.AddForm(deviceMac);
                 //鐣岄潰璺宠浆,璁板綍褰撳墠鐨勬鍦ㄦ搷浣滅殑璁惧鐨凪ac鍦板潃
                 this.nowActionDeviceMac = deviceMac;
             };
@@ -352,7 +377,8 @@
                     }
                 }
                 else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFreshAir
-                       || deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleEnvironment)
+                       || deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleEnvironment
+                       || deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueEnvironment)
                 {
                     var listTemp = Common.LocalDevice.Current.GetPanelMatchEpointByMac(listDevice);
                     //灞曞紑妯″紡鏃讹紝鎵╁ぇ渚濇嵁涓�:瀹冩湁鍑犱釜瀛愭帶浠�
@@ -467,6 +493,16 @@
                 var form = new DeviceMacInfoEditorForm();
                 form.AddForm(device.DeviceAddr);
             }
+            else 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);
+            }
             else if (deviceEnumInfo.BeloneType == DeviceBeloneType.A绐楀笜)
             {
                 var form = new DeviceMacInfoEditorForm();
@@ -493,12 +529,6 @@
                 var form = new DeviceAirConditioner.IndoorUnitSettionForm();
                 form.AddForm((AC)device);
             }
-            //鐜闈㈡澘
-            else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueEnvironment)
-            {
-                var form = new DeviceFunctionSettionForm();
-                form.AddForm(device, true);
-            }
             //鏂伴闈㈡澘
             else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFreshAir)
             {
@@ -506,7 +536,7 @@
                 //骞叉帴鐐�
                 if (device.Type == DeviceType.FreshAir)
                 {
-                    var form = new DevicePanel.PanelFangyueFreshAirButtonSettionForm();
+                    var form = new DevicePanel.PanelSettionWithSourceForm();
                     form.AddForm(device);
                 }
                 else
@@ -521,7 +551,7 @@
 
                 if (device.Type == DeviceType.FreshAir || device.Type == DeviceType.Thermostat)
                 {
-                    var form = new DevicePanel.PanelSimpleEnvironmentButtonSettionForm();
+                    var form = new DevicePanel.PanelSettionWithSourceForm();
                     form.AddForm(device);
                 }
                 else
@@ -530,7 +560,7 @@
                     form.AddForm(device, true);
                 }
             }
-            //绠�绾︾幆澧冮潰鏉跨殑鎸夐敭閰嶇疆
+            //绠�绾﹀鍔熻兘闈㈡澘鐨勬寜閿厤缃�
             else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleMultifunction)
             {
                 var form = new DeviceFunctionSettionForm();
@@ -625,7 +655,7 @@
         {
             lock (dicRowInfo)
             {
-                Application.RunOnMainThread(() =>
+                HdlThreadLogic.Current.RunMain(() =>
                 {
                     if (this.listView == null)
                     {
@@ -674,7 +704,7 @@
         /// <summary>
         /// 婊戝姩鎺т欢涓嬫媺鍒锋柊
         /// </summary>
-        private async void ListViewBeginHeaderRefreshing()
+        private void ListViewBeginHeaderRefreshing()
         {
             //濡傛灉褰撳墠浣忓畢鏄櫄鎷熺殑
             if (Common.Config.Instance.Home.IsVirtually == true)
@@ -690,7 +720,7 @@
             }
             //濡傛灉鏄湪绾跨殑
             var nowGateway = HdlGatewayLogic.Current.GetLocalGateway(GatewayResourse.NowSelectGatewayId);
-            if (HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(nowGateway) == true)
+            if (HdlGatewayLogic.Current.CheckGatewayOnlineByMemory(nowGateway) == true)
             {
                 //妫�娴嬪箍鎾埌鐨勮繖涓綉鍏虫槸鍚︽嫢鏈変綇瀹匢D
                 ZbGateway realWay = null;
@@ -701,11 +731,16 @@
                     {
                         //鏄剧ず杩涘害鏉�
                         ProgressBar.Show();
-                        int result2 = await HdlGatewayLogic.Current.ReBindNewGateway(realWay);
+                        int result2 = HdlGatewayLogic.Current.ReBindNewGateway(realWay);
                         //鍏抽棴杩涘害鏉�
                         ProgressBar.Close();
                         if (result2 == -1)
                         {
+                            HdlThreadLogic.Current.RunMain(() =>
+                            {
+                                //闅愯棌涓嬫媺鍒锋柊鐗规晥
+                                listView.EndHeaderRefreshing();
+                            });
                             return;
                         }
                     }
@@ -717,7 +752,7 @@
             }
 
             //鑾峰彇鍏ㄩ儴璁惧
-            int result = LocalDevice.Current.SetDeviceToMemmoryByGateway(nowGateway);
+            int result = LocalDevice.Current.SetDeviceToMemmoryByGateway(nowGateway.GwId, false);
             if (this.Parent == null)
             {
                 return;
@@ -754,11 +789,11 @@
                 //鍒锋柊缃戝叧鍦ㄧ嚎鐘舵��
                 HdlGatewayLogic.Current.RefreshGatewayOnlineStatu(new List<ZbGateway>() { zbGateway });
 
-                Application.RunOnMainThread(() =>
+                HdlThreadLogic.Current.RunMain(() =>
                 {
                     if (this.gatewayViewRow != null && this.gatewayViewRow.zbGatewayId == selectGwId)
                     {
-                        bool online = HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(zbGateway);
+                        bool online = HdlGatewayLogic.Current.CheckGatewayOnlineByMemory(zbGateway);
                         //鍒锋柊鎺т欢鍦ㄧ嚎鐘舵��
                         this.gatewayViewRow?.RefreshOnlineStatu();
                         //鏍规嵁缃戝叧鍦ㄧ嚎鐘舵�佸埛鏂拌澶囧湪绾跨姸鎬�
@@ -782,7 +817,7 @@
             }
             if (gateWay.GwId == this.gatewayViewRow.zbGatewayId)
             {
-                Application.RunOnMainThread(() =>
+                HdlThreadLogic.Current.RunMain(() =>
                 {
                     //鐩稿悓鐨勭姸鎬�,涓嶉渶瑕佸啀娆″埛鏂�
                     if (this.gatewayViewRow.isOnline != online)
@@ -848,7 +883,7 @@
                                 this.ReceiveDeviceStatu(device);
                             }, ShowErrorMode.NO);
                         }
-                        System.Threading.Thread.Sleep(30);
+                        System.Threading.Thread.Sleep(50);
                     }
                 }
             });
@@ -954,10 +989,10 @@
                         return;
                     }
                     //娣诲姞鍗囩骇鍥轰欢淇℃伅(鎴愪笉鎴愬姛閮芥棤鎵�璋�)
-                    var result = HdlFirmwareUpdateLogic.AddFirmwareVersionInfo(FirmwareLevelType.ZigbeeDevice, ota.HwVersion.ToString(), ota.ImgTypeId.ToString());
+                    var result = HdlFirmwareUpdateLogic.AddFirmwareVersionInfo(FirmwareLevelType.A璁惧, ota.HwVersion.ToString(), ota.ImgTypeId.ToString());
 
                     //鑾峰彇璁惧鏈�鏂扮増鏈�
-                    var deviceFirmware = HdlFirmwareUpdateLogic.GetFirmwareMostVersionInfo(FirmwareLevelType.ZigbeeDevice,
+                    var deviceFirmware = HdlFirmwareUpdateLogic.GetFirmwareMostVersionInfo(FirmwareLevelType.A璁惧,
                         ota.HwVersion.ToString(),
                         ota.ImgTypeId.ToString(),
                         ota.ImgVersion);
@@ -984,7 +1019,7 @@
                         }
                     });
                 }
-            });
+            }, ShowErrorMode.NO);
         }
 
         #endregion
@@ -1034,14 +1069,27 @@
         {
             if (this.dicRowInfo.ContainsKey(deviceAddr) == true)
             {
-                var row = this.dicRowInfo[deviceAddr];
-                row.MenuRow?.RefreshControlInfo(true);
-                //鏄庣粏
-                if (row.dicDetailRow != null)
+                var rowInfo = this.dicRowInfo[deviceAddr];
+                //妫�娴嬭繖涓澶囨槸鍚﹁鍒犻櫎 2020.01.13鍙樻洿:杩藉姞Ota璁惧鐨勫垽鏂�
+                if (LocalDevice.Current.GetDevicesByMac(deviceAddr).Count == 0
+                    && LocalDevice.Current.GetOTADevice(deviceAddr) == null)
                 {
-                    foreach (var detailRow in row.dicDetailRow.Values)
+                    //绉婚櫎鎺т欢
+                    rowInfo.dicDetailRow = null;
+                    rowInfo.frameTable.RemoveFromParent();
+
+                    this.dicRowInfo.Remove(deviceAddr);
+                }
+                else
+                {
+                    //鍒锋柊璁惧淇℃伅
+                    rowInfo.MenuRow?.RefreshControlInfo(true);
+                    if (rowInfo.dicDetailRow != null)
                     {
-                        detailRow.RefreshControlInfo();
+                        foreach (var contr in rowInfo.dicDetailRow.Values)
+                        {
+                            contr?.RefreshControlInfo();
+                        }
                     }
                 }
             }
@@ -1105,32 +1153,24 @@
         /// </summary>
         public override int FormActionAgainEvent()
         {
+            if (GatewayResourse.AppOldSelectGatewayId != this.gatewayViewRow.zbGatewayId)
+            {
+                //杩欎釜缃戝叧琚暣鎺変簡,闇�瑕侀噸鏂板垵濮嬪寲鐣岄潰
+                this.nowActionDeviceMac = null;
+                this.oldShowRightMuneRow = null;
+                //閲嶆柊閫夋嫨缃戝叧
+                HdlGatewayLogic.Current.RefreshAppOldSelectGatewayId();
+
+                //鍒濆鍖栫晫闈�
+                this.InitMiddleFrame();
+
+                return 1;
+            }
+
             if (this.nowActionDeviceMac != null)
             {
-                var rowInfo = this.dicRowInfo[nowActionDeviceMac];
-                //妫�娴嬭繖涓澶囨槸鍚﹁鍒犻櫎 2020.01.13鍙樻洿:杩藉姞Ota璁惧鐨勫垽鏂�
-                if (Common.LocalDevice.Current.GetDevicesByMac(nowActionDeviceMac).Count == 0
-                    && Common.LocalDevice.Current.GetOTADevice(nowActionDeviceMac) == null)
-                {
-                    //绉婚櫎鎺т欢
-                    rowInfo.dicDetailRow = null;
-                    rowInfo.frameTable.RemoveFromParent();
-
-                    this.dicRowInfo.Remove(nowActionDeviceMac);
-                    rowInfo = null;
-                }
-                else
-                {
-                    //鍒锋柊璁惧淇℃伅
-                    rowInfo.MenuRow?.RefreshControlInfo(true);
-                    if (rowInfo.dicDetailRow != null)
-                    {
-                        foreach (var contr in rowInfo.dicDetailRow.Values)
-                        {
-                            contr?.RefreshControlInfo();
-                        }
-                    }
-                }
+                //鍒锋柊鎸囧畾璁惧琛岀殑淇℃伅
+                this.RefreshDeviceRow(this.nowActionDeviceMac);
             }
             //娓呯┖璁板綍
             this.nowActionDeviceMac = null;
@@ -1208,9 +1248,9 @@
             /// </summary>
             private NormalViewControl btnName = null;
             /// <summary>
-            /// 鍦ㄧ嚎鐘舵��
+            /// 鍦ㄧ嚎鐘舵��(鍒濆鐘舵�佷负鍦ㄧ嚎)
             /// </summary>
-            public bool isOnline = false;
+            public bool isOnline = true;
 
             /// <summary>
             /// 鑷畾涔夌綉鍏虫帶浠�
@@ -1255,11 +1295,11 @@
                 {
                     btnName.Text = HdlGatewayLogic.Current.GetGatewayName(zbway);
                     //鍦ㄧ嚎鐘舵��
-                    this.isOnline = HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(zbway);
-                    if (this.isOnline == false)
-                    {
-                        btnName.TextColor = UserCenterColor.Current.TextGrayColor1;
-                    }
+                    //this.isOnline = HdlGatewayLogic.Current.CheckGatewayOnlineByMemory(zbway);
+                    //if (this.isOnline == false)
+                    //{
+                    //    btnName.TextColor = UserCenterColor.Current.TextGrayColor1;
+                    //}
                 }
                 else
                 {
@@ -1324,7 +1364,7 @@
                     return;
                 }
                 //鍦ㄧ嚎鐘舵��
-                bool statu = HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(zbway);
+                bool statu = HdlGatewayLogic.Current.CheckGatewayOnlineByMemory(zbway);
                 if (this.isOnline != statu)
                 {
                     this.isOnline = statu;
@@ -1381,7 +1421,7 @@
                 btnName.Height = Application.GetRealHeight(60);
                 btnName.TextSize = 15;
                 btnName.Y = Application.GetRealHeight(57);
-                btnName.Text = "灏忓害灏忓害";
+                btnName.Text = "鏅鸿兘闊崇";
 
                 this.AddRightArrow();
                 this.AddMostRightView("", 300, false).Name = "smartSoundLayout";

--
Gitblit v1.8.0