From 9bea5849559521fe09b681025958886e9d6e2d74 Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期二, 24 十二月 2019 14:29:51 +0800
Subject: [PATCH] 2019.12.24

---
 ZigbeeApp/Shared/Phone/Device/Category/Category.cs |   93 ++++++++++++++++++++++++++++++----------------
 1 files changed, 61 insertions(+), 32 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Device/Category/Category.cs b/ZigbeeApp/Shared/Phone/Device/Category/Category.cs
index 9ebea2a..10ac345 100644
--- a/ZigbeeApp/Shared/Phone/Device/Category/Category.cs
+++ b/ZigbeeApp/Shared/Phone/Device/Category/Category.cs
@@ -195,7 +195,7 @@
                                         light.DeviceStatusReport = common.DeviceStatusReport;
                                         light.OnOffStatus = light.DeviceStatusReport.AttriBute[0].AttriButeData;
                                         var row = rowLayout.GetChildren(0) as CategoryFunctionRow;
-                                        row.SetStatu(light.OnOffStatus == 1);
+                                        row.IsSelected = light.OnOffStatus == 1;
                                         row.SetStatuText(deviceUI.GetDeviceStatu());
                                         light.LastDateTime = DateTime.Now;
                                     }
@@ -203,8 +203,6 @@
                                     {
                                         deviceUI.CommonDevice.IsOnline = 1;
                                         deviceUI.CommonDevice.LastDateTime = DateTime.Now;
-                                        var row = rowLayout.GetChildren(0) as CategoryFunctionRow;
-                                        row.SetStatu(true);
                                     }
                                     break;
 
@@ -216,7 +214,7 @@
                                         airSwitch.DeviceStatusReport = common.DeviceStatusReport;
                                         airSwitch.OnOffStatus = airSwitch.DeviceStatusReport.AttriBute[0].AttriButeData;
                                         var row = rowLayout.GetChildren(0) as CategoryFunctionRow;
-                                        row.SetStatu(airSwitch.OnOffStatus == 1);
+                                        row.IsSelected = airSwitch.OnOffStatus == 1;
                                         row.SetStatuText(deviceUI.GetDeviceStatu());
                                         airSwitch.LastDateTime = DateTime.Now;
                                     }
@@ -224,8 +222,6 @@
                                     {
                                         deviceUI.CommonDevice.IsOnline = 1;
                                         deviceUI.CommonDevice.LastDateTime = DateTime.Now;
-                                        var row = rowLayout.GetChildren(0) as CategoryFunctionRow;
-                                        row.SetStatu(true);
                                     }
                                     break;
                                 case DeviceType.WindowCoveringDevice:
@@ -248,6 +244,7 @@
                                             rollerShade.DeviceStatusReport = common.DeviceStatusReport;
                                             rollerShade.WcdCurrentPositionLiftPercentage = common.DeviceStatusReport.AttriBute[0].AttriButeData;
                                             row.SetStatuText($"{Language.StringByID(R.MyInternationalizationString.Current)} { deviceUI.GetDeviceStatu()}");
+                                            row.IsSelected = rollerShade.WcdCurrentPositionLiftPercentage != 0;
                                             rollerShade.LastDateTime = DateTime.Now;
                                         }
                                     }
@@ -255,8 +252,6 @@
                                     {
                                         deviceUI.CommonDevice.IsOnline = 1;
                                         deviceUI.CommonDevice.LastDateTime = DateTime.Now;
-                                        var row = rowLayout.GetChildren(0) as CategoryFunctionForWinRow;
-                                        row.SetStatu(true);
                                     }
                                     break;
 
@@ -307,7 +302,7 @@
                                             }
                                         }
                                         var row = rowLayout.GetChildren(0) as CategoryFunctionRow;
-                                        row.SetStatu(ac.currentSystemMode != 0);
+                                        row.IsSelected = ac.currentSystemMode != 0;
                                         row.SetStatuText(deviceUI.GetDeviceStatu());
                                     }
 
@@ -331,7 +326,7 @@
                                             }
                                         }
                                         var row = rowLayout.GetChildren(0) as CategoryFunctionRow;
-                                        row.SetStatu(ac.currentSystemMode != 0);
+                                        row.IsSelected = ac.currentSystemMode != 0;
                                         row.SetStatuText(deviceUI.GetDeviceStatu());
                                     }
 
@@ -340,8 +335,6 @@
                                         var ac = deviceUI.CommonDevice as ZigBee.Device.AC;
                                         ac.IsOnline = 1;
                                         ac.LastDateTime = DateTime.Now;
-                                        var row = rowLayout.GetChildren(0) as CategoryFunctionRow;
-                                        row.SetStatu(true);
                                     }
                                     break;
                                 case DeviceType.DimmableLight:
@@ -352,7 +345,7 @@
                                         dimmableLight.DeviceStatusReport = common.DeviceStatusReport;
                                         dimmableLight.OnOffStatus = dimmableLight.DeviceStatusReport.AttriBute[0].AttriButeData;
                                         var row = rowLayout.GetChildren(0) as CategoryFunctionRow;
-                                        row.SetStatu(dimmableLight.OnOffStatus == 1);
+                                        row.IsSelected = dimmableLight.OnOffStatus == 1;
                                         row.SetStatuText(deviceUI.GetDeviceStatu());
                                         dimmableLight.LastDateTime = DateTime.Now;
                                     }
@@ -362,7 +355,7 @@
                                         dimmableLight.DeviceStatusReport = common.DeviceStatusReport;
                                         dimmableLight.Level = dimmableLight.DeviceStatusReport.AttriBute[0].AttriButeData;
                                         var row = rowLayout.GetChildren(0) as CategoryFunctionRow;
-                                        row.SetStatu(dimmableLight.OnOffStatus == 1);
+                                        row.IsSelected = dimmableLight.OnOffStatus == 1;
                                         row.SetStatuText(deviceUI.GetDeviceStatu());
                                         dimmableLight.LastDateTime = DateTime.Now;
                                     }
@@ -370,8 +363,6 @@
                                     {
                                         deviceUI.CommonDevice.IsOnline = 1;
                                         deviceUI.CommonDevice.LastDateTime = DateTime.Now;
-                                        var row = rowLayout.GetChildren(0) as CategoryFunctionRow;
-                                        row.SetStatu(true);
                                     }
                                     break;
                             }
@@ -405,37 +396,66 @@
                             {
                                 case DeviceType.OnOffOutput:
                                     deviceUI.CommonDevice.IsOnline = common.IsOnline;
-                                    var row = rowLayout.GetChildren(0) as CategoryFunctionRow;
-                                    row.SetStatu(deviceUI.CommonDevice.IsOnline == 1);
                                     deviceUI.CommonDevice.LastDateTime = DateTime.Now;
                                     break;
 
                                 case DeviceType.AirSwitch:
                                     deviceUI.CommonDevice.IsOnline = common.IsOnline;
-                                    var row1 = rowLayout.GetChildren(0) as CategoryFunctionRow;
-                                    row1.SetStatu(deviceUI.CommonDevice.IsOnline == 1);
                                     deviceUI.CommonDevice.LastDateTime = DateTime.Now;
                                     break;
 
                                 case DeviceType.WindowCoveringDevice:
                                     deviceUI.CommonDevice.LastDateTime = DateTime.Now;
                                     deviceUI.CommonDevice.IsOnline = common.IsOnline;
-                                    var row2 = rowLayout.GetChildren(0) as CategoryFunctionForWinRow;
-                                    row2.SetStatu(deviceUI.CommonDevice.IsOnline == 1);
                                     break;
 
                                 case DeviceType.DimmableLight:
                                     deviceUI.CommonDevice.LastDateTime = DateTime.Now;
                                     deviceUI.CommonDevice.IsOnline = common.IsOnline;
-                                    var row3 = rowLayout.GetChildren(0) as CategoryFunctionRow;
-                                    row3.SetStatu(deviceUI.CommonDevice.IsOnline == 1);
                                     break;
 
                                 case DeviceType.Thermostat:
                                     deviceUI.CommonDevice.LastDateTime = DateTime.Now;
                                     deviceUI.CommonDevice.IsOnline = common.IsOnline;
-                                    var row5 = rowLayout.GetChildren(0) as CategoryFunctionRow;
-                                    row5.SetStatu(deviceUI.CommonDevice.IsOnline == 1);
+                                    break;
+                            }
+                        }
+                    }
+                    catch (Exception ex)
+                    {
+                        System.Console.WriteLine($"鍒嗙被璁惧鐘舵��-Error:{ex.Message}");
+                    }
+                });
+            }
+            else if (typeTag == "IASInfoReport")
+            {
+                Application.RunOnMainThread(() =>
+                {
+                    try
+                    {
+                        for (int i = 0; deviceListScrolView != null && i < deviceListScrolView.ChildrenCount; i++)
+                        {
+                            var rowLayout = deviceListScrolView.GetChildren(i) as RowLayout;
+                            var deviceUI = rowLayout.Tag as DeviceUI;
+                            if (deviceUI == null || deviceUI.CommonDevice == null)
+                            {
+                                continue;
+                            }
+                            if (deviceUI.CommonDevice.DeviceAddr != common.DeviceAddr || deviceUI.CommonDevice.DeviceEpoint != common.DeviceEpoint)
+                            {
+                                continue;
+                            }
+                            switch (deviceUI.CommonDevice.Type)
+                            {
+                                case DeviceType.IASZone:
+                                    //寮�鍏冲姛鑳�
+                                    var ias = common as IASZone;
+                                    var iAS = deviceUI.CommonDevice as ZigBee.Device.IASZone;
+                                    iAS.iASInfo = ias.iASInfo;
+                                    var row = rowLayout.GetChildren(0) as CategoryFunctionRow;
+                                    row.IsSelected = iAS.iASInfo?.Alarm1 == 1;
+                                    row.SetStatuText(deviceUI.GetDeviceStatu());
+                                    iAS.LastDateTime = DateTime.Now;
                                     break;
                             }
                         }
@@ -986,13 +1006,22 @@
                                 {
                                     if (e2)
                                     {
-                                        Shared.Common.Room.CurrentRoom.DeleteDevice(deviceUI.CommonDevice);
-                                        deviceListScrolView.RemoveViewByTag((delSender as Button).Tag);
-                                        sameTypeList.Remove(deviceUI);
-                                        if (sameTypeList.Count == 0)
+                                        if(curRoom.IsLove)
                                         {
-                                            RefreshBodyView();
+                                            Shared.Common.Room.CurrentRoom.DeleteDevice(deviceUI.FileName);
+                                            deviceListScrolView.RemoveViewByTag((delSender as Button).Tag);
+                                            sameTypeList.Remove(deviceUI);
                                         }
+                                        else
+                                        {
+                                            Shared.Common.Room.CurrentRoom.DeleteDevice(deviceUI.CommonDevice);
+                                            deviceListScrolView.RemoveViewByTag((delSender as Button).Tag);
+                                            sameTypeList.Remove(deviceUI);
+                                        }
+                                        //if (sameTypeList.Count == 0)
+                                        //{
+                                        //    RefreshBodyView();
+                                        //}
                                     }
                                 };
                             };
@@ -1478,7 +1507,7 @@
                                     deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName);
                                     deviceRow.SetOnLineStatu(rollerShade.IsOnline == 1);
                                     deviceRow.SetStatuText(deviceUI.GetDeviceStatu());
-                                    deviceRow.SetStatu(rollerShade.WcdCurrentPositionLiftPercentage != 0);
+                                    deviceRow.IsSelected = rollerShade.WcdCurrentPositionLiftPercentage != 0;
                                     deviceRow.SetRollerShadeIcon(rollerShade.WcdType);
                                     deviceTypeRowLayout.AddChidren(deviceRow);
 

--
Gitblit v1.8.0