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/Safety/SafetyManagementMainForm.cs |  109 +++++++++++++++++++++++++-----------------------------
 1 files changed, 51 insertions(+), 58 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Safety/SafetyManagementMainForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Safety/SafetyManagementMainForm.cs
index c470209..ea700d3 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Safety/SafetyManagementMainForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Safety/SafetyManagementMainForm.cs
@@ -78,12 +78,23 @@
             frameLayoutDraw.Height = frameBack.Height - Application.GetRealHeight(181);
             frameBack.AddChidren(frameLayoutDraw);
 
+            //璁$畻瀹藉害浣跨敤
+            var btnTemp = new ButtonBase();
+            btnTemp.TextSize = 16;
+            btnTemp.IsBold = true;
+
+            btnTemp.TextID = R.MyInternationalizationString.uSecurityLog;
+            int frameLogWidth = btnTemp.GetRealWidthByText() + Application.GetRealWidth(30);
+
+            btnTemp.TextID = R.MyInternationalizationString.uSensorStatu;
+            int frameSensorWidth = btnTemp.GetRealWidthByText() + Application.GetRealWidth(30);
+
             //瀹夐槻璁板綍(鐐瑰嚮鑼冨洿鏈夌偣灏忥紝闇�瑕佹墿澶у畠鐨勭偣鍑昏寖鍥�)
             var frameLog = new FrameLayoutStatuControl();
             frameLog.UseClickStatu = false;
             frameLog.Height = Application.GetRealHeight(123);
-            frameLog.Width = Application.GetRealWidth(273);
-            frameLog.X = Application.GetRealWidth(259);
+            frameLog.Width = frameLogWidth;
+            frameLog.X = (frameBack.Width - frameLogWidth - frameSensorWidth) / 2;
             frameLog.Y = Application.GetRealHeight(58);
             frameBack.AddChidren(frameLog);
             //鏍囬
@@ -96,7 +107,8 @@
             //搴曠嚎
             var btnLogLine = new NormalViewControl(40, 10, true);
             btnLogLine.Y = Application.GetRealHeight(86);
-            btnLogLine.X = btnLog.X + btnLog.Width / 2 - Application.GetRealWidth(40) / 2;
+            //btnLogLine.X = btnLog.X + btnLog.Width / 2 - Application.GetRealWidth(40) / 2;
+            btnLogLine.Gravity = Gravity.CenterHorizontal;
             btnLogLine.Radius = (uint)Application.GetRealHeight(10) / 2;
             btnLogLine.BackgroundColor = UserCenterColor.Current.TextOrangeColor;
             frameLog.AddChidren(btnLogLine, ChidrenBindMode.BindEvent);
@@ -106,7 +118,7 @@
             var frameSensor = new FrameLayoutStatuControl();
             frameSensor.UseClickStatu = false;
             frameSensor.Height = frameLog.Height;
-            frameSensor.Width = frameLog.Width;
+            frameSensor.Width = frameSensorWidth;
             frameSensor.X = frameLog.Right;
             frameSensor.Y = frameLog.Y;
             frameBack.AddChidren(frameSensor);
@@ -123,7 +135,8 @@
             var btnSensorLine = new NormalViewControl(40, 10, true);
             btnSensorLine.BackgroundColor = UserCenterColor.Current.TextOrangeColor;
             btnSensorLine.Y = btnLogLine.Y;
-            btnSensorLine.X = btnSensor.X + btnSensor.Width / 2 - Application.GetRealWidth(40) / 2;
+            //btnSensorLine.X = btnSensor.X + btnSensor.Width / 2 - Application.GetRealWidth(40) / 2;
+            btnSensorLine.Gravity = Gravity.CenterHorizontal;
             btnSensorLine.Radius = (uint)Application.GetRealHeight(10) / 2;
             frameSensor.AddChidren(btnSensorLine, ChidrenBindMode.BindEvent);
 
@@ -254,7 +267,7 @@
                         UserCenterResourse.ResidenceOption.Save();
                         btnShortCut.IsSelected = false;
                         //鍙栨秷涓婚〉鐨勩�屽畨闃层�嶆嵎寰勭殑璇�,涓婚〉闇�瑕侀噸鏂板埛鏂�
-                        UserView.UserPage.Instance.RefreshForm = true;
+                        UserView.UserPage.Instance.RefreshAllForm = true;
                     });
                 }
                 else
@@ -266,7 +279,7 @@
                         UserCenterResourse.ResidenceOption.Save();
                         btnShortCut.IsSelected = true;
                         //鍒涘缓涓婚〉鐨勩�屽畨闃层�嶆嵎寰勭殑璇�,涓婚〉闇�瑕侀噸鏂板埛鏂�
-                        UserView.UserPage.Instance.RefreshForm = true;
+                        UserView.UserPage.Instance.RefreshAllForm = true;
                     });
                 }
             };
@@ -315,7 +328,7 @@
             this.CloseProgressBar();
 
             //鏁版嵁鍒濆鍖栧畬鎴愬悗
-            Application.RunOnMainThread(() =>
+            HdlThreadLogic.Current.RunMain(() =>
             {
                 //鍒濆鍖栧ご閮ㄧ殑閭d笁涓浘鏍�
                 garrisonControl = new SafetyMasterControl();
@@ -534,79 +547,59 @@
             //浠庤澶囧垪琛ㄤ腑鑾峰彇鍦ㄧ嚎鐘舵��
             HdlThreadLogic.Current.RunThread(() =>
             {
-                //棣栧厛鑾峰彇杩欎簺浼犳劅鍣ㄦ墍鍦ㄧ殑缃戝叧
-                var listWay = new List<ZbGateway>();
                 foreach (var device in listDevice)
-                {
-                    ZbGateway realWay = null;
-                    //鏄惁瀛樺湪鐪熷疄鐗╃悊缃戝叧
-                    if (HdlGatewayLogic.Current.GetRealGateway(ref realWay, device.CurrentGateWayId) == false)
-                    {
-                        continue;
-                    }
-                    listWay.Add(realWay);
-                }
-                foreach (var zbway in listWay)
                 {
                     if (this.Parent == null)
                     {
                         //鐣岄潰鍏抽棴
                         return;
                     }
-                    int statu = 0;
-                    var list = Common.LocalDevice.Current.GetDeviceListFromGateway(zbway, ref statu, false, ShowErrorMode.NO);
-                    if (statu != -1)
+                    var deviceInfo = Common.LocalDevice.Current.ReadDeviceEpointDeviceInfo(device);
+                    if (deviceInfo != null)
                     {
-                        for (int i = 0; i < list.Count; i++)
-                        {
-                            //璁剧疆璁惧鍦ㄧ嚎鐘舵��
-                            this.ReceiveDeviceStatuPush(list[i]);
-                        }
+                        //璁剧疆璁惧鍦ㄧ嚎鐘舵��
+                        this.ReceiveDeviceStatuPush(device, deviceInfo);
                     }
+                    System.Threading.Thread.Sleep(50);
                 }
-            });
+            }, ShowErrorMode.NO);
         }
 
         /// <summary>
         /// 鎺ュ彈璁惧鍦ㄧ嚎鎺ㄩ��
         /// </summary>
         /// <param name="device"></param>
-        private void ReceiveDeviceStatuPush(CommonDevice device)
+        private void ReceiveDeviceStatuPush(CommonDevice device, CommonDevice.DeviceInfoData deviceInfo)
         {
             if (this.Parent == null)
             {
                 //鐣岄潰鍏抽棴
                 return;
             }
-
-            lock (objOnlineLock)
+            string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
+            if (this.dicSensorStatuView.ContainsKey(mainkeys) == true)
             {
-                string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
-                if (this.dicSensorStatuView.ContainsKey(mainkeys) == true)
+                CommonDevice Loacldevice = Common.LocalDevice.Current.GetDevice(mainkeys);
+                if (Loacldevice == null)
                 {
-                    CommonDevice Loacldevice = Common.LocalDevice.Current.GetDevice(mainkeys);
-                    if (Loacldevice == null)
-                    {
-                        return;
-                    }
-                    //鍦ㄧ嚎鐘舵�佷竴鏍风殑璇濓紝涓嶉渶瑕佸埛鏂�
-                    if (Loacldevice.IsOnline == device.IsOnline)
-                    {
-                        return;
-                    }
-                    //淇濆瓨鐘舵��
-                    Loacldevice.IsOnline = device.IsOnline;
-                    Loacldevice.ReSave();
-
-                    //鍥犱负杩欐槸鎺ㄩ�佽繃鏉ョ殑锛屾垜涓嶄繚璇侀偅涓�鐬棿杩欎釜涓滆タ浼氫笉浼氳绉婚櫎
-                    var control = this.dicSensorStatuView[mainkeys];
-                    Application.RunOnMainThread(() =>
-                    {
-                        //璁剧疆鎺т欢鐨勫湪绾跨姸鎬佹枃鏈晥鏋�
-                        bool bolOnline = Common.LocalDevice.Current.CheckDeviceIsOnline(device);
-                        control?.SetOnlineStatu(bolOnline);
-                    });
+                    return;
                 }
+                //鍦ㄧ嚎鐘舵�佷竴鏍风殑璇濓紝涓嶉渶瑕佸埛鏂�
+                if (Loacldevice.IsOnline == deviceInfo.IsOnline)
+                {
+                    return;
+                }
+                //淇濆瓨鐘舵��
+                Loacldevice.IsOnline = deviceInfo.IsOnline;
+
+                //鍥犱负杩欐槸鎺ㄩ�佽繃鏉ョ殑锛屾垜涓嶄繚璇侀偅涓�鐬棿杩欎釜涓滆タ浼氫笉浼氳绉婚櫎
+                var control = this.dicSensorStatuView[mainkeys];
+                HdlThreadLogic.Current.RunMain(() =>
+                {
+                    //璁剧疆鎺т欢鐨勫湪绾跨姸鎬佹枃鏈晥鏋�
+                    bool bolOnline = Common.LocalDevice.Current.CheckDeviceIsOnline(device);
+                    control?.SetOnlineStatu(bolOnline);
+                });
             }
         }
 
@@ -672,7 +665,7 @@
                 }
                 dicAlarm = null;
 
-                Application.RunOnMainThread(() =>
+                HdlThreadLogic.Current.RunMain(() =>
                 {
                     if (this.Parent == null)
                     {
@@ -743,7 +736,7 @@
                 }
             }
 
-            Application.RunOnMainThread(() =>
+            HdlThreadLogic.Current.RunMain(() =>
             {
                 if (this.TodaySafeguardFrame != null)
                 {

--
Gitblit v1.8.0