From aed247d7fa4499665041864479fae82089eafe5f Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期二, 07 一月 2020 09:15:57 +0800
Subject: [PATCH] 2019.1.7

---
 ZigbeeApp/Shared/Phone/UserView/UserHomeView.cs |  110 +++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 98 insertions(+), 12 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserView/UserHomeView.cs b/ZigbeeApp/Shared/Phone/UserView/UserHomeView.cs
index 0545a23..82e94d9 100644
--- a/ZigbeeApp/Shared/Phone/UserView/UserHomeView.cs
+++ b/ZigbeeApp/Shared/Phone/UserView/UserHomeView.cs
@@ -637,7 +637,7 @@
                 if (roomPageView.GetChildren(roomPageView.PageIndex) != null)
                 {
                     (roomPageView.GetChildren(roomPageView.PageIndex) as RoomView).HideName(false);
-                    
+
                 }
 
                 var functionSceneView = new FrameLayout()
@@ -733,7 +733,7 @@
                     //鍒囨崲褰撳墠鎴块棿
                     Room.CurrentRoom = rList[roomPageView.PageIndex];
                     RefreshBodyView();
-                    
+
                 };
             }
             else
@@ -776,6 +776,7 @@
             floorFL.FloorAction = (floorId) =>
             {
                 floorBtn.Text = Config.Instance.Home.GetFloorNameById(floorId);
+                Common.Room.CurrentRoom = Common.Room.CurrentRoom?.GetLoveRoom();
                 Show();
             };
         }
@@ -918,6 +919,7 @@
         /// </summary>
         private void ShowFunction()
         {
+            functionSceneBodyView.RemoveAll();
             //閫夋嫨鍔熻兘--鐩存帴浠庢埧闂寸殑devicelist涓幏鍙�
             var deviceList = Room.CurrentRoom.DeviceUIList;
             if (deviceList == null)
@@ -1017,7 +1019,6 @@
                                         lightView.SetDeviceImage(device.IconPath, device.OnlineIconPath);
                                         lightView.SetStatuText(device.GetDeviceStatu());
                                         lightView.SetDeviceName(rollerShade.DeviceEpointName);
-                                        //lightView.SetStatu(true);
                                         lightView.IsSelected = rollerShade.WcdCurrentPositionLiftPercentage == 100;
                                         lightView.SetCollect(true);
 
@@ -1085,8 +1086,20 @@
                                             UserView.HomePage.Instance.AddChidren(rollerShadeControl);
                                             UserView.HomePage.Instance.PageIndex += 1;
                                             UserView.HomePage.Instance.ScrollEnabled = false;
-                                            //rollerShadeControl.action = RefreshBodyView;
                                             rollerShadeControl.Show(device, Room.CurrentRoom);
+                                            rollerShadeControl.action += (curDev, curRoom) =>
+                                            {
+                                                if (curRoom.Id != Common.Room.CurrentRoom.Id)
+                                                {
+                                                    Common.Room.CurrentRoom.DeleteDevice(device.FileName);
+                                                    ShowFunction();
+                                                }
+                                                else
+                                                {
+                                                    lightView.SetDeviceImage(curDev.IconPath, curDev.OnlineIconPath);
+                                                    lightView.SetDeviceName(curDev.CommonDevice.DeviceEpointName);
+                                                }
+                                            };
                                         };
 
                                         lightView.CollectButton.MouseUpEventHandler += collectionEvent;
@@ -1203,24 +1216,60 @@
                                                 var lightControl = new Phone.Device.Light.OnOffControl();
                                                 UserView.HomePage.Instance.AddChidren(lightControl);
                                                 UserView.HomePage.Instance.PageIndex += 1;
-                                                //lightControl.action = RefreshBodyView;
                                                 lightControl.Show(device, Room.CurrentRoom);
+                                                lightControl.action += (curDev, curRoom) =>
+                                                {
+                                                    if (curRoom.Id != Common.Room.CurrentRoom.Id)
+                                                    {
+                                                        Common.Room.CurrentRoom.DeleteDevice(device.FileName);
+                                                        ShowFunction();
+                                                    }
+                                                    else
+                                                    {
+                                                        lightView.SetDeviceImage(curDev.IconPath, curDev.OnlineIconPath);
+                                                        lightView.SetDeviceName(curDev.CommonDevice.DeviceEpointName);
+                                                    }
+                                                };
                                             }
                                             else if (device.CommonDevice.DfunctionType == DeviceFunctionType.A鎻掑骇)
                                             {
                                                 var lightControl = new Phone.Device.Light.PlugControl();
                                                 UserView.HomePage.Instance.AddChidren(lightControl);
                                                 UserView.HomePage.Instance.PageIndex += 1;
-                                                //lightControl.action = RefreshBodyView;
                                                 lightControl.Show(device, Room.CurrentRoom);
+                                                lightControl.action += (curDev, curRoom) =>
+                                                {
+                                                    if (curRoom.Id != Common.Room.CurrentRoom.Id)
+                                                    {
+                                                        Common.Room.CurrentRoom.DeleteDevice(device.FileName);
+                                                        ShowFunction();
+                                                    }
+                                                    else
+                                                    {
+                                                        lightView.SetDeviceImage(curDev.IconPath, curDev.OnlineIconPath);
+                                                        lightView.SetDeviceName(curDev.CommonDevice.DeviceEpointName);
+                                                    }
+                                                };
                                             }
                                             else
                                             {
                                                 var lightControl = new Phone.Device.Light.LightControl();
                                                 UserView.HomePage.Instance.AddChidren(lightControl);
                                                 UserView.HomePage.Instance.PageIndex += 1;
-                                                //lightControl.action = RefreshBodyView;
                                                 lightControl.Show(device, Room.CurrentRoom);
+                                                lightControl.action += (curDev, curRoom) =>
+                                                {
+                                                    if (curRoom.Id != Common.Room.CurrentRoom.Id)
+                                                    {
+                                                        Common.Room.CurrentRoom.DeleteDevice(device.FileName);
+                                                        ShowFunction();
+                                                    }
+                                                    else
+                                                    {
+                                                        lightView.SetDeviceImage(curDev.IconPath, curDev.OnlineIconPath);
+                                                        lightView.SetDeviceName(curDev.CommonDevice.DeviceEpointName);
+                                                    }
+                                                };
                                             }
                                         };
 
