From 587c36e27131f2d028fcabc13b296a8de7470034 Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期三, 08 一月 2020 08:59:19 +0800
Subject: [PATCH] 2019.1.8

---
 ZigbeeApp/Shared/Phone/Device/Category/Category.cs |  330 +++++++++++++++----------------------------------------
 1 files changed, 90 insertions(+), 240 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Device/Category/Category.cs b/ZigbeeApp/Shared/Phone/Device/Category/Category.cs
index ba82d19..36aa8a7 100644
--- a/ZigbeeApp/Shared/Phone/Device/Category/Category.cs
+++ b/ZigbeeApp/Shared/Phone/Device/Category/Category.cs
@@ -1142,21 +1142,7 @@
                                             lightControl.Show(deviceUI, Common.Room.CurrentRoom);
                                             lightControl.action += (curDev, curRoom) =>
                                             {
-                                                if (curRoom.Id != Common.Room.CurrentRoom.Id)
-                                                {
-                                                    Shared.Common.Room.CurrentRoom.DeleteDevice(deviceUI.FileName);
-                                                    deviceListScrolView.RemoveViewByTag(deviceUI);
-                                                    sameTypeList.Remove(deviceUI);
-                                                    if (sameTypeList.Count == 0)
-                                                    {
-                                                        RefreshFunction(Common.Room.CurrentRoom);
-                                                    }
-                                                }
-                                                else
-                                                {
-                                                    deviceRow.SetDeviceIcon(deviceUI.IconPath, deviceUI.OnlineIconPath);
-                                                    deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName);
-                                                }
+                                                ReFreshDeviceAction(deviceUI, curRoom, sameTypeList, deviceListScrolView, deviceRow);
                                             };
                                         }
                                         else if (deviceUI.CommonDevice.DfunctionType == DeviceFunctionType.A鎻掑骇)
@@ -1167,21 +1153,7 @@
                                             lightControl.Show(deviceUI, Common.Room.CurrentRoom);
                                             lightControl.action += (curDev, curRoom) =>
                                             {
-                                                if (curRoom.Id != Common.Room.CurrentRoom.Id)
-                                                {
-                                                    Shared.Common.Room.CurrentRoom.DeleteDevice(deviceUI.FileName);
-                                                    deviceListScrolView.RemoveViewByTag(deviceUI);
-                                                    sameTypeList.Remove(deviceUI);
-                                                    if (sameTypeList.Count == 0)
-                                                    {
-                                                        RefreshFunction(Common.Room.CurrentRoom);
-                                                    }
-                                                }
-                                                else
-                                                {
-                                                    deviceRow.SetDeviceIcon(deviceUI.IconPath, deviceUI.OnlineIconPath);
-                                                    deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName);
-                                                }
+                                                ReFreshDeviceAction(deviceUI, curRoom, sameTypeList, deviceListScrolView, deviceRow);
                                             };
                                         }
                                         else
@@ -1192,21 +1164,7 @@
                                             lightControl.Show(deviceUI, Common.Room.CurrentRoom);
                                             lightControl.action += (curDev, curRoom) =>
                                             {
-                                                if (curRoom.Id != Common.Room.CurrentRoom.Id)
-                                                {
-                                                    Shared.Common.Room.CurrentRoom.DeleteDevice(deviceUI.FileName);
-                                                    deviceListScrolView.RemoveViewByTag(deviceUI);
-                                                    sameTypeList.Remove(deviceUI);
-                                                    if (sameTypeList.Count == 0)
-                                                    {
-                                                        RefreshFunction(Common.Room.CurrentRoom);
-                                                    }
-                                                }
-                                                else
-                                                {
-                                                    deviceRow.SetDeviceIcon(deviceUI.IconPath, deviceUI.OnlineIconPath);
-                                                    deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName);
-                                                }
+                                                ReFreshDeviceAction(deviceUI, curRoom, sameTypeList, deviceListScrolView, deviceRow);
                                             };
                                         }
                                     };
