From 509e7b543f8a8770cf09dff97000acf78140c119 Mon Sep 17 00:00:00 2001 From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local> Date: 星期一, 06 一月 2020 09:46:13 +0800 Subject: [PATCH] 2019、1、6 --- ZigbeeApp/Shared/Phone/Device/Category/Category.cs | 500 +++++++++++++++++++++++++++++++++---------------------- 1 files changed, 297 insertions(+), 203 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Device/Category/Category.cs b/ZigbeeApp/Shared/Phone/Device/Category/Category.cs index 47604d0..251cc36 100644 --- a/ZigbeeApp/Shared/Phone/Device/Category/Category.cs +++ b/ZigbeeApp/Shared/Phone/Device/Category/Category.cs @@ -8,6 +8,7 @@ using Shared.Phone.Device.AC; using Shared.Phone.UserCenter.DoorLock; using Shared.Phone.Device.DeviceLogic; +using Shared.Phone.UserCenter; namespace Shared.Phone.Device.Category { @@ -808,6 +809,10 @@ UserView.HomePage.Instance.AddChidren(scene); UserView.HomePage.Instance.PageIndex += 1; scene.Show(); + scene.AddAction = () => + { + ShowScene(); + }; } /// <summary> @@ -1053,43 +1058,14 @@ { try { - //鍒犻櫎璁惧 - EventHandler<MouseEventArgs> delEvent = (delSender, delE) => + var deviceTypeRowLayout = new RowLayout() { - var alert = new CustomAlert(); - AddChidren(alert); - alert.Show(Language.StringByID(R.MyInternationalizationString.DeleteFunction)); - alert.ResultEventHandler += (e2) => - { - if (e2) - { - if (Common.Room.CurrentRoom.IsLove) - { - Shared.Common.Room.CurrentRoom.DeleteDevice(deviceUI.FileName); - deviceListScrolView.RemoveViewByTag((delSender as Button).Tag); - sameTypeList.Remove(deviceUI); - } - else - { - Shared.Common.Room.CurrentRoom.DeleteDevice(deviceUI.CommonDevice); - deviceListScrolView.RemoveViewByTag((delSender as Button).Tag); - sameTypeList.Remove(deviceUI); - } - //if (sameTypeList.Count == 0) - //{ - // RefreshBodyView(); - //} - } - }; + Height = Application.GetRealHeight(127 + 35), + LineColor = ZigbeeColor.Current.GXCClearColor, + Tag = deviceUI, + SubViewWidth=Application.GetRealWidth(184) }; - EventHandler<MouseEventArgs> deviceDetailHandler = (send2, e2) => - { - var detailInfo = new Device.CommonForm.DeviceDetailInfo { }; - UserView.HomePage.Instance.AddChidren(detailInfo); - UserView.HomePage.Instance.PageIndex += 1; - detailInfo.Show(deviceUI, Shared.Common.Room.CurrentRoom); - detailInfo.action = RefreshBodyView; - }; + deviceListScrolView.AddChidren(deviceTypeRowLayout); if (deviceUI.CommonDevice.Type == DeviceType.OnOffOutput) { @@ -1117,19 +1093,10 @@ } }) { IsBackground = true }.Start(); - - var deviceTypeRowLayout = new RowLayout() - { - Height = Application.GetRealHeight(129 + 35), - LineColor = ZigbeeColor.Current.GXCBackgroundColor, - Tag = deviceUI - }; - deviceListScrolView.AddChidren(deviceTypeRowLayout); - + var deviceRow = new CategoryFunctionRow(0, 35); deviceRow.Init(deviceUI.IconPath, deviceUI.OnlineIconPath); deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName); - //deviceRow.SetOnLineStatu(light.IsOnline == 1); deviceRow.SetStatuText(deviceUI.GetDeviceStatu()); deviceRow.IsSelected = light.OnOffStatus == 1; deviceTypeRowLayout.AddChidren(deviceRow); @@ -1165,7 +1132,6 @@ } }); }; - deviceRow.ClickBtn.MouseUpEventHandler += (send2, e2) => { if (deviceUI.CommonDevice.DfunctionType == DeviceFunctionType.A寮�鍏�) @@ -1194,22 +1160,39 @@ } }; + EventHandler<MouseEventArgs> deviceDetailHandler = (send2, e2) => + { + var detailInfo = new Device.CommonForm.DeviceDetailInfo { }; + UserView.HomePage.Instance.AddChidren(detailInfo); + UserView.HomePage.Instance.PageIndex += 1; + 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); + deviceRow.RemoveFromParent(); + sameTypeList.Remove(deviceUI); + if (sameTypeList.Count == 0) + { + RefreshFunction(Common.Room.CurrentRoom); + } + } + else + { + deviceRow.SetDeviceIcon(deviceUI.IconPath, deviceUI.OnlineIconPath); + deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName); + } + }; + }; var editBtn = new CommonForm.RowLayoutEditButton() { - Tag = deviceUI, - Radius = 0 - }; - var delBtn = new CommonForm.RowLayoutDeleteButton() - { - Tag = deviceUI, - Radius = 0 + Tag = deviceUI }; if (Common.Room.CurrentRoom.IsSharedRoom == false) { deviceTypeRowLayout.AddRightView(editBtn); editBtn.MouseUpEventHandler += deviceDetailHandler; - deviceTypeRowLayout.AddRightView(delBtn); - delBtn.MouseUpEventHandler += delEvent; } } } @@ -1239,22 +1222,12 @@ }) { IsBackground = true }.Start(); - var deviceTypeRowLayout = new RowLayout() - { - Height = Application.GetRealHeight(129 + 35), - LineColor = ZigbeeColor.Current.GXCBackgroundColor, - Tag = deviceUI - }; - deviceListScrolView.AddChidren(deviceTypeRowLayout); - var deviceRow = new CategoryFunctionRow(0, 35); deviceRow.Init(deviceUI.IconPath, deviceUI.OnlineIconPath); deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName); - //deviceRow.SetOnLineStatu(airSwitch.IsOnline == 1); deviceRow.IsSelected = airSwitch.OnOffStatus == 1; deviceRow.SetStatuText(deviceUI.GetDeviceStatu()); deviceTypeRowLayout.AddChidren(deviceRow); - deviceRow.SwitchBtn.MouseUpEventHandler += (send2, e2) => { zbGateway = deviceUI.CommonDevice.Gateway; @@ -1286,7 +1259,6 @@ } }); }; - deviceRow.ClickBtn.MouseUpEventHandler += (send2, e2) => { @@ -1297,22 +1269,39 @@ lightControl.Show(deviceUI, Common.Room.CurrentRoom); }; + EventHandler<MouseEventArgs> deviceDetailHandler = (send2, e2) => + { + var detailInfo = new Device.CommonForm.DeviceDetailInfo { }; + UserView.HomePage.Instance.AddChidren(detailInfo); + UserView.HomePage.Instance.PageIndex += 1; + 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); + deviceRow.RemoveFromParent(); + sameTypeList.Remove(deviceUI); + if (sameTypeList.Count == 0) + { + RefreshFunction(Common.Room.CurrentRoom); + } + } + else + { + deviceRow.SetDeviceIcon(deviceUI.IconPath, deviceUI.OnlineIconPath); + deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName); + } + }; + }; var editBtn = new CommonForm.RowLayoutEditButton() { - Tag = deviceUI, - Radius = 0 - }; - var delBtn = new CommonForm.RowLayoutDeleteButton() - { - Tag = deviceUI, - Radius = 0 + Tag = deviceUI }; if (Common.Room.CurrentRoom.IsSharedRoom == false) { deviceTypeRowLayout.AddRightView(editBtn); editBtn.MouseUpEventHandler += deviceDetailHandler; - deviceTypeRowLayout.AddRightView(delBtn); - delBtn.MouseUpEventHandler += delEvent; } } } @@ -1342,18 +1331,9 @@ }) { IsBackground = true }.Start(); - var deviceTypeRowLayout = new RowLayout() - { - Height = Application.GetRealHeight(129 + 35), - LineColor = ZigbeeColor.Current.GXCBackgroundColor, - Tag = deviceUI - }; - deviceListScrolView.AddChidren(deviceTypeRowLayout); - var deviceRow = new CategoryFunctionRow(0, 35); deviceRow.Init(deviceUI.IconPath, deviceUI.OnlineIconPath); deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName); - //deviceRow.SetOnLineStatu(dimmableLight.IsOnline == 1); deviceRow.SetStatuText(deviceUI.GetDeviceStatu()); deviceRow.IsSelected = dimmableLight.OnOffStatus == 1; deviceTypeRowLayout.AddChidren(deviceRow); @@ -1400,22 +1380,39 @@ dimmableLightControl.Show(deviceUI, Common.Room.CurrentRoom); }; + EventHandler<MouseEventArgs> deviceDetailHandler = (send2, e2) => + { + var detailInfo = new Device.CommonForm.DeviceDetailInfo { }; + UserView.HomePage.Instance.AddChidren(detailInfo); + UserView.HomePage.Instance.PageIndex += 1; + 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); + deviceRow.RemoveFromParent(); + sameTypeList.Remove(deviceUI); + if (sameTypeList.Count == 0) + { + RefreshFunction(Common.Room.CurrentRoom); + } + } + else + { + deviceRow.SetDeviceIcon(deviceUI.IconPath, deviceUI.OnlineIconPath); + deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName); + } + }; + }; var editBtn = new CommonForm.RowLayoutEditButton() { - Tag = deviceUI, - Radius = 0 - }; - var delBtn = new Device.CommonForm.RowLayoutDeleteButton() - { - Tag = deviceUI, - Radius = 0 + Tag = deviceUI }; if (Common.Room.CurrentRoom.IsSharedRoom == false) { deviceTypeRowLayout.AddRightView(editBtn); editBtn.MouseUpEventHandler += deviceDetailHandler; - deviceTypeRowLayout.AddRightView(delBtn); - delBtn.MouseUpEventHandler += delEvent; } } } @@ -1446,14 +1443,6 @@ } }) { IsBackground = true }.Start(); - - var deviceTypeRowLayout = new RowLayout() - { - Height = Application.GetRealHeight(129 + 35), - LineColor = ZigbeeColor.Current.GXCBackgroundColor, - Tag = deviceUI - }; - deviceListScrolView.AddChidren(deviceTypeRowLayout); var deviceRow = new CategoryFunctionRow(0, 35); deviceRow.Init(deviceUI.IconPath, deviceUI.OnlineIconPath); @@ -1495,25 +1484,6 @@ } }); }; - - var editBtn = new CommonForm.RowLayoutEditButton() - { - Tag = deviceUI, - Radius = 0 - }; - var delBtn = new CommonForm.RowLayoutDeleteButton() - { - Tag = deviceUI, - Radius = 0 - }; - if (Common.Room.CurrentRoom.IsSharedRoom == false) - { - deviceTypeRowLayout.AddRightView(editBtn); - editBtn.MouseUpEventHandler += deviceDetailHandler; - deviceTypeRowLayout.AddRightView(delBtn); - delBtn.MouseUpEventHandler += delEvent; - } - deviceRow.ClickBtn.MouseUpEventHandler += (send2, e2) => { var acControl = new Phone.Device.AC.ACControl(); @@ -1523,6 +1493,41 @@ //rollerShadeControl.action = RefreshBodyView; acControl.Show(deviceUI, Common.Room.CurrentRoom); }; + + EventHandler<MouseEventArgs> deviceDetailHandler = (send2, e2) => + { + var detailInfo = new Device.CommonForm.DeviceDetailInfo { }; + UserView.HomePage.Instance.AddChidren(detailInfo); + UserView.HomePage.Instance.PageIndex += 1; + 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); + deviceRow.RemoveFromParent(); + sameTypeList.Remove(deviceUI); + if (sameTypeList.Count == 0) + { + RefreshFunction(Common.Room.CurrentRoom); + } + } + else + { + deviceRow.SetDeviceIcon(deviceUI.IconPath, deviceUI.OnlineIconPath); + deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName); + } + }; + }; + var editBtn = new CommonForm.RowLayoutEditButton() + { + Tag = deviceUI + }; + if (Common.Room.CurrentRoom.IsSharedRoom == false) + { + deviceTypeRowLayout.AddRightView(editBtn); + editBtn.MouseUpEventHandler += deviceDetailHandler; + } } } else if (deviceUI.CommonDevice.Type == DeviceType.WindowCoveringDevice) @@ -1552,18 +1557,9 @@ }) { IsBackground = true }.Start(); - var deviceTypeRowLayout = new RowLayout() - { - Height = Application.GetRealHeight(129 + 35), - LineColor = ZigbeeColor.Current.GXCBackgroundColor, - Tag = deviceUI - }; - deviceListScrolView.AddChidren(deviceTypeRowLayout); - var deviceRow = new CategoryFunctionForWinRow(0, 35); deviceRow.Init(deviceUI); deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName); - //deviceRow.SetOnLineStatu(rollerShade.IsOnline == 1); deviceRow.SetStatuText(deviceUI.GetDeviceStatu()); deviceRow.IsSelected = rollerShade.WcdCurrentPositionLiftPercentage != 0; deviceRow.SetRollerShadeIcon(rollerShade.WcdType); @@ -1586,22 +1582,6 @@ { IsBackground = true }.Start(); } - var editBtn = new CommonForm.RowLayoutEditButton() - { - Tag = deviceUI, - }; - var delBtn = new Device.CommonForm.RowLayoutDeleteButton() - { - Tag = deviceUI, - }; - if (Common.Room.CurrentRoom.IsSharedRoom == false) - { - deviceTypeRowLayout.AddRightView(editBtn); - editBtn.MouseUpEventHandler += deviceDetailHandler; - deviceTypeRowLayout.AddRightView(delBtn); - delBtn.MouseUpEventHandler += delEvent; - } - deviceRow.ClickBtn.MouseUpEventHandler += (send2, e2) => { var rollerShadeControl = new Phone.Device.Curtain.RollerShadeControl(); @@ -1611,22 +1591,49 @@ //rollerShadeControl.action = RefreshBodyView; rollerShadeControl.Show(deviceUI, Common.Room.CurrentRoom); }; + + EventHandler<MouseEventArgs> deviceDetailHandler = (send2, e2) => + { + var detailInfo = new Device.CommonForm.DeviceDetailInfo { }; + UserView.HomePage.Instance.AddChidren(detailInfo); + UserView.HomePage.Instance.PageIndex += 1; + 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); + deviceRow.RemoveFromParent(); + sameTypeList.Remove(deviceUI); + if (sameTypeList.Count == 0) + { + RefreshFunction(Common.Room.CurrentRoom); + } + } + else + { + deviceRow.SetDeviceIcon(deviceUI.IconPath, deviceUI.OnlineIconPath); + deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName); + } + }; + }; + var editBtn = new CommonForm.RowLayoutEditButton() + { + Tag = deviceUI + }; + if (Common.Room.CurrentRoom.IsSharedRoom == false) + { + deviceTypeRowLayout.AddRightView(editBtn); + editBtn.MouseUpEventHandler += deviceDetailHandler; + } + } } else if (deviceUI.CommonDevice.Type == DeviceType.DoorLock) { - var deviceTypeRowLayout = new RowLayout() - { - Height = Application.GetRealHeight(129 + 35), - LineColor = ZigbeeColor.Current.GXCBackgroundColor, - Tag = deviceUI - }; - deviceListScrolView.AddChidren(deviceTypeRowLayout); - var deviceRow = new CategoryFunctionRow(0, 35); deviceRow.Init(deviceUI.IconPath, deviceUI.OnlineIconPath); deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName); - //deviceRow.SetOnLineStatu(deviceUI.CommonDevice.IsOnline == 1); deviceRow.SetStatuText(deviceUI.GetDeviceStatu()); deviceRow.HideSwitchBtn(true); deviceTypeRowLayout.AddChidren(deviceRow); @@ -1638,12 +1645,32 @@ HomePage.Instance.PageIndex += 1; userDoorLockPage.Show(); }; - - var editBtn = new CommonForm.RowLayoutEditButton() + EventHandler<MouseEventArgs> deviceDetailHandler = (send2, e2) => { - Tag = deviceUI + var detailInfo = new Device.CommonForm.DeviceDetailInfo { }; + UserView.HomePage.Instance.AddChidren(detailInfo); + UserView.HomePage.Instance.PageIndex += 1; + 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); + deviceRow.RemoveFromParent(); + sameTypeList.Remove(deviceUI); + if (sameTypeList.Count == 0) + { + RefreshFunction(Common.Room.CurrentRoom); + } + } + else + { + deviceRow.SetDeviceIcon(deviceUI.IconPath, deviceUI.OnlineIconPath); + deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName); + } + }; }; - var delBtn = new Device.CommonForm.RowLayoutDeleteButton() + var editBtn = new CommonForm.RowLayoutEditButton() { Tag = deviceUI }; @@ -1651,20 +1678,10 @@ { deviceTypeRowLayout.AddRightView(editBtn); editBtn.MouseUpEventHandler += deviceDetailHandler; - deviceTypeRowLayout.AddRightView(delBtn); - delBtn.MouseUpEventHandler += delEvent; } } else if (deviceUI.CommonDevice.Type == DeviceType.IASZone) { - var deviceTypeRowLayout = new RowLayout() - { - Height = Application.GetRealHeight(129 + 35), - LineColor = ZigbeeColor.Current.GXCBackgroundColor, - Tag = deviceUI - }; - deviceListScrolView.AddChidren(deviceTypeRowLayout); - var deviceRow = new CategoryFunctionRow(0, 35); deviceRow.Init(deviceUI.IconPath, deviceUI.OnlineIconPath); deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName); @@ -1673,11 +1690,32 @@ deviceRow.HideSwitchBtn(true); deviceTypeRowLayout.AddChidren(deviceRow); - var editBtn = new CommonForm.RowLayoutEditButton() + EventHandler<MouseEventArgs> deviceDetailHandler = (send2, e2) => { - Tag = deviceUI + var detailInfo = new Device.CommonForm.DeviceDetailInfo { }; + UserView.HomePage.Instance.AddChidren(detailInfo); + UserView.HomePage.Instance.PageIndex += 1; + 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); + deviceRow.RemoveFromParent(); + sameTypeList.Remove(deviceUI); + if (sameTypeList.Count == 0) + { + RefreshFunction(Common.Room.CurrentRoom); + } + } + else + { + deviceRow.SetDeviceIcon(deviceUI.IconPath, deviceUI.OnlineIconPath); + deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName); + } + }; }; - var delBtn = new Device.CommonForm.RowLayoutDeleteButton() + var editBtn = new CommonForm.RowLayoutEditButton() { Tag = deviceUI }; @@ -1685,8 +1723,6 @@ { deviceTypeRowLayout.AddRightView(editBtn); editBtn.MouseUpEventHandler += deviceDetailHandler; - deviceTypeRowLayout.AddRightView(delBtn); - delBtn.MouseUpEventHandler += delEvent; } } else if (deviceUI.CommonDevice.Type == DeviceType.TemperatureSensor) @@ -1727,13 +1763,6 @@ } }) { IsBackground = true }.Start(); - var deviceTypeRowLayout = new RowLayout() - { - Height = Application.GetRealHeight(129 + 35), - LineColor = ZigbeeColor.Current.GXCBackgroundColor, - Tag = deviceUI - }; - deviceListScrolView.AddChidren(deviceTypeRowLayout); var deviceRow = new CategoryFunctionRow(0, 35); deviceRow.Init(deviceUI.IconPath, deviceUI.OnlineIconPath); @@ -1743,11 +1772,32 @@ deviceRow.HideSwitchBtn(true); deviceTypeRowLayout.AddChidren(deviceRow); - var editBtn = new CommonForm.RowLayoutEditButton() + EventHandler<MouseEventArgs> deviceDetailHandler = (send2, e2) => { - Tag = deviceUI + var detailInfo = new Device.CommonForm.DeviceDetailInfo { }; + UserView.HomePage.Instance.AddChidren(detailInfo); + UserView.HomePage.Instance.PageIndex += 1; + 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); + deviceRow.RemoveFromParent(); + sameTypeList.Remove(deviceUI); + if (sameTypeList.Count == 0) + { + RefreshFunction(Common.Room.CurrentRoom); + } + } + else + { + deviceRow.SetDeviceIcon(deviceUI.IconPath, deviceUI.OnlineIconPath); + deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName); + } + }; }; - var delBtn = new Device.CommonForm.RowLayoutDeleteButton() + var editBtn = new CommonForm.RowLayoutEditButton() { Tag = deviceUI }; @@ -1755,35 +1805,44 @@ { deviceTypeRowLayout.AddRightView(editBtn); editBtn.MouseUpEventHandler += deviceDetailHandler; - deviceTypeRowLayout.AddRightView(delBtn); - delBtn.MouseUpEventHandler += delEvent; } - } } else { - var deviceTypeRowLayout = new RowLayout() - { - Height = Application.GetRealHeight(129 + 35), - LineColor = ZigbeeColor.Current.GXCBackgroundColor, - Tag = deviceUI - }; - deviceListScrolView.AddChidren(deviceTypeRowLayout); - var deviceRow = new CategoryFunctionRow(0, 35); deviceRow.Init(deviceUI.IconPath, deviceUI.OnlineIconPath); deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName); - //deviceRow.SetOnLineStatu(deviceUI.CommonDevice.IsOnline == 1); deviceRow.SetStatuText(deviceUI.GetDeviceStatu()); deviceRow.HideSwitchBtn(true); deviceTypeRowLayout.AddChidren(deviceRow); - var editBtn = new CommonForm.RowLayoutEditButton() + EventHandler<MouseEventArgs> deviceDetailHandler = (send2, e2) => { - Tag = deviceUI + var detailInfo = new Device.CommonForm.DeviceDetailInfo { }; + UserView.HomePage.Instance.AddChidren(detailInfo); + UserView.HomePage.Instance.PageIndex += 1; + 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); + deviceRow.RemoveFromParent(); + sameTypeList.Remove(deviceUI); + if (sameTypeList.Count == 0) + { + RefreshFunction(Common.Room.CurrentRoom); + } + } + else + { + deviceRow.SetDeviceIcon(deviceUI.IconPath, deviceUI.OnlineIconPath); + deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName); + } + }; }; - var delBtn = new Device.CommonForm.RowLayoutDeleteButton() + var editBtn = new CommonForm.RowLayoutEditButton() { Tag = deviceUI }; @@ -1791,15 +1850,50 @@ { deviceTypeRowLayout.AddRightView(editBtn); editBtn.MouseUpEventHandler += deviceDetailHandler; - deviceTypeRowLayout.AddRightView(delBtn); - delBtn.MouseUpEventHandler += delEvent; } } - } - catch - { + + //鍒犻櫎璁惧 + EventHandler<MouseEventArgs> delEvent = (delSender, delE) => + { + var alert = new UserCenter.ShowMsgControl(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.DeleteFunction)); + alert.Show(); + alert.ConfirmClickEvent += () => + { + if (Common.Room.CurrentRoom.IsLove) + { + Shared.Common.Room.CurrentRoom.DeleteDevice(deviceUI.FileName); + deviceListScrolView.RemoveViewByTag((delSender as Button).Tag); + sameTypeList.Remove(deviceUI); + } + else + { + Shared.Common.Room.CurrentRoom.DeleteDevice(deviceUI.CommonDevice); + deviceListScrolView.RemoveViewByTag((delSender as Button).Tag); + sameTypeList.Remove(deviceUI); + if (Common.Room.CurrentRoom.GetLoveRoom().DeviceUIList.Find((obj) => obj.FileName == deviceUI.FileName) != null) + { + Common.Room.CurrentRoom.DeleteDevice(deviceUI.FileName); + } + } + if (sameTypeList.Count == 0) + { + RefreshBodyView(); + } + }; + }; + var delBtn = new CommonForm.RowLayoutDeleteButton() + { + Tag = deviceUI + }; + if (Common.Room.CurrentRoom.IsSharedRoom == false) + { + deviceTypeRowLayout.AddRightView(delBtn); + delBtn.MouseUpEventHandler += delEvent; + } } + catch { } }); }) { IsBackground = true }.Start(); -- Gitblit v1.8.0