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/Gateway/Manage/GatewayListForm.cs |  118 +++++++++++++++++++++++++++++++++-------------------------
 1 files changed, 67 insertions(+), 51 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Manage/GatewayListForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Manage/GatewayListForm.cs
index 8ab794a..8be5933 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Manage/GatewayListForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Manage/GatewayListForm.cs
@@ -2,7 +2,6 @@
 using System;
 using System.Collections.Generic;
 using System.Text;
-using System.Threading.Tasks;
 using ZigBee.Device;
 
 namespace Shared.Phone.UserCenter.GatewayManage
@@ -39,16 +38,20 @@
             //璁剧疆鏍囬淇℃伅
             base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uGatewayManagement));
 
-            //娣诲姞鍥炬爣
-            var btnAdd = new MostRightIconControl(69, 69);
-            btnAdd.UnSelectedImagePath = "Item/Add.png";
-            topFrameLayout.AddChidren(btnAdd);
-            btnAdd.InitControl();
-            btnAdd.ButtonClickEvent += (sender, e) =>
+            //灞曠ず妯℃澘涓嶅厑璁哥紪杈�
+            if (Config.Instance.Home.IsShowTemplate == false)
             {
-                var form = new GatewayAdd.NewGateWayMenuSelectForm();
-                form.AddForm();
-            };
+                //娣诲姞鍥炬爣
+                var btnAdd = new MostRightIconControl(69, 69);
+                btnAdd.UnSelectedImagePath = "Item/Add.png";
+                topFrameLayout.AddChidren(btnAdd);
+                btnAdd.InitControl();
+                btnAdd.ButtonClickEvent += (sender, e) =>
+                {
+                    var form = new GatewayAdd.NewGateWayMenuSelectForm();
+                    form.AddForm();
+                };
+            }
 
             //鍒濆鍖栦腑閮ㄦ帶浠�
             this.InitMiddleFrame();
@@ -95,15 +98,18 @@
             for (int i = 0; i < listway.Count; i++)
             {
                 //娣诲姞琛�
-                var gwId = HdlGatewayLogic.Current.GetGatewayId(listway[i]);
-                this.AddRowLayout(gwId, i != listway.Count - 1);
+                this.AddRowLayout(listway[i].GwId, i != listway.Count - 1);
             }
 
             //璋冩暣鍒楄〃鎺т欢鐨勯珮搴�
             this.listview.AdjustRealHeight(Application.GetRealHeight(23));
 
-            //寮�鍚綉鍏冲湪绾跨洃娴嬬殑绾跨▼
-            this.StartGatewayOnlieCheckThread(listway);
+            //濡傛灉鏄睍绀烘ā鏉跨殑璇�,涓嶉渶瑕佹娴�
+            if (Common.Config.Instance.Home.IsShowTemplate == false)
+            {
+                //寮�鍚綉鍏冲湪绾跨洃娴嬬殑绾跨▼
+                this.StartGatewayOnlieCheckThread(listway);
+            }
         }
 
         #endregion
@@ -131,7 +137,7 @@
             //鎻愮ず鏂扮増鏈�
             var btnNew = new InformationTipView(gatewayRow.btnIcon);
             btnNew.Visible = false;
-            gatewayRow.frameTable.AddChidren(btnNew, ChidrenBindMode.BindEventOnly);
+            gatewayRow.frameTable.AddChidren(btnNew, ChidrenBindMode.BindEvent);
             gatewayRow.AddTag("btnNew", btnNew);
             //鍗曞嚮浜嬩欢
             gatewayRow.frameTable.ButtonClickEvent += (sender, e) =>
@@ -147,36 +153,46 @@
                 form.AddForm(gateway);
             };
 
-            //鍒囨崲
-            var btnSwitch = new NormalViewControl(Application.GetRealWidth(184), gatewayRow.Height, false);
-            btnSwitch.BackgroundColor = 0xfffb744a;
-            btnSwitch.TextAlignment = TextAlignment.Center;
-            btnSwitch.TextColor = UserCenterColor.Current.White;
-            btnSwitch.TextSize = 12;
-            btnSwitch.TextID = R.MyInternationalizationString.uSwitch1;
-            if (strWayId == GatewayResourse.AppOldSelectGatewayId)
+            //濡傛灉鏄睍绀烘ā鏉跨殑璇�,涓嶈兘缂栬緫
+            if (Common.Config.Instance.Home.IsShowTemplate == true)
             {
-                btnSwitch.TextID = R.MyInternationalizationString.uRefresh;
+                return;
             }