@@ -1219,21 +1177,7 @@
                                         detailInfo.Show(deviceUI, Shared.Common.Room.CurrentRoom);
                                         detailInfo.EditAction += (curDevice, curRoom) =>
                                         {
-                                            if (curRoom.Id != Common.Room.CurrentRoom.Id)
-                                            {
-                                                Shared.Common.Room.CurrentRoom.DeleteDevice(deviceUI.FileName);
-                                                deviceListScrolView.RemoveViewByTag(deviceUI);
-                                                sameTypeList.Remove(deviceUI);
-                                                if (sameTypeList.Count == 0)
-                                                {
-                                                    RefreshFunction(Common.Room.CurrentRoom);
-                                                }
-                                            }
-                                            else
-                                            {
-                                                deviceRow.SetDeviceIcon(deviceUI.IconPath, deviceUI.OnlineIconPath);
-                                                deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName);
-                                            }
+                                            ReFreshDeviceAction(deviceUI, curRoom, sameTypeList, deviceListScrolView, deviceRow);
                                         };
                                     };
                                     var editBtn = new CommonForm.RowLayoutEditButton()
@@ -1319,21 +1263,9 @@
                                         lightControl.Show(deviceUI, Common.Room.CurrentRoom);
                                         lightControl.action += (curDev, curRoom) =>
                                         {
-                                            if (curRoom.Id != Common.Room.CurrentRoom.Id)
-                                            {
-                                                Shared.Common.Room.CurrentRoom.DeleteDevice(deviceUI.FileName);
-                                                deviceListScrolView.RemoveViewByTag(deviceUI);
-                                                sameTypeList.Remove(deviceUI);
-                                                if (sameTypeList.Count == 0)
-                                                {
-                                                    RefreshFunction(Common.Room.CurrentRoom);
-                                                }
-                                            }
-                                            else
-                                            {
-                                                deviceRow.SetDeviceIcon(deviceUI.IconPath, deviceUI.OnlineIconPath);
-                                                deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName);
-                                            }
+
+                                            ReFreshDeviceAction(deviceUI, curRoom, sameTypeList, deviceListScrolView, deviceRow);
+
                                         };
                                     };
 
@@ -1345,21 +1277,8 @@
                                         detailInfo.Show(deviceUI, Shared.Common.Room.CurrentRoom);
                                         detailInfo.EditAction += (curDevice, curRoom) =>
                                         {
-                                            if (curRoom.Id != Common.Room.CurrentRoom.Id)
-                                            {
-                                                Shared.Common.Room.CurrentRoom.DeleteDevice(deviceUI.FileName);
-                                                deviceListScrolView.RemoveViewByTag(deviceUI);
-                                                sameTypeList.Remove(deviceUI);
-                                                if (sameTypeList.Count == 0)
-                                                {
-                                                    RefreshFunction(Common.Room.CurrentRoom);
-                                                }
-                                            }
-                                            else
-                                            {
-                                                deviceRow.SetDeviceIcon(deviceUI.IconPath, deviceUI.OnlineIconPath);
-                                                deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName);
-                                            }
+                                            ReFreshDeviceAction(deviceUI, curRoom, sameTypeList, deviceListScrolView, deviceRow);
+
                                         };
                                     };
                                     var editBtn = new CommonForm.RowLayoutEditButton()
@@ -1447,21 +1366,7 @@
                                         dimmableLightControl.Show(deviceUI, Common.Room.CurrentRoom);
                                         dimmableLightControl.action += (curDev, curRoom) =>
                                         {
-                                            if (curRoom.Id != Common.Room.CurrentRoom.Id)
-                                            {
-                                                Shared.Common.Room.CurrentRoom.DeleteDevice(deviceUI.FileName);
-                                                deviceListScrolView.RemoveViewByTag(deviceUI);
-                                                sameTypeList.Remove(deviceUI);
-                                                if (sameTypeList.Count == 0)
-                                                {
-                                                    RefreshFunction(Common.Room.CurrentRoom);
-                                                }
-                                            }
-                                            else
-                                            {
-                                                deviceRow.SetDeviceIcon(deviceUI.IconPath, deviceUI.OnlineIconPath);
-                                                deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName);
-                                            }
+                                            ReFreshDeviceAction(deviceUI, curRoom, sameTypeList, deviceListScrolView, deviceRow);
                                         };
 
                                     };
