From 40f46f32cb00f4304a691d4f027a76a13a9ebb6d Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期一, 16 十二月 2019 15:11:36 +0800
Subject: [PATCH] 2019.12.16

---
 ZigbeeApp/Shared/Phone/Device/Category/Category.cs |  252 ++++++++++++++++++++++++++------------------------
 1 files changed, 132 insertions(+), 120 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Device/Category/Category.cs b/ZigbeeApp/Shared/Phone/Device/Category/Category.cs
index 178c8f5..a9211dd 100644
--- a/ZigbeeApp/Shared/Phone/Device/Category/Category.cs
+++ b/ZigbeeApp/Shared/Phone/Device/Category/Category.cs
@@ -7,6 +7,7 @@
 using Shared.Phone.Device.CommonForm;
 using Shared.Phone.Device.AC;
 using Shared.Phone.UserCenter.DoorLock;
+using Shared.Phone.Device.DeviceLogic;
 
 namespace Shared.Phone.Device.Category
 {
@@ -344,7 +345,20 @@
                                     {
                                         var dimmableLight = deviceUI.CommonDevice as DimmableLight;
                                         dimmableLight.DeviceStatusReport = common.DeviceStatusReport;
-                                        //璁板綍銆佹洿鏂扮姸鎬�
+                                        if (dimmableLight.DeviceStatusReport.AttriBute == null || dimmableLight.DeviceStatusReport.AttriBute.Count == 0)
+                                        {
+                                            continue;
+                                        }
+                                        dimmableLight.OnOffStatus = dimmableLight.DeviceStatusReport.AttriBute[0].AttriButeData;
+                                        var row = rowLayout.GetChildren(0) as CategoryFunctionRow;
+                                        row.SetStatu(dimmableLight.OnOffStatus == 1);
+                                        row.SetStatuText(deviceUI.GetDeviceStatu());
+                                        dimmableLight.LastDateTime = DateTime.Now;
+                                    }
+                                    if (common.DeviceStatusReport.CluterID == 8)
+                                    {
+                                        var dimmableLight = deviceUI.CommonDevice as DimmableLight;
+                                        dimmableLight.DeviceStatusReport = common.DeviceStatusReport;
                                         if (dimmableLight.DeviceStatusReport.AttriBute == null || dimmableLight.DeviceStatusReport.AttriBute.Count == 0)
                                         {
                                             continue;
@@ -484,8 +498,9 @@
                 Gravity = Gravity.CenterVertical,
                 TextAlignment = TextAlignment.CenterLeft,
                 TextID = R.MyInternationalizationString.Category,
-                TextSize = 20,
+                TextSize = 24,
                 TextColor = ZigbeeColor.Current.GXCTextDeepBlackColor,
+                IsBold=true
             };
             topView.AddChidren(title);
 
@@ -842,6 +857,7 @@
                 //deviceListScrolView.SetCornerWithSameRadius(Application.GetRealHeight(50), HDLUtils.RectCornerTopLeft);
 
                 tempFunctionTypeBtn = new FunctionButton();
+                tempFunctionTypeBtn.Init("","");
 
                 EventHandler<MouseEventArgs> ShowSameTypeFunction = (object typeSender, MouseEventArgs mouseEventArgs) =>
                 {
@@ -873,7 +889,7 @@
                         {
                             var alert = new CustomAlert();
                             AddChidren(alert);
-                            alert.Show(Language.StringByID(R.MyInternationalizationString.ConfirmDelete));
+                            alert.Show(Language.StringByID(R.MyInternationalizationString.DeleteFunction));
                             alert.ResultEventHandler += (e2) =>
                             {
                                 if (e2)
@@ -910,8 +926,7 @@
                             {
                                 UserHomeView.ReadStatus(light, () =>
                                 {
-                                    light.ReadOnOffStatus();
-                                    light.ReadAttri(Cluster_ID.Identify, AttriButeId.Switch);
+                                    ReadDeviceAttributeLogic.Instance.SendLightStatuComand(deviceUI.CommonDevice);
                                 });
                             }
                             else
@@ -919,8 +934,7 @@
                                 //闃叉鐭椂闂村唴澶氭璇诲彇鐘舵��
                                 if (CommonPage.ReadDeviceStatuSpan < (DateTime.Now - light.LastDateTime).TotalSeconds)
                                 {
-                                    light.ReadOnOffStatus();
-                                    light.ReadAttri(Cluster_ID.Identify, AttriButeId.Switch);
+                                    ReadDeviceAttributeLogic.Instance.SendLightStatuComand(deviceUI.CommonDevice);
                                 }
                             }
 
@@ -1005,16 +1019,18 @@
                                 Tag = deviceUI,
                                 Radius = 0
                             };
-                            deviceTypeRowLayout.AddRightView(editBtn);
-                            editBtn.MouseUpEventHandler += deviceDetailHandler;
-
                             var delBtn = new Device.CommonForm.RowLayoutDeleteButton()
                             {
                                 Tag = deviceUI,
                                 Radius = 0
                             };
-                            deviceTypeRowLayout.AddRightView(delBtn);
-                            delBtn.MouseUpEventHandler += delEvent;
+                            if (room.IsSharedRoom == false)
+                            {
+                                deviceTypeRowLayout.AddRightView(editBtn);
+                                editBtn.MouseUpEventHandler += deviceDetailHandler;
+                                deviceTypeRowLayout.AddRightView(delBtn);
+                                delBtn.MouseUpEventHandler += delEvent;
+                            }
                         }
                         else if (deviceUI.CommonDevice.Type == ZigBee.Device.DeviceType.AirSwitch)
                         {
@@ -1029,16 +1045,14 @@
                             {
                                 UserHomeView.ReadStatus(airSwitch, () =>
                                 {
-                                    airSwitch.ReadOnOffStatus();
-                                    airSwitch.ReadAttri(Cluster_ID.Identify, AttriButeId.Switch);
+                                    ReadDeviceAttributeLogic.Instance.SendLightStatuComand(deviceUI.CommonDevice);
                                 });
                             }
                             else
                             {
                                 if ((DateTime.Now - airSwitch.LastDateTime).TotalSeconds > CommonPage.ReadDeviceStatuSpan)
                                 {
-                                    airSwitch.ReadOnOffStatus();
-                                    airSwitch.ReadAttri(Cluster_ID.Identify, AttriButeId.Switch);
+                                    ReadDeviceAttributeLogic.Instance.SendLightStatuComand(deviceUI.CommonDevice);
                                 }
                             }
 
@@ -1105,16 +1119,19 @@
                                 Tag = deviceUI,
                                 Radius = 0
                             };
-                            deviceTypeRowLayout.AddRightView(editBtn);
-                            editBtn.MouseUpEventHandler += deviceDetailHandler;
-
                             var delBtn = new Device.CommonForm.RowLayoutDeleteButton()
                             {
                                 Tag = deviceUI,
                                 Radius = 0
                             };
-                            deviceTypeRowLayout.AddRightView(delBtn);
-                            delBtn.MouseUpEventHandler += delEvent;
+                            if (room.IsSharedRoom == false)
+                            {
+                                deviceTypeRowLayout.AddRightView(editBtn);
+                                editBtn.MouseUpEventHandler += deviceDetailHandler;
+                                deviceTypeRowLayout.AddRightView(delBtn);
+                                delBtn.MouseUpEventHandler += delEvent;
+                            }
+
                         }
                         else if (deviceUI.CommonDevice.Type == ZigBee.Device.DeviceType.DimmableLight)
                         {
@@ -1129,18 +1146,14 @@
                             {
                                 UserHomeView.ReadStatus(dimmableLight, () =>
                                 {
-                                    dimmableLight.ReadAttri(Cluster_ID.Identify, AttriButeId.Switch);
-                                    dimmableLight.ReadOnOffStatus();
-                                    dimmableLight.ReadLevel();
+                                    ReadDeviceAttributeLogic.Instance.SendDimmableLightStatuComand(deviceUI.CommonDevice);
                                 });
                             }
                             else
                             {
                                 if ((DateTime.Now - dimmableLight.LastDateTime).TotalSeconds > CommonPage.ReadDeviceStatuSpan)
                                 {
-                                    dimmableLight.ReadAttri(Cluster_ID.Identify, AttriButeId.Switch);
-                                    dimmableLight.ReadOnOffStatus();
-                                    dimmableLight.ReadLevel();
+                                    ReadDeviceAttributeLogic.Instance.SendDimmableLightStatuComand(deviceUI.CommonDevice);
                                 }
                             }
 
@@ -1207,17 +1220,18 @@
                                 Tag = deviceUI,
                                 Radius = 0
                             };
-                            deviceTypeRowLayout.AddRightView(editBtn);
-                            editBtn.MouseUpEventHandler += deviceDetailHandler;
-
                             var delBtn = new Device.CommonForm.RowLayoutDeleteButton()
                             {
                                 Tag = deviceUI,
                                 Radius = 0
                             };
-                            deviceTypeRowLayout.AddRightView(delBtn);
-                            delBtn.MouseUpEventHandler += delEvent;
-
+                            if (room.IsSharedRoom == false)
+                            {
+                                deviceTypeRowLayout.AddRightView(editBtn);
+                                editBtn.MouseUpEventHandler += deviceDetailHandler;
+                                deviceTypeRowLayout.AddRightView(delBtn);
+                                delBtn.MouseUpEventHandler += delEvent;
+                            }
                         }
                         else if (deviceUI.CommonDevice.Type == ZigBee.Device.DeviceType.Thermostat)
                         {
@@ -1233,16 +1247,7 @@
                                 //鍙戦�佽鍙栫姸鎬佸懡浠�
                                 UserView.UserHomeView.ReadStatus(ac, () =>
                                 {
-                                    ac.ReadAttri(Cluster_ID.Identify, AttriButeId.Switch);
-                                    ac.ReadLocalTemperature();
-                                    ac.ReadCoolingSetpoint();
-                                    ac.ReadHeatingSetpoint();
-                                    ac.ReadAutoSetpoint();
-                                    ac.ReadFanMode();
-                                    ac.ReadSystemMode();
-                                    ac.ReadSystemFansSwingMode();
-                                    ac.ReadModeSupport();
-                                    ac.ReadCleanStatu();
+                                    ReadDeviceAttributeLogic.Instance.SendACStatuComand(deviceUI.CommonDevice);
                                 });
                             }
                             else
@@ -1250,16 +1255,7 @@
                                 //闃叉鐭椂闂村唴澶氭璇诲彇璁惧鐘舵��
                                 if ((DateTime.Now - ac.LastDateTime).TotalSeconds > CommonPage.ReadDeviceStatuSpan)
                                 {
-                                    ac.ReadAttri(Cluster_ID.Identify, AttriButeId.Switch);
-                                    ac.ReadLocalTemperature();
-                                    ac.ReadCoolingSetpoint();
-                                    ac.ReadHeatingSetpoint();
-                                    ac.ReadAutoSetpoint();
-                                    ac.ReadFanMode();
-                                    ac.ReadSystemMode();
-                                    ac.ReadSystemFansSwingMode();
-                                    ac.ReadModeSupport();
-                                    ac.ReadCleanStatu();
+                                    ReadDeviceAttributeLogic.Instance.SendACStatuComand(deviceUI.CommonDevice);
                                 }
                             }
 
@@ -1316,16 +1312,18 @@
                                 Tag = deviceUI,
                                 Radius = 0
                             };
-                            deviceTypeRowLayout.AddRightView(editBtn);
-                            editBtn.MouseUpEventHandler += deviceDetailHandler;
-
-                            var delBtn = new Device.CommonForm.RowLayoutDeleteButton()
+                            var delBtn = new CommonForm.RowLayoutDeleteButton()
                             {
                                 Tag = deviceUI,
                                 Radius = 0
                             };
-                            deviceTypeRowLayout.AddRightView(delBtn);
-                            delBtn.MouseUpEventHandler += delEvent;
+                            if (room.IsSharedRoom == false)
+                            {
+                                deviceTypeRowLayout.AddRightView(editBtn);
+                                editBtn.MouseUpEventHandler += deviceDetailHandler;
+                                deviceTypeRowLayout.AddRightView(delBtn);
+                                delBtn.MouseUpEventHandler += delEvent;
+                            }
 
                             deviceRow.ClickBtn.MouseUpEventHandler += (send2, e2) =>
                             {
@@ -1350,8 +1348,7 @@
                             {
                                 UserHomeView.ReadStatus(rollerShade, () =>
                                 {
-                                    rollerShade.ReadAttri(Cluster_ID.Identify, AttriButeId.Switch);
-                                    rollerShade.ReadWcdCurrentPositionLiftPercentage();
+                                    ReadDeviceAttributeLogic.Instance.SendCurtainStatuComand(deviceUI.CommonDevice);
                                 });
                             }
                             else
@@ -1359,8 +1356,7 @@
                                 //闃叉鐭椂闂村唴澶氭璇诲彇
                                 if ((DateTime.Now - rollerShade.LastDateTime).TotalSeconds > CommonPage.ReadDeviceStatuSpan)
                                 {
-                                    rollerShade.ReadAttri(Cluster_ID.Identify, AttriButeId.Switch);
-                                    rollerShade.ReadWcdCurrentPositionLiftPercentage();
+                                    ReadDeviceAttributeLogic.Instance.SendCurtainStatuComand(deviceUI.CommonDevice);
                                 }
                             }
 
@@ -1403,16 +1399,18 @@
                                 Tag = deviceUI,
                                 Radius = 0
                             };
-                            deviceTypeRowLayout.AddRightView(editBtn);
-                            editBtn.MouseUpEventHandler += deviceDetailHandler;
-
                             var delBtn = new Device.CommonForm.RowLayoutDeleteButton()
                             {
                                 Tag = deviceUI,
                                 Radius = 0
                             };
-                            deviceTypeRowLayout.AddRightView(delBtn);
-                            delBtn.MouseUpEventHandler += delEvent;
+                            if (room.IsSharedRoom == false)
+                            {
+                                deviceTypeRowLayout.AddRightView(editBtn);
+                                editBtn.MouseUpEventHandler += deviceDetailHandler;
+                                deviceTypeRowLayout.AddRightView(delBtn);
+                                delBtn.MouseUpEventHandler += delEvent;
+                            }
 
                             deviceRow.ClickBtn.MouseUpEventHandler += (send2, e2) =>
                             {
@@ -1455,15 +1453,17 @@
                             {
                                 Tag = deviceUI
                             };
-                            deviceTypeRowLayout.AddRightView(editBtn);
-                            editBtn.MouseUpEventHandler += deviceDetailHandler;
-
                             var delBtn = new Device.CommonForm.RowLayoutDeleteButton()
                             {
                                 Tag = deviceUI
                             };
-                            deviceTypeRowLayout.AddRightView(delBtn);
-                            delBtn.MouseUpEventHandler += delEvent;
+                            if (room.IsSharedRoom == false)
+                            {
+                                deviceTypeRowLayout.AddRightView(editBtn);
+                                editBtn.MouseUpEventHandler += deviceDetailHandler;
+                                deviceTypeRowLayout.AddRightView(delBtn);
+                                delBtn.MouseUpEventHandler += delEvent;
+                            }
                         }
                         else
                         {
@@ -1487,15 +1487,17 @@
                             {
                                 Tag = deviceUI
                             };
-                            deviceTypeRowLayout.AddRightView(editBtn);
-                            editBtn.MouseUpEventHandler += deviceDetailHandler;
-
                             var delBtn = new Device.CommonForm.RowLayoutDeleteButton()
                             {
                                 Tag = deviceUI
                             };
-                            deviceTypeRowLayout.AddRightView(delBtn);
-                            delBtn.MouseUpEventHandler += delEvent;
+                            if (room.IsSharedRoom == false)
+                            {
+                                deviceTypeRowLayout.AddRightView(editBtn);
+                                editBtn.MouseUpEventHandler += deviceDetailHandler;
+                                deviceTypeRowLayout.AddRightView(delBtn);
+                                delBtn.MouseUpEventHandler += delEvent;
+                            }
                         }
                     }
                 };
@@ -1647,7 +1649,6 @@
                     var sceneView = new SceneCategoryView(0, 0);
                     sceneScrolView.AddChidren(sceneView);
                     sceneView.Init(scene, room);
-                    sceneView.SetViewShadow(true);
                     GetDelayScene(sceneScrolView);
                 }
             }
@@ -1687,61 +1688,68 @@
         /// GetDelayScene
         /// </summary>
         /// <param name="scrolViewLayout"></param>
-        private void GetDelayScene(VerticalScrolViewLayout scrolViewLayout)
+        private async void GetDelayScene(VerticalScrolViewLayout scrolViewLayout)
         {
-            new System.Threading.Thread(async () =>
+            var catDelaySceneResponseAllData = await Scene.CatDelaySceneAsync();
+            if (catDelaySceneResponseAllData == null)
             {
-                var catDelaySceneResponseAllData = await Scene.CatDelaySceneAsync();
-                if (catDelaySceneResponseAllData == null)
-                {
-                    return;
-                }
-                var catDelaySceneResponseData = catDelaySceneResponseAllData.catDelaySceneResponseData;
-                if (catDelaySceneResponseData == null || catDelaySceneResponseData.DelayScenesList.Count == 0)
-                {
-                    return;
-                }
-                var delayList = catDelaySceneResponseData.DelayScenesList;
+                return;
+            }
+            var catDelaySceneResponseData = catDelaySceneResponseAllData.catDelaySceneResponseData;
+            if (catDelaySceneResponseData == null || catDelaySceneResponseData.DelayScenesList.Count == 0)
+            {
+                return;
+            }
+            var delayList = catDelaySceneResponseData.DelayScenesList;
 
-                Application.RunOnMainThread(() =>
+            for (int i = 0; scrolViewLayout != null && i < scrolViewLayout.ChildrenCount; i++)
+            {
+                var sceneView = scrolViewLayout.GetChildren(i) as SceneCategoryView;
+                foreach (var delayScenesListResponseInfo in delayList)
                 {
-                    for (int i = 0; scrolViewLayout != null && i < scrolViewLayout.ChildrenCount; i++)
+                    if (delayScenesListResponseInfo.ScenesId == sceneView.scene.Id)
                     {
-                        var sceneView = scrolViewLayout.GetChildren(i) as SceneCategoryView;
-                        foreach (var delayScenesListResponseInfo in delayList)
+                        sceneView.scene.RemainTime = delayScenesListResponseInfo.RemainTime;
+                        var remainTime= delayScenesListResponseInfo.RemainTime;
+                        if (remainTime > 0)
                         {
-                            if (delayScenesListResponseInfo.ScenesId == sceneView.scene.Id)
+                            new System.Threading.Thread(() =>
                             {
-                                sceneView.scene.RemainTime = delayScenesListResponseInfo.RemainTime;
-                                new System.Threading.Thread(() =>
+                                while (remainTime-- > 0)
                                 {
-                                    while (sceneView.scene.RemainTime > 0)
-                                    {
-                                        System.Threading.Thread.Sleep(1000);
-                                        Application.RunOnMainThread(() =>
-                                        {
-                                            sceneView.SetTimeText(CommonFormResouce.GetTimeString(sceneView.scene.RemainTime));
-                                        });
-                                        sceneView.scene.RemainTime -= 1;
-                                    }
+                                    System.Threading.Thread.Sleep(1000);
                                     Application.RunOnMainThread(() =>
                                     {
-                                        sceneView.SetTimeImage();
+                                        sceneView.SetTimeText(CommonFormResouce.GetTimeString(remainTime));
                                     });
-                                })
-                                { IsBackground = true }.Start();
-
-                                break;
-                            }
+                                }
+                                Application.RunOnMainThread(() =>
+                                {
+                                    sceneView.scene.RemainTime = 0;
+                                    sceneView.SetTimeImage();
+                                });
+                            })
+                            { IsBackground = true }.Start();
                         }
+                        break;
                     }
-                });
+                }
+            }
+        }
+
+        /// <summary>
+        /// GetExecScene
+        /// </summary>
+        /// <param name="scrolViewLayout"></param>
+        private void GetExecScene(VerticalScrolViewLayout scrolViewLayout)
+        {
+            new System.Threading.Thread(() =>
+            {
+
             })
             { IsBackground = true }.Start();
         }
-
         #endregion
-
 
         #region 鈼� 鑷姩鍖朹_________________________
 
@@ -1759,11 +1767,11 @@
                 Height = Application.GetRealHeight(170),
                 BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor,
                 X = Application.GetRealWidth(58),
-                Radius = (uint)Application.GetRealHeight(50),
+                //Radius = (uint)Application.GetRealHeight(50),
                 Y = Application.GetRealHeight(30),
             };
             functionSceneAutoBodyView.AddChidren(bjFrameLayout);
-
+            bjFrameLayout.SetCornerWithSameRadius(25, HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerBottomLeft);
             var sigBtn = new Button
             {
                 Width = Application.GetMinRealAverage(84),
@@ -1784,6 +1792,7 @@
                 TextID = MyInternationalizationString.logictemplate,
                 Gravity = Gravity.CenterVertical,
                 TextColor = ZigbeeColor.Current.LogicBtnSelectedColor,
+                TextSize=15,
             };
             bjFrameLayout.AddChidren(recommendtextBtn);
 
@@ -1813,10 +1822,11 @@
                 Height = functionSceneAutoBodyView.Height - bjFrameLayout.Height - bjFrameLayout.Y - scenehorizontalScrol.Height - Application.GetRealHeight(30),
                 BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor,
                 X = Application.GetRealWidth(58),
-                Radius = (uint)Application.GetRealHeight(50),
+                //Radius = (uint)Application.GetRealHeight(50),
                 Y = scenehorizontalScrol.Bottom,
             };
             functionSceneAutoBodyView.AddChidren(logicScrolView);
+            logicScrolView.SetCornerWithSameRadius(20, HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerBottomLeft);
 
 
             recommendswitchBtn.MouseUpEventHandler += (sender, e) =>
@@ -1854,6 +1864,7 @@
                             Y = Application.GetRealHeight(246 - 23 - 80),
                             TextAlignment = TextAlignment.CenterLeft,
                             TextColor = ZigbeeColor.Current.LogicBtnSaveTextColor,
+                            TextSize = 14,
                         };
                         frameLayout.AddChidren(logicnameBtn);
 
@@ -1964,6 +1975,7 @@
                     Y = Application.GetRealHeight(30),
                     TextAlignment = TextAlignment.CenterLeft,
                     TextColor = ZigbeeColor.Current.LogicTextBlackColor,
+                    TextSize = 14,
                 };
                 logicRowlayout.AddChidren(logicnameBtn);
 

--
Gitblit v1.8.0