@@ -1260,7 +1309,6 @@
                                         lightView.SetDeviceImage(device.IconPath, device.OnlineIconPath);
                                         lightView.SetStatuText(device.GetDeviceStatu());
                                         lightView.SetDeviceName(airSwitch.DeviceEpointName);
-                                        //lightView.SetStatu(true);
                                         lightView.IsSelected = airSwitch.OnOffStatus == 1;
                                         lightView.SetCollect(Room.CurrentRoom.IsCollectInRoom(Room.CurrentRoom, device.FileName));
 
@@ -1327,8 +1375,21 @@
                                             var lightControl = new Phone.Device.Light.AirSwitchControl();
                                             UserView.HomePage.Instance.AddChidren(lightControl);
                                             UserView.HomePage.Instance.PageIndex += 1;
-                                            //lightControl.action = RefreshBodyView;
                                             lightControl.Show(device, Room.CurrentRoom);
+                                            lightControl.action += (curDev, curRoom) =>
+                                            {
+                                                if (curRoom.Id != Common.Room.CurrentRoom.Id)
+                                                {
+                                                    Common.Room.CurrentRoom.DeleteDevice(device.FileName);
+                                                    ShowFunction();
+                                                }
+                                                else
+                                                {
+                                                    lightView.SetDeviceImage(curDev.IconPath, curDev.OnlineIconPath);
+                                                    lightView.SetDeviceName(curDev.CommonDevice.DeviceEpointName);
+                                                }
+                                            };
+
                                         };
 
                                         lightView.CollectButton.MouseUpEventHandler += collectionEvent;
@@ -1433,8 +1494,20 @@
                                             var lightControl = new Phone.Device.AC.ACControl();
                                             UserView.HomePage.Instance.AddChidren(lightControl);
                                             UserView.HomePage.Instance.PageIndex += 1;
-                                            //lightControl.action = RefreshBodyView;
                                             lightControl.Show(device, Room.CurrentRoom);
+                                            lightControl.action += (curDev, curRoom) =>
+                                            {
+                                                if (curRoom.Id != Common.Room.CurrentRoom.Id)
+                                                {
+                                                    Common.Room.CurrentRoom.DeleteDevice(device.FileName);
+                                                    ShowFunction();
+                                                }
+                                                else
+                                                {
+                                                    lightView.SetDeviceImage(curDev.IconPath, curDev.OnlineIconPath);
+                                                    lightView.SetDeviceName(curDev.CommonDevice.DeviceEpointName);
+                                                }
+                                            };
                                         };
 
                                         lightView.CollectButton.MouseUpEventHandler += collectionEvent;
@@ -1551,8 +1624,20 @@
                                             var dimmableLightControl = new Phone.Device.Light.DimmableLightControl();
                                             UserView.HomePage.Instance.AddChidren(dimmableLightControl);
                                             UserView.HomePage.Instance.PageIndex += 1;
-                                            //dimmableLightControl.action = RefreshBodyView;
                                             dimmableLightControl.Show(device, Room.CurrentRoom);
+                                            dimmableLightControl.action += (curDev, curRoom) =>
+                                            {
+                                                if (curRoom.Id != Common.Room.CurrentRoom.Id)
+                                                {
+                                                    Common.Room.CurrentRoom.DeleteDevice(device.FileName);
+                                                    ShowFunction();
+                                                }
+                                                else
+                                                {
+                                                    lightView.SetDeviceImage(curDev.IconPath, curDev.OnlineIconPath);
+                                                    lightView.SetDeviceName(curDev.CommonDevice.DeviceEpointName);
+                                                }
+                                            };
                                         };
                                         lightView.CollectButton.MouseUpEventHandler += collectionEvent;
                                     }
@@ -1690,7 +1775,7 @@
                                     lightView.SetStatuText(device.GetDeviceStatu());
                                     lightView.SetDeviceName(device.CommonDevice.DeviceEpointName);
                                     lightView.CanControl(false);
-                                    lightView.IsSelected = device.CommonDevice.IsOnline == 1;
+                                    //lightView.IsSelected = device.CommonDevice.IsOnline == 1;
                                     lightView.SetCollect(Room.CurrentRoom.IsCollectInRoom(Room.CurrentRoom, device.FileName));
 
                                     var dev = Room.LoveRoomDeviceUIFilePathList.Find((obj) => obj == device.FileName);
@@ -1751,6 +1836,7 @@
         /// </summary>
         private void ShowScene()
         {
+            functionSceneBodyView.RemoveAll();
             //閫夋嫨鍦烘櫙
             var sceneList = Room.CurrentRoom.SceneUIList;
             if (sceneList == null)

--
Gitblit v1.8.0