gxc
2020-01-07 aed247d7fa4499665041864479fae82089eafe5f
ZigbeeApp/Shared/Phone/UserView/UserHomeView.cs
@@ -919,6 +919,7 @@
        /// </summary>
        private void ShowFunction()
        {
            functionSceneBodyView.RemoveAll();
            //选择功能--直接从房间的devicelist中获取
            var deviceList = Room.CurrentRoom.DeviceUIList;
            if (deviceList == null)
@@ -1018,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);
@@ -1086,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;
@@ -1204,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);
                                                    }
                                                };
                                            }
                                        };
@@ -1261,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));
@@ -1328,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;
@@ -1434,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;
@@ -1552,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;
                                    }
@@ -1691,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);
@@ -1752,6 +1836,7 @@
        /// </summary>
        private void ShowScene()
        {
            functionSceneBodyView.RemoveAll();
            //选择场景
            var sceneList = Room.CurrentRoom.SceneUIList;
            if (sceneList == null)