@@ -1474,21 +1379,7 @@
                                         detailInfo.Show(deviceUI, Shared.Common.Room.CurrentRoom);
                                         detailInfo.EditAction += (curDevice, curRoom) =>
                                         {
-                                            if (curRoom.Id != Common.Room.CurrentRoom.Id)
-                                            {
-                                                Shared.Common.Room.CurrentRoom.DeleteDevice(deviceUI.FileName);
-                                                deviceListScrolView.RemoveViewByTag(deviceUI);
-                                                sameTypeList.Remove(deviceUI);
-                                                if (sameTypeList.Count == 0)
-                                                {
-                                                    RefreshFunction(Common.Room.CurrentRoom);
-                                                }
-                                            }
-                                            else
-                                            {
-                                                deviceRow.SetDeviceIcon(deviceUI.IconPath, deviceUI.OnlineIconPath);
-                                                deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName);
-                                            }
+                                            ReFreshDeviceAction(deviceUI, curRoom, sameTypeList, deviceListScrolView, deviceRow);
                                         };
                                     };
                                     var editBtn = new CommonForm.RowLayoutEditButton()
@@ -1578,21 +1469,8 @@
                                         acControl.Show(deviceUI, Common.Room.CurrentRoom);
                                         acControl.action += (curDev, curRoom) =>
                                         {
-                                            if (curRoom.Id != Common.Room.CurrentRoom.Id)
-                                            {
-                                                Shared.Common.Room.CurrentRoom.DeleteDevice(deviceUI.FileName);
-                                                deviceListScrolView.RemoveViewByTag(deviceUI);
-                                                sameTypeList.Remove(deviceUI);
-                                                if (sameTypeList.Count == 0)
-                                                {
-                                                    RefreshFunction(Common.Room.CurrentRoom);
-                                                }
-                                            }
-                                            else
-                                            {
-                                                deviceRow.SetDeviceIcon(deviceUI.IconPath, deviceUI.OnlineIconPath);
-                                                deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName);
-                                            }
+                                            ReFreshDeviceAction(deviceUI, curRoom, sameTypeList, deviceListScrolView, deviceRow);
+
                                         };
                                     };
 
@@ -1604,21 +1482,8 @@
                                         detailInfo.Show(deviceUI, Shared.Common.Room.CurrentRoom);
                                         detailInfo.EditAction += (curDevice, curRoom) =>
                                         {
-                                            if (curRoom.Id != Common.Room.CurrentRoom.Id)
-                                            {
-                                                Shared.Common.Room.CurrentRoom.DeleteDevice(deviceUI.FileName);
-                                                deviceListScrolView.RemoveViewByTag(deviceUI);
-                                                sameTypeList.Remove(deviceUI);
-                                                if (sameTypeList.Count == 0)
-                                                {
-                                                    RefreshFunction(Common.Room.CurrentRoom);
-                                                }
-                                            }
-                                            else
-                                            {
-                                                deviceRow.SetDeviceIcon(deviceUI.IconPath, deviceUI.OnlineIconPath);
-                                                deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName);
-                                            }
+                                            ReFreshDeviceAction(deviceUI, curRoom, sameTypeList, deviceListScrolView, deviceRow);
+
                                         };
                                     };
                                     var editBtn = new CommonForm.RowLayoutEditButton()
@@ -1693,21 +1558,7 @@
                                         rollerShadeControl.Show(deviceUI, Common.Room.CurrentRoom);
                                         rollerShadeControl.action += (curDev, curRoom) =>
                                         {
-                                            if (curRoom.Id != Common.Room.CurrentRoom.Id)
-                                            {
-                                                Shared.Common.Room.CurrentRoom.DeleteDevice(deviceUI.FileName);
-                                                deviceListScrolView.RemoveViewByTag(deviceUI);
-                                                sameTypeList.Remove(deviceUI);
-                                                if (sameTypeList.Count == 0)
-                                                {
-                                                    RefreshFunction(Common.Room.CurrentRoom);
-                                                }
-                                            }
-                                            else
-                                            {
-                                                deviceRow.SetDeviceIcon(deviceUI.IconPath, deviceUI.OnlineIconPath);
-                                                deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName);
-                                            }
+                                            ReFreshDeviceActionForWin(deviceUI, curRoom, sameTypeList, deviceListScrolView, deviceRow);
                                         };
                                     };
 
@@ -1719,21 +1570,7 @@
                                         detailInfo.Show(deviceUI, Shared.Common.Room.CurrentRoom);
                                         detailInfo.EditAction += (curDevice, curRoom) =>
                                         {
-                                            if (curRoom.Id != Common.Room.CurrentRoom.Id)
-                                            {
-                                                Shared.Common.Room.CurrentRoom.DeleteDevice(deviceUI.FileName);
-                                                deviceListScrolView.RemoveViewByTag(deviceUI);
-                                                sameTypeList.Remove(deviceUI);
-                                                if (sameTypeList.Count == 0)
-                                                {
-                                                    RefreshFunction(Common.Room.CurrentRoom);
-                                                }
-                                            }
-                                            else
-                                            {
-                                                deviceRow.SetDeviceIcon(deviceUI.IconPath, deviceUI.OnlineIconPath);
-                                                deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName);
-                                            }
+                                            ReFreshDeviceActionForWin(deviceUI, curRoom, sameTypeList, deviceListScrolView, deviceRow);
                                         };
                                     };
                                     var editBtn = new CommonForm.RowLayoutEditButton()
@@ -1771,21 +1608,7 @@
                                     detailInfo.Show(deviceUI, Shared.Common.Room.CurrentRoom);
                                     detailInfo.EditAction += (curDevice, curRoom) =>
                                     {
-                                        if (curRoom.Id != Common.Room.CurrentRoom.Id)
-                                        {
-                                            Shared.Common.Room.CurrentRoom.DeleteDevice(deviceUI.FileName);
-                                            deviceListScrolView.RemoveViewByTag(deviceUI);
-                                            sameTypeList.Remove(deviceUI);
-                                            if (sameTypeList.Count == 0)
-                                            {
-                                                RefreshFunction(Common.Room.CurrentRoom);
-                                            }
-                                        }
-                                        else
-                                        {
-                                            deviceRow.SetDeviceIcon(deviceUI.IconPath, deviceUI.OnlineIconPath);
-                                            deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName);
-                                        }
+                                        ReFreshDeviceAction(deviceUI, curRoom, sameTypeList, deviceListScrolView, deviceRow);
                                     };
                                 };
                                 var editBtn = new CommonForm.RowLayoutEditButton()
@@ -1816,21 +1639,7 @@
                                     detailInfo.Show(deviceUI, Shared.Common.Room.CurrentRoom);
                                     detailInfo.EditAction += (curDevice, curRoom) =>
                                     {
-                                        if (curRoom.Id != Common.Room.CurrentRoom.Id)
-                                        {
-                                            Shared.Common.Room.CurrentRoom.DeleteDevice(deviceUI.FileName);
-                                            deviceListScrolView.RemoveViewByTag(deviceUI);
-                                            sameTypeList.Remove(deviceUI);
-                                            if (sameTypeList.Count == 0)
-                                            {
-                                                RefreshFunction(Common.Room.CurrentRoom);
-                                            }
-                                        }
-                                        else
-                                        {
-                                            deviceRow.SetDeviceIcon(deviceUI.IconPath, deviceUI.OnlineIconPath);
-                                            deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName);
-                                        }
+                                        ReFreshDeviceAction(deviceUI, curRoom, sameTypeList, deviceListScrolView, deviceRow);
                                     };
                                 };
                                 var editBtn = new CommonForm.RowLayoutEditButton()
@@ -1898,21 +1707,7 @@
                                         detailInfo.Show(deviceUI, Shared.Common.Room.CurrentRoom);
                                         detailInfo.EditAction += (curDevice, curRoom) =>
                                         {
-                                            if (curRoom.Id != Common.Room.CurrentRoom.Id)
-                                            {
-                                                Shared.Common.Room.CurrentRoom.DeleteDevice(deviceUI.FileName);
-                                                deviceListScrolView.RemoveViewByTag(deviceUI);
-                                                sameTypeList.Remove(deviceUI);
-                                                if (sameTypeList.Count == 0)
-                                                {
-                                                    RefreshFunction(Common.Room.CurrentRoom);
-                                                }
-                                            }
-                                            else
-                                            {
-                                                deviceRow.SetDeviceIcon(deviceUI.IconPath, deviceUI.OnlineIconPath);
-                                                deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName);
-                                            }
+                                            ReFreshDeviceAction(deviceUI, curRoom, sameTypeList, deviceListScrolView, deviceRow);
                                         };
                                     };
                                     var editBtn = new CommonForm.RowLayoutEditButton()
@@ -1943,21 +1738,7 @@
                                     detailInfo.Show(deviceUI, Shared.Common.Room.CurrentRoom);
                                     detailInfo.EditAction += (curDevice, curRoom) =>
                                     {
-                                        if (curRoom.Id != Common.Room.CurrentRoom.Id)
-                                        {
-                                            Shared.Common.Room.CurrentRoom.DeleteDevice(deviceUI.FileName);
-                                            deviceListScrolView.RemoveViewByTag(deviceUI);
-                                            sameTypeList.Remove(deviceUI);
-                                            if (sameTypeList.Count == 0)
-                                            {
-                                                RefreshFunction(Common.Room.CurrentRoom);
-                                            }
-                                        }
-                                        else
-                                        {
-                                            deviceRow.SetDeviceIcon(deviceUI.IconPath, deviceUI.OnlineIconPath);
-                                            deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName);
-                                        }
+                                        ReFreshDeviceAction(deviceUI, curRoom, sameTypeList, deviceListScrolView, deviceRow);
                                     };
                                 };
                                 var editBtn = new CommonForm.RowLayoutEditButton()
@@ -2018,6 +1799,75 @@
         }
 
         /// <summary>
+        /// ReFreshDeviceAction
+        /// </summary>
+        /// <param name="curRoom"></param>
+        /// <param name="sameTypeList"></param>
+        /// <param name="devListScrolView"></param>
+        /// <param name="deviceRow"></param>
+        private void ReFreshDeviceAction(DeviceUI deviceUI,Common.Room curRoom,List<DeviceUI> sameTypeList,VerticalScrolViewLayout devListScrolView,CategoryFunctionRow deviceRow)
+        {
+            if (curRoom.Id != Common.Room.CurrentRoom.Id)
+            {
+                if(Common.Room.CurrentRoom.IsLove)
+                {
+                    deviceRow.SetDeviceIcon(deviceUI.IconPath, deviceUI.OnlineIconPath);
+                    deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName);
+                }
+                else
+                {
+                    Shared.Common.Room.CurrentRoom.DeleteDevice(deviceUI.FileName);
+                    devListScrolView.RemoveViewByTag(deviceUI);
+                    sameTypeList.Remove(deviceUI);
+                    if (sameTypeList.Count == 0)
+                    {
+                        RefreshFunction(Common.Room.CurrentRoom);
+                    }
+                }
+            }
+            else
+            {
+                deviceRow.SetDeviceIcon(deviceUI.IconPath, deviceUI.OnlineIconPath);
+                deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName);
+            }
+        }
+
+        /// <summary>
+        /// ReFreshDeviceAction
+        /// </summary>
+        /// <param name="curRoom"></param>
+        /// <param name="sameTypeList"></param>
+        /// <param name="devListScrolView"></param>
+        /// <param name="deviceRow"></param>
+        private void ReFreshDeviceActionForWin(DeviceUI deviceUI, Common.Room curRoom, List<DeviceUI> sameTypeList, VerticalScrolViewLayout devListScrolView, CategoryFunctionForWinRow deviceRow)
+        {
+            if (curRoom.Id != Common.Room.CurrentRoom.Id)
+            {
+                if (Common.Room.CurrentRoom.IsLove)
+                {
+                    deviceRow.SetDeviceIcon(deviceUI.IconPath, deviceUI.OnlineIconPath);
+                    deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName);
+                }
+                else
+                {
+                    Shared.Common.Room.CurrentRoom.DeleteDevice(deviceUI.FileName);
+                    devListScrolView.RemoveViewByTag(deviceUI);
+                    sameTypeList.Remove(deviceUI);
+                    if (sameTypeList.Count == 0)
+                    {
+                        RefreshFunction(Common.Room.CurrentRoom);
+                    }
+                }
+            }
+            else
+            {
+                deviceRow.SetDeviceIcon(deviceUI.IconPath, deviceUI.OnlineIconPath);
+                deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName);
+            }
+        }
+
+
+        /// <summary>
         /// AddRoomView
         /// </summary>
         private void AddRoomView()

--
Gitblit v1.8.0