From b8cbf4a8b6910eefcb83b6d3a39e9b5b5a9cd79e Mon Sep 17 00:00:00 2001 From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local> Date: 星期五, 10 一月 2020 16:39:22 +0800 Subject: [PATCH] 2019.1.10 --- ZigbeeApp/Shared/Phone/Device/Category/Category.cs | 381 ++++++++++++++++-------------------------------------- 1 files changed, 112 insertions(+), 269 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Device/Category/Category.cs b/ZigbeeApp/Shared/Phone/Device/Category/Category.cs index ba82d19..fca0186 100644 --- a/ZigbeeApp/Shared/Phone/Device/Category/Category.cs +++ b/ZigbeeApp/Shared/Phone/Device/Category/Category.cs @@ -1134,81 +1134,14 @@ }; deviceRow.ClickBtn.MouseUpEventHandler += (send2, e2) => { - if (deviceUI.CommonDevice.DfunctionType == DeviceFunctionType.A寮�鍏�) + var lightControl = new Phone.Device.Light.OnOffControl(); + UserView.HomePage.Instance.AddChidren(lightControl); + UserView.HomePage.Instance.PageIndex += 1; + lightControl.Show(deviceUI, Common.Room.CurrentRoom); + lightControl.action += (curDev, curRoom) => { - var lightControl = new Phone.Device.Light.OnOffControl(); - UserView.HomePage.Instance.AddChidren(lightControl); - UserView.HomePage.Instance.PageIndex += 1; - 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.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.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); + }; }; EventHandler<MouseEventArgs> deviceDetailHandler = (send2, e2) => @@ -1219,21 +1152,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 +1238,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 +1252,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 +1341,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 +1354,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 +1444,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 +1457,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 +1533,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 +1545,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 +1583,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 +1614,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 +1682,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 +1713,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 +1774,93 @@ } /// <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 (Common.Room.CurrentRoom.IsLove) + { + deviceRow.SetDeviceIcon(deviceUI.IconPath, deviceUI.OnlineIconPath); + deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName); + if (Common.Room.CurrentRoom.IsCollectInRoom(deviceUI.FileName) == false) + { + devListScrolView.RemoveViewByTag(deviceUI); + sameTypeList.Remove(deviceUI); + if (sameTypeList.Count == 0) + { + RefreshFunction(Common.Room.CurrentRoom); + } + } + } + else + { + if (curRoom.Id != Common.Room.CurrentRoom.Id) + { + 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 (Common.Room.CurrentRoom.IsLove) + { + deviceRow.SetDeviceIcon(deviceUI.IconPath, deviceUI.OnlineIconPath); + deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName); + if (Common.Room.CurrentRoom.IsCollectInRoom(deviceUI.FileName) == false) + { + devListScrolView.RemoveViewByTag(deviceUI); + sameTypeList.Remove(deviceUI); + if (sameTypeList.Count == 0) + { + RefreshFunction(Common.Room.CurrentRoom); + } + } + } + else + { + if (curRoom.Id != Common.Room.CurrentRoom.Id) + { + 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