From 94e4e5b9fd3da964c44b7b14227d6fe2bbb426d7 Mon Sep 17 00:00:00 2001 From: WJC <wjc@hdlchina.com.cn> Date: 星期四, 02 四月 2020 13:56:39 +0800 Subject: [PATCH] 2020-04-02-2 --- ZigbeeApp/Shared/Phone/Device/Room/RoomTemperatureSetting.cs | 92 ++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 76 insertions(+), 16 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Device/Room/RoomTemperatureSetting.cs b/ZigbeeApp/Shared/Phone/Device/Room/RoomTemperatureSetting.cs index eab1d72..60d6d8f 100755 --- a/ZigbeeApp/Shared/Phone/Device/Room/RoomTemperatureSetting.cs +++ b/ZigbeeApp/Shared/Phone/Device/Room/RoomTemperatureSetting.cs @@ -1,6 +1,8 @@ 锘縰sing System; +using System.Collections.Generic; using Shared.Common; using Shared.Phone.Device.CommonForm; +using ZigBee.Device; namespace Shared.Phone.Device.Room { @@ -14,7 +16,7 @@ /// <summary> /// The action. /// </summary> - public Action<string> action; + public Action<CommonDevice> selectDeviceAction; /// <summary> /// verticalScrolView /// </summary> @@ -23,6 +25,14 @@ /// The room. /// </summary> public Shared.Common.Room room; + /// <summary> + /// tempDeviceRow + /// </summary> + private DeviceInfoWithZoneRow tempDeviceRow = null; + /// <summary> + /// tempDevice + /// </summary> + public CommonDevice tempDevice; #endregion @@ -37,7 +47,7 @@ public void Show(Shared.Common.Room r) { room = r; - + AddTop(); AddBodyView(); @@ -80,29 +90,79 @@ }; bodyFrameLayout.AddChidren(verticalScrolView); - var confirm = new Device.CommonForm.CompleteButton(1700, 700, 127); + var confirm = new Device.CommonForm.CompleteButton(1700, 900, 127); confirm.SetTitle(R.MyInternationalizationString.Save); AddChidren(confirm); - - for(int i=0;i<15;i++) + confirm.MouseUpEventHandler += (sender, e) => { - AddItem(verticalScrolView, 20 + i * (127 + 20)); - } + RemoveFromParent(); + if(tempDevice!=null) + { + selectDeviceAction?.Invoke(tempDevice); + } + }; + var deviceList = GetTemperatrueDevices(); + for (int i = 0; i < deviceList.Count; i++) + { + var fl = new FrameLayout + { + Height = Application.GetRealHeight(127 + 20), + BackgroundColor=ZigbeeColor.Current.GXCBackgroundColor + }; + verticalScrolView.AddChidren(fl); + var device = deviceList[i]; + var devRow = new DeviceInfoWithZoneRow(20); + fl.AddChidren(devRow); + devRow.Init(); + devRow.SetIcon(device.IconPath); + devRow.SetName(Common.LocalDevice.Current.GetDeviceEpointName(device)); + devRow.SetZone(UserCenter.HdlRoomLogic.Current.GetRoomNameByDevice(device)); + if (i == deviceList.Count - 1) + { + devRow.HideLine(true); + } + if (tempDevice!=null && tempDevice==device) + { + tempDeviceRow = devRow; + tempDevice = device; + devRow.SetStatu(true); + } + else + { + if (i == 0 && tempDevice == null) + { + tempDeviceRow = devRow; + tempDevice = device; + devRow.SetStatu(true); + } + } + + devRow.ClickButton.MouseUpEventHandler += (sender, e) => + { + tempDeviceRow.SetStatu(false); + devRow.SetStatu(true); + tempDeviceRow = devRow; + tempDevice = device; + }; + } } /// <summary> - /// AddItem + /// 娓╁害浼犳劅鍣ㄥ垪琛� /// </summary> - /// <param name="vertical"></param> - public void AddItem(VerticalScrolViewLayout vertical,int y) + private List<ZigBee.Device.CommonDevice> GetTemperatrueDevices() { - var dev = new DeviceInfoWithZoneRow(y); - vertical.AddChidren(dev); - dev.Init(); - dev.SetIcon("DeviceIcon/1.png"); - dev.SetName("娓╁害浼犳劅鍣�"+y); - dev.SetZone(room.FloorName + ", " + room.Name); + var listDevice = new List<ZigBee.Device.CommonDevice>(); + foreach (var device in Common.LocalDevice.Current.listAllDevice) + { + //鑾峰彇娓╁害浼犳劅鍣� + if (device is ZigBee.Device.TemperatureSensor && ((ZigBee.Device.TemperatureSensor)device).SensorDiv == 1) + { + listDevice.Add(device); + } + } + return listDevice; } #endregion -- Gitblit v1.8.0