-            gatewayRow.AddRightView(btnSwitch);
-            btnSwitch.ButtonClickEvent += (sender, e) =>
+
+            //闈炶櫄鎷熶綇瀹�,鎵嶆湁杩欎釜鍔熻兘
+            if (Common.Config.Instance.Home.IsVirtually == false)
             {
-                //鏄惁鍒囨崲鍒皗0}缃戝叧?
-                string msg = string.Format(Language.StringByID(R.MyInternationalizationString.uConfirmWantToSwitchTheGateway), "[" + gatewayRow.btnName.Text + "]");
+                //鍒囨崲
+                var btnSwitch = new NormalViewControl(Application.GetRealWidth(184), gatewayRow.Height, false);
+                btnSwitch.BackgroundColor = 0xfffb744a;
+                btnSwitch.TextAlignment = TextAlignment.Center;
+                btnSwitch.TextColor = UserCenterColor.Current.White;
+                btnSwitch.TextSize = 12;
+                btnSwitch.TextID = R.MyInternationalizationString.uSwitch1;
                 if (strWayId == GatewayResourse.AppOldSelectGatewayId)
                 {
-                    //鏄惁閲嶆柊鍒锋柊{0}缃戝叧?
-                    msg = string.Format(Language.StringByID(R.MyInternationalizationString.uConfirmWantToRefreshTheGateway), "[" + gatewayRow.btnName.Text + "]");
+                    btnSwitch.TextID = R.MyInternationalizationString.uRefresh;
                 }
-                this.ShowMassage(ShowMsgType.Confirm, msg, () =>
+                gatewayRow.AddRightView(btnSwitch);
+                btnSwitch.ButtonClickEvent += (sender, e) =>
                 {
-                    HdlThreadLogic.Current.RunThread(() =>
+                    //鏄惁鍒囨崲鍒皗0}缃戝叧?
+                    string msg = string.Format(Language.StringByID(R.MyInternationalizationString.uConfirmWantToSwitchTheGateway), "[" + gatewayRow.btnName.Text + "]");
+                    if (strWayId == GatewayResourse.AppOldSelectGatewayId)
                     {
-                        //鎵ц鍒囨崲缃戝叧鎿嶄綔
-                        this.DoSwitchGateway(strWayId);
+                        //鏄惁閲嶆柊鍒锋柊{0}缃戝叧?
+                        msg = string.Format(Language.StringByID(R.MyInternationalizationString.uConfirmWantToRefreshTheGateway), "[" + gatewayRow.btnName.Text + "]");
+                    }
+                    this.ShowMassage(ShowMsgType.Confirm, msg, () =>
+                    {
+                        HdlThreadLogic.Current.RunThread(() =>
+                        {
+                            //鎵ц鍒囨崲缃戝叧鎿嶄綔
+                            this.DoSwitchGateway(strWayId);
+                        });
                     });
-                });
-            };
+                };
+            }
 
             //瀹氫綅
             var btnPosition = gatewayRow.AddEditorControl(false);
@@ -207,7 +223,7 @@
                 {
                     HdlThreadLogic.Current.RunThread(() =>
                     {
-                        this.DeleteGateway(strWayId, gatewayRow);
+                        this.DeleteGateway(strWayId);
                     });
                 });
             };
@@ -226,7 +242,7 @@
                 btnNow.Y = Application.GetMinReal(23) + gatewayRow.frameTable.chidrenYaxis;
                 btnNow.UnSelectedImagePath = "Item/NowAcctionTip.png";
                 btnNow.X = gatewayRow.btnName.X + gatewayRow.btnName.GetRealWidthByText();
-                gatewayRow.frameTable.AddChidren(btnNow, ChidrenBindMode.BindEventOnly);
+                gatewayRow.frameTable.AddChidren(btnNow, ChidrenBindMode.BindEvent);
             }
         }
 
@@ -239,12 +255,12 @@
         /// </summary>
         /// <param name="strWayId"></param>
         /// <param name="row"></param>
-        private async void DeleteGateway(string strWayId, GatewayRowControl row)
+        private void DeleteGateway(string strWayId)
         {
             //鎵撳紑杩涘害鏉�
             this.ShowProgressBar();
             //鍒犻櫎浜戠缃戝叧
-            bool result = await HdlGatewayLogic.Current.DeleteGateway(strWayId);
+            bool result = HdlGatewayLogic.Current.DeleteGateway(strWayId);
             //鍏抽棴杩涘害鏉�
             this.CloseProgressBar();
             if (result == false)
@@ -274,9 +290,9 @@
         /// </summary>
         /// <param name="gatewayId"></param>
         /// <param name="online"></param>
-        private async void DoSwitchGateway(string gatewayId)
+        private void DoSwitchGateway(string gatewayId)
         {
-            var result = await HdlGatewayLogic.Current.DoSwitchGateway(gatewayId);
+            var result = HdlGatewayLogic.Current.DoSwitchGateway(gatewayId);
             if (result == false)
             {
                 return;
@@ -339,7 +355,7 @@
                     {
                         return;
                     }
-                    bool online = HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(way);
+                    bool online = HdlGatewayLogic.Current.CheckGatewayOnlineByMemory(way);
                     this.GatewayOnlinePush(way, online, true);
                 }
                 //缃戝叧鏂扮増鏈娴�
@@ -355,18 +371,18 @@
         /// <param name="hadGwOnline">2020.05.25杩藉姞:姝や綇瀹呮槸鍚︽嫢鏈夌綉鍏冲湪绾�</param>
         public override void GatewayOnlinePush(ZbGateway gateWay, bool online, bool hadGwOnline)
         {
-            Application.RunOnMainThread(() =>
+            HdlThreadLogic.Current.RunMain(() =>
             {
                 if (this.Parent == null)
                 {
                     return;
                 }
-                string gwid = HdlGatewayLogic.Current.GetGatewayId(gateWay);
+                string gwid = gateWay.GwId;
                 if (this.dicRowContr.ContainsKey(gwid) == true && this.dicRowContr[gwid] != null)
                 {
                     this.dicRowContr[gwid].IsOnline = online;
                 }
-            });
+            }, ShowErrorMode.NO);
         }
 
         #endregion
@@ -377,7 +393,7 @@
         /// 缃戝叧鏂扮増鏈娴�
         /// </summary>
         /// <param name="listWays"></param>
-        private async void CheckGatewayNewVersion(List<ZbGateway> listWays)
+        private void CheckGatewayNewVersion(List<ZbGateway> listWays)
         {
             foreach (var way in listWays)
             {
@@ -385,13 +401,13 @@
                 {
                     return;
                 }
-                if (HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(way) == false)
+                if (HdlGatewayLogic.Current.CheckGatewayOnlineByMemory(way) == false)
                 {
                     //涓嶅湪绾跨殑涓嶇敤鐞嗗畠
                     continue;
                 }
                 //鑾峰彇鏈�鏂扮増鏈�
-                var result = await HdlGatewayLogic.Current.GetGatewayAllNewVersion(way, ShowErrorMode.NO);
+                var result = HdlGatewayLogic.Current.GetGatewayAllNewVersion(way, ShowErrorMode.NO);
                 if (result == null)
                 {
                     continue;
@@ -399,8 +415,8 @@
                 if (result[0] != null || result[1] != null || result[2] != null)
                 {
                     //鏈夋柊鐗堟湰
-                    string gwid = HdlGatewayLogic.Current.GetGatewayId(way);
-                    Application.RunOnMainThread(() =>
+                    string gwid = way.GwId;
+                    HdlThreadLogic.Current.RunMain(() =>
                     {
                         if (this.dicRowContr.ContainsKey(gwid) == true && this.dicRowContr[gwid] != null)
                         {

--
Gitblit v1.8.0