gxc
2020-01-07 aed247d7fa4499665041864479fae82089eafe5f
ZigbeeApp/Shared/Phone/Device/Category/Category.cs
@@ -1139,24 +1139,75 @@
                                            var lightControl = new Phone.Device.Light.OnOffControl();
                                            UserView.HomePage.Instance.AddChidren(lightControl);
                                            UserView.HomePage.Instance.PageIndex += 1;
                                            //lightControl.action = RefreshBodyView;
                                            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);
                                                }
                                            };
                                        }
                                        else if (deviceUI.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(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);
                                                }
                                            };
                                        }
                                        else
                                        {
                                            var lightControl = new Phone.Device.Light.LightControl();
                                            UserView.HomePage.Instance.AddChidren(lightControl);
                                            UserView.HomePage.Instance.PageIndex += 1;
                                            //lightControl.action = RefreshBodyView;
                                            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);
                                                }
                                            };
                                        }
                                    };
@@ -1171,7 +1222,7 @@
                                            if (curRoom.Id != Common.Room.CurrentRoom.Id)
                                            {
                                                Shared.Common.Room.CurrentRoom.DeleteDevice(deviceUI.FileName);
                                                deviceRow.RemoveFromParent();
                                                deviceListScrolView.RemoveViewByTag(deviceUI);
                                                sameTypeList.Remove(deviceUI);
                                                if (sameTypeList.Count == 0)
                                                {
@@ -1265,8 +1316,25 @@
                                        var lightControl = new Phone.Device.Light.AirSwitchControl();
                                        UserView.HomePage.Instance.AddChidren(lightControl);
                                        UserView.HomePage.Instance.PageIndex += 1;
                                        //lightControl.action = RefreshBodyView;
                                        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);
                                            }
                                        };
                                    };
                                    EventHandler<MouseEventArgs> deviceDetailHandler = (send2, e2) =>
@@ -1280,7 +1348,7 @@
                                            if (curRoom.Id != Common.Room.CurrentRoom.Id)
                                            {
                                                Shared.Common.Room.CurrentRoom.DeleteDevice(deviceUI.FileName);
                                                deviceRow.RemoveFromParent();
                                                deviceListScrolView.RemoveViewByTag(deviceUI);
                                                sameTypeList.Remove(deviceUI);
                                                if (sameTypeList.Count == 0)
                                                {
@@ -1376,8 +1444,26 @@
                                        UserView.HomePage.Instance.AddChidren(dimmableLightControl);
                                        UserView.HomePage.Instance.PageIndex += 1;
                                        UserView.HomePage.Instance.ScrollEnabled = false;
                                        //dimmableLightControl.action = RefreshBodyView;
                                        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);
                                            }
                                        };
                                    };
                                    EventHandler<MouseEventArgs> deviceDetailHandler = (send2, e2) =>
@@ -1391,7 +1477,7 @@
                                            if (curRoom.Id != Common.Room.CurrentRoom.Id)
                                            {
                                                Shared.Common.Room.CurrentRoom.DeleteDevice(deviceUI.FileName);
                                                deviceRow.RemoveFromParent();
                                                deviceListScrolView.RemoveViewByTag(deviceUI);
                                                sameTypeList.Remove(deviceUI);
                                                if (sameTypeList.Count == 0)
                                                {
@@ -1447,7 +1533,6 @@
                                    var deviceRow = new CategoryFunctionRow(0, 35);
                                    deviceRow.Init(deviceUI.IconPath, deviceUI.OnlineIconPath);
                                    deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName);
                                    //deviceRow.SetOnLineStatu(ac.IsOnline == 1);
                                    deviceRow.SetStatuText(deviceUI.GetDeviceStatu());
                                    deviceRow.IsSelected = ac.currentSystemMode != 1;
                                    deviceTypeRowLayout.AddChidren(deviceRow);
@@ -1490,8 +1575,25 @@
                                        UserView.HomePage.Instance.AddChidren(acControl);
                                        UserView.HomePage.Instance.PageIndex += 1;
                                        UserView.HomePage.Instance.ScrollEnabled = false;
                                        //rollerShadeControl.action = RefreshBodyView;
                                        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);
                                            }
                                        };
                                    };
                                    EventHandler<MouseEventArgs> deviceDetailHandler = (send2, e2) =>
@@ -1505,7 +1607,7 @@
                                            if (curRoom.Id != Common.Room.CurrentRoom.Id)
                                            {
                                                Shared.Common.Room.CurrentRoom.DeleteDevice(deviceUI.FileName);
                                                deviceRow.RemoveFromParent();
                                                deviceListScrolView.RemoveViewByTag(deviceUI);
                                                sameTypeList.Remove(deviceUI);
                                                if (sameTypeList.Count == 0)
                                                {
@@ -1588,8 +1690,25 @@
                                        UserView.HomePage.Instance.AddChidren(rollerShadeControl);
                                        UserView.HomePage.Instance.PageIndex += 1;
                                        UserView.HomePage.Instance.ScrollEnabled = false;
                                        //rollerShadeControl.action = RefreshBodyView;
                                        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);
                                            }
                                        };
                                    };
                                    EventHandler<MouseEventArgs> deviceDetailHandler = (send2, e2) =>
@@ -1603,7 +1722,7 @@
                                            if (curRoom.Id != Common.Room.CurrentRoom.Id)
                                            {
                                                Shared.Common.Room.CurrentRoom.DeleteDevice(deviceUI.FileName);
                                                deviceRow.RemoveFromParent();
                                                deviceListScrolView.RemoveViewByTag(deviceUI);
                                                sameTypeList.Remove(deviceUI);
                                                if (sameTypeList.Count == 0)
                                                {
@@ -1626,7 +1745,6 @@
                                        deviceTypeRowLayout.AddRightView(editBtn);
                                        editBtn.MouseUpEventHandler += deviceDetailHandler;
                                    }
                                }
                            }
                            else if (deviceUI.CommonDevice.Type == DeviceType.DoorLock)
@@ -1656,7 +1774,7 @@
                                        if (curRoom.Id != Common.Room.CurrentRoom.Id)
                                        {
                                            Shared.Common.Room.CurrentRoom.DeleteDevice(deviceUI.FileName);
                                            deviceRow.RemoveFromParent();
                                            deviceListScrolView.RemoveViewByTag(deviceUI);
                                            sameTypeList.Remove(deviceUI);
                                            if (sameTypeList.Count == 0)
                                            {
@@ -1701,7 +1819,7 @@
                                        if (curRoom.Id != Common.Room.CurrentRoom.Id)
                                        {
                                            Shared.Common.Room.CurrentRoom.DeleteDevice(deviceUI.FileName);
                                            deviceRow.RemoveFromParent();
                                            deviceListScrolView.RemoveViewByTag(deviceUI);
                                            sameTypeList.Remove(deviceUI);
                                            if (sameTypeList.Count == 0)
                                            {
@@ -1783,7 +1901,7 @@
                                            if (curRoom.Id != Common.Room.CurrentRoom.Id)
                                            {
                                                Shared.Common.Room.CurrentRoom.DeleteDevice(deviceUI.FileName);
                                                deviceRow.RemoveFromParent();
                                                deviceListScrolView.RemoveViewByTag(deviceUI);
                                                sameTypeList.Remove(deviceUI);
                                                if (sameTypeList.Count == 0)
                                                {
@@ -1828,7 +1946,7 @@
                                        if (curRoom.Id != Common.Room.CurrentRoom.Id)
                                        {
                                            Shared.Common.Room.CurrentRoom.DeleteDevice(deviceUI.FileName);
                                            deviceRow.RemoveFromParent();
                                            deviceListScrolView.RemoveViewByTag(deviceUI);
                                            sameTypeList.Remove(deviceUI);
                                            if (sameTypeList.Count == 0)
                                            {
@@ -1853,7 +1971,6 @@
                                }
                            }
                            //删除设备
                            EventHandler<MouseEventArgs> delEvent = (delSender, delE) =>
                            {
@@ -1874,7 +1991,7 @@
                                        sameTypeList.Remove(deviceUI);
                                        if (Common.Room.CurrentRoom.GetLoveRoom().DeviceUIList.Find((obj) => obj.FileName == deviceUI.FileName) != null)
                                        {
                                            Common.Room.CurrentRoom.DeleteDevice(deviceUI.FileName);
                                            Common.Room.CurrentRoom.GetLoveRoom().DeleteDevice(deviceUI.FileName);
                                        }
                                    }
                                    if (sameTypeList.Count == 0)