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/Device/Light/LightControl.cs |   59 ++++++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 40 insertions(+), 19 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Device/Light/LightControl.cs b/ZigbeeApp/Shared/Phone/Device/Light/LightControl.cs
old mode 100755
new mode 100644
index 54e4f18..ed3cd89
--- a/ZigbeeApp/Shared/Phone/Device/Light/LightControl.cs
+++ b/ZigbeeApp/Shared/Phone/Device/Light/LightControl.cs
@@ -2,6 +2,7 @@
 using System.Collections.Generic;
 using Shared.Common;
 using Shared.Phone.Device.CommonForm;
+using Shared.Phone.Device.DeviceLogic;
 using Shared.Phone.UserView;
 using ZigBee.Device;
 namespace Shared.Phone.Device.Light
@@ -62,6 +63,10 @@
 
         private Button StatuBtn;
 
+        /// <summary>
+        /// IsDrawerLockMode
+        /// </summary>
+        public bool IsDrawerLockMode;
         #endregion
 
         #region 鈼� 鎺ュ彛__________________________
@@ -121,10 +126,10 @@
                         }
                         if (deviceUI.CommonDevice.Type == DeviceType.OnOffOutput)
                         {
-                            if ((common as ToggleLight).DeviceStatusReport.CluterID == 6)
+                            if (common.DeviceStatusReport.CluterID == 6)
                             {
                                 var light = deviceUI.CommonDevice as ToggleLight;
-                                light.DeviceStatusReport = (common as ToggleLight).DeviceStatusReport;
+                                light.DeviceStatusReport = common.DeviceStatusReport;
                                 //璁板綍銆佹洿鏂扮姸鎬�
                                 if (light.DeviceStatusReport.AttriBute == null || light.DeviceStatusReport.AttriBute.Count == 0)
                                 {
@@ -145,7 +150,30 @@
             }
             else if (typeTag == "OnlineStatusChange")
             {
-
+                Application.RunOnMainThread(() =>
+                {
+                    try
+                    {
+                        var deviceUI = device;
+                        //璁惧涓虹┖
+                        if (deviceUI.CommonDevice == null)
+                        {
+                            return;
+                        }
+                        //鏄惁涓哄綋鍓嶈澶�
+                        if (deviceUI.CommonDevice.DeviceEpoint != common.DeviceEpoint || deviceUI.CommonDevice.DeviceAddr != common.DeviceAddr)
+                        {
+                            return;
+                        }
+                        deviceUI.CommonDevice.IsOnline = common.IsOnline;
+                        //deviceIMG.IsSelected = switchBtn.IsSelected = deviceUI.CommonDevice.IsOnline == 1;
+                        deviceUI.CommonDevice.LastDateTime = DateTime.Now;
+                    }
+                    catch (Exception ex)
+                    {
+                        System.Console.WriteLine($"Error:{ex.Message}");
+                    }
+                });
             }
         }
         #endregion
@@ -157,8 +185,12 @@
         public override void RemoveFromParent()
         {
             ZbGateway.StatusList.Remove(this);
-            action();
-            action = null;
+            //action();
+            //action = null;
+            if (IsDrawerLockMode)
+            {
+                CommonPage.Instance.IsDrawerLockMode = false;
+            }
             RemoveUpdateControlDeviceStatuAction();
             base.RemoveFromParent();
         }
@@ -197,8 +229,7 @@
             {
                 UserHomeView.ReadStatus(light, () =>
                 {
-                    light.ReadOnOffStatus();
-                    light.ReadAttri(Cluster_ID.Identify, AttriButeId.Switch);
+                    ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device.CommonDevice);
                 });
             }
             else
@@ -206,8 +237,7 @@
                 //闃叉鐭椂闂村唴澶氭璇诲彇鐘舵��
                 if (CommonPage.ReadDeviceStatuSpan < (DateTime.Now - light.LastDateTime).TotalSeconds)
                 {
-                    light.ReadOnOffStatus();
-                    light.ReadAttri(Cluster_ID.Identify, AttriButeId.Switch);
+                    ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device.CommonDevice);
                 }
             }
 
@@ -243,15 +273,6 @@
                 RemoveFromParent();
             };
 
-            var sharedBtn = new Button
-            {
-                X = Application.GetRealWidth(850),
-                Width = Application.GetMinReal(69),
-                Height = Application.GetMinReal(69),
-                Gravity = Gravity.CenterVertical,
-                UnSelectedImagePath = "Item/Shared.png"
-            };
-            top.topView.AddChidren(sharedBtn);
 
             var moreBtn = new Button
             {
@@ -320,7 +341,7 @@
                 Height = Application.GetRealHeight(60),
                 Gravity = Gravity.CenterHorizontal,
                 TextColor = ZigbeeColor.Current.GXCTextGrayColor,
-                Text=CommonFormResouce.GetSwitchStatu(device.CommonDevice.IsOnline==1)
+                Text=CommonFormResouce.GetSwitchStatu((device.CommonDevice as ToggleLight).OnOffStatus == 1)
             };
             itemView.AddChidren(StatuBtn);
 

--
Gitblit v1.8.0