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

---
 ZigbeeApp/Shared/Phone/Device/Category/Category.cs |  161 ++++++++++++++++++++++++++++++++---------------------
 1 files changed, 98 insertions(+), 63 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Device/Category/Category.cs b/ZigbeeApp/Shared/Phone/Device/Category/Category.cs
index 75b3e76..10ac345 100644
--- a/ZigbeeApp/Shared/Phone/Device/Category/Category.cs
+++ b/ZigbeeApp/Shared/Phone/Device/Category/Category.cs
@@ -85,7 +85,7 @@
         /// <summary>
         /// 鍔熻兘绫诲瀷鎸夐挳
         /// </summary>
-        private FunctionButton functionTypeIMG;
+        //private FunctionButton functionTypeIMG;
         /// <summary>
         /// 鍔熻兘绫诲瀷
         /// </summary>
@@ -93,7 +93,7 @@
         /// <summary>
         /// 璁惧绫诲瀷RowLayout
         /// </summary>
-        private FrameLayout typeRowLayout;
+        //private FrameLayout typeRowLayout;
         /// <summary>
         /// 妤煎眰
         /// </summary>
@@ -122,7 +122,7 @@
         /// <summary>
         /// 褰撳墠閫変腑鎴块棿
         /// </summary>
-        private Common.Room room;
+        private Common.Room curRoom;
         #endregion
 
         #region 鈼� 鎺ュ彛____________________________
@@ -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;
                             }
                         }
@@ -799,18 +819,25 @@
         {
             devList = room.DeviceUIList;
             sceneList = room.SceneUIList;
-            var sameDevList = new List<DeviceUI> { };
             typeDeviceDic.Clear();
             typeIdDic.Clear();
             foreach (var device in devList)
             {
                 var info = Common.LocalDevice.Current.GetNotHdlMyDeviceEnumInfo(new List<CommonDevice> { device.CommonDevice });
-                if(info.BeloneType== DeviceBeloneType.A骞叉帴鐐� || info.BeloneType==DeviceBeloneType.A涓户鍣�)
+                if (info.BeloneType == DeviceBeloneType.A骞叉帴鐐� || info.BeloneType == DeviceBeloneType.A涓户鍣�)
                 {
                     continue;
                 }
-                sameDevList.Add(device);
-                typeDeviceDic[info.BeloneTextId] = sameDevList;
+                if (typeDeviceDic.ContainsKey(info.BeloneTextId) == false)
+                {
+                    var sameDevList = new List<DeviceUI> { };
+                    sameDevList.Add(device);
+                    typeDeviceDic[info.BeloneTextId] = sameDevList;
+                }
+                else
+                {
+                    typeDeviceDic[info.BeloneTextId].Add(device);
+                }
                 typeIdDic[info.BeloneTextId] = info.ConcreteType;
             }
         }
@@ -904,9 +931,9 @@
                 deviceListScrolView = new VerticalScrolViewLayout
                 {
                     X = Application.GetRealWidth(CommonFormResouce.X_Left),
-                    Y = Application.GetRealHeight(35+275),
+                    Y = Application.GetRealHeight(35+279),
                     Width = Application.GetRealWidth(1028),
-                    Height = Application.GetRealHeight(939),
+                    Height = Application.GetRealHeight(942),
                     BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
                 };
                 functionSceneBodyView.AddChidren(deviceListScrolView);
@@ -917,13 +944,13 @@
 
                 foreach (var deviceType in typeIdDic)
                 {
-                    typeRowLayout = new FrameLayout()
+                    var typeRowLayout = new FrameLayout()
                     {
                         Width = Application.GetRealWidth(220),
                     };
                     functionTypeScrowView.AddChidren(typeRowLayout);
 
-                    functionTypeIMG = new FunctionButton()
+                    var functionTypeIMG = new FunctionButton()
                     {
                         Tag = deviceType.Key
                     };
@@ -936,7 +963,7 @@
 
                     functionTypeIMG.ClickBtn.MouseUpEventHandler += ShowSameTypeFunction;
 
-                    if (typeRowLayout.ChildrenCount == 1)
+                    if (functionTypeScrowView.ChildrenCount == 1)
                     {
                         ShowSameTypeFunction(functionTypeIMG.ImageBtn, null);
                     }
@@ -979,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();
+                                        //}
                                     }
                                 };
                             };
@@ -1081,7 +1117,7 @@
                                             UserView.HomePage.Instance.AddChidren(lightControl);
                                             UserView.HomePage.Instance.PageIndex += 1;
                                             //lightControl.action = RefreshBodyView;
-                                            lightControl.Show(deviceUI, room);
+                                            lightControl.Show(deviceUI, curRoom);
                                         }
                                         else if (deviceUI.CommonDevice.DfunctionType == DeviceFunctionType.A鎻掑骇)
                                         {
@@ -1089,7 +1125,7 @@
                                             UserView.HomePage.Instance.AddChidren(lightControl);
                                             UserView.HomePage.Instance.PageIndex += 1;
                                             //lightControl.action = RefreshBodyView;
-                                            lightControl.Show(deviceUI, room);
+                                            lightControl.Show(deviceUI, curRoom);
                                         }
                                         else
                                         {
@@ -1097,7 +1133,7 @@
                                             UserView.HomePage.Instance.AddChidren(lightControl);
                                             UserView.HomePage.Instance.PageIndex += 1;
                                             //lightControl.action = RefreshBodyView;
-                                            lightControl.Show(deviceUI, room);
+                                            lightControl.Show(deviceUI, curRoom);
                                         }
                                     };
 
@@ -1111,7 +1147,7 @@
                                         Tag = deviceUI,
                                         Radius = 0
                                     };
-                                    if (room.IsSharedRoom == false)
+                                    if (curRoom.IsSharedRoom == false)
                                     {
                                         deviceTypeRowLayout.AddRightView(editBtn);
                                         editBtn.MouseUpEventHandler += deviceDetailHandler;
@@ -1201,7 +1237,7 @@
                                         UserView.HomePage.Instance.AddChidren(lightControl);
                                         UserView.HomePage.Instance.PageIndex += 1;
                                         //lightControl.action = RefreshBodyView;
-                                        lightControl.Show(deviceUI, room);
+                                        lightControl.Show(deviceUI, curRoom);
                                     };
 
                                     var editBtn = new CommonForm.RowLayoutEditButton()
@@ -1214,7 +1250,7 @@
                                         Tag = deviceUI,
                                         Radius = 0
                                     };
-                                    if (room.IsSharedRoom == false)
+                                    if (curRoom.IsSharedRoom == false)
                                     {
                                         deviceTypeRowLayout.AddRightView(editBtn);
                                         editBtn.MouseUpEventHandler += deviceDetailHandler;
@@ -1304,7 +1340,7 @@
                                         UserView.HomePage.Instance.PageIndex += 1;
                                         UserView.HomePage.Instance.ScrollEnabled = false;
                                         //dimmableLightControl.action = RefreshBodyView;
-                                        dimmableLightControl.Show(deviceUI, room);
+                                        dimmableLightControl.Show(deviceUI, curRoom);
                                     };
 
                                     var editBtn = new CommonForm.RowLayoutEditButton()
@@ -1317,7 +1353,7 @@
                                         Tag = deviceUI,
                                         Radius = 0
                                     };
-                                    if (room.IsSharedRoom == false)
+                                    if (curRoom.IsSharedRoom == false)
                                     {
                                         deviceTypeRowLayout.AddRightView(editBtn);
                                         editBtn.MouseUpEventHandler += deviceDetailHandler;
@@ -1412,7 +1448,7 @@
                                         Tag = deviceUI,
                                         Radius = 0
                                     };
-                                    if (room.IsSharedRoom == false)
+                                    if (curRoom.IsSharedRoom == false)
                                     {
                                         deviceTypeRowLayout.AddRightView(editBtn);
                                         editBtn.MouseUpEventHandler += deviceDetailHandler;
@@ -1427,7 +1463,7 @@
                                         UserView.HomePage.Instance.PageIndex += 1;
                                         UserView.HomePage.Instance.ScrollEnabled = false;
                                         //rollerShadeControl.action = RefreshBodyView;
-                                        acControl.Show(deviceUI, room);
+                                        acControl.Show(deviceUI, curRoom);
                                     };
                                 }
                             }
@@ -1471,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);
 
@@ -1502,7 +1538,7 @@
                                         Tag = deviceUI,
                                         Radius = 0
                                     };
-                                    if (room.IsSharedRoom == false)
+                                    if (curRoom.IsSharedRoom == false)
                                     {
                                         deviceTypeRowLayout.AddRightView(editBtn);
                                         editBtn.MouseUpEventHandler += deviceDetailHandler;
@@ -1517,7 +1553,7 @@
                                         UserView.HomePage.Instance.PageIndex += 1;
                                         UserView.HomePage.Instance.ScrollEnabled = false;
                                         //rollerShadeControl.action = RefreshBodyView;
-                                        rollerShadeControl.Show(deviceUI, room);
+                                        rollerShadeControl.Show(deviceUI, curRoom);
                                     };
                                 }
                             }
@@ -1541,7 +1577,7 @@
 
                                 deviceRow.ClickBtn.MouseUpEventHandler += (send2, e2) =>
                                 {
-                                    var userDoorLockPage = new UserDoorLockPage(room, deviceUI);
+                                    var userDoorLockPage = new UserDoorLockPage(curRoom, deviceUI);
                                     HomePage.Instance.AddChidren(userDoorLockPage);
                                     HomePage.Instance.PageIndex += 1;
                                     userDoorLockPage.Show();
@@ -1555,7 +1591,7 @@
                                 {
                                     Tag = deviceUI
                                 };
-                                if (room.IsSharedRoom == false)
+                                if (curRoom.IsSharedRoom == false)
                                 {
                                     deviceTypeRowLayout.AddRightView(editBtn);
                                     editBtn.MouseUpEventHandler += deviceDetailHandler;
@@ -1589,7 +1625,7 @@
                                 {
                                     Tag = deviceUI
                                 };
-                                if (room.IsSharedRoom == false)
+                                if (curRoom.IsSharedRoom == false)
                                 {
                                     deviceTypeRowLayout.AddRightView(editBtn);
                                     editBtn.MouseUpEventHandler += deviceDetailHandler;
@@ -1661,9 +1697,8 @@
                 if (room.IsLove)
                 {
                     roomBtn.IsSelected = true;
-                    this.room = room;
+                    this.curRoom = room;
                     curBtn = roomBtn;
-
                     if(sceneBtn.IsSelected)
                     {
                         RefreshScene(room);
@@ -1683,7 +1718,7 @@
                     (sender as Button).IsSelected = true;
                     curBtn.IsSelected = false;
                     curBtn = sender as Button;
-                    this.room = room;
+                    this.curRoom = room;
                     if (sceneBtn.IsSelected)
                     {
                         RefreshScene(room);
@@ -1713,8 +1748,8 @@
         /// <param name="room"></param>
         public void RefreshScene(Common.Room room)
         {
+            RefreshData(room);
             functionSceneBodyView.RemoveAll();
-            var sceneList = room.SceneUIList;
             if (sceneList.Count == 0)
             {
                 ShowNoSceneTip();

--
Gitblit v1.8.0