From b7b3e92bed9c4553e30e2901a1877f088a5f8823 Mon Sep 17 00:00:00 2001 From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local> Date: 星期一, 04 十一月 2019 17:20:52 +0800 Subject: [PATCH] 2019.11.4 --- ZigbeeApp/Shared/Phone/Device/Room/RoomTemperatureSetting.cs | 85 ++++++++++++++++++++++++++++++++++-------- 1 files changed, 68 insertions(+), 17 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Device/Room/RoomTemperatureSetting.cs b/ZigbeeApp/Shared/Phone/Device/Room/RoomTemperatureSetting.cs index eab1d72..bf48c23 100644 --- 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 @@ -83,26 +93,67 @@ var confirm = new Device.CommonForm.CompleteButton(1700, 700, 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 device = deviceList[i]; + var devRow = new DeviceInfoWithZoneRow(20 + i * (127 + 20)); + verticalScrolView.AddChidren(devRow); + devRow.Init(); + devRow.SetIcon(device.IconPath); + devRow.SetName(device.DeviceName); + devRow.SetZone(room.FloorName + ", " + room.Name); + + 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) - { - var dev = new DeviceInfoWithZoneRow(y); - vertical.AddChidren(dev); - dev.Init(); - dev.SetIcon("DeviceIcon/1.png"); - dev.SetName("娓╁害浼犳劅鍣�"+y); - dev.SetZone(room.FloorName + ", " + room.Name); + /// <summary> + /// 娓╁害浼犳劅鍣ㄥ垪琛� + /// </summary> + private List<ZigBee.Device.CommonDevice> GetTemperatrueDevices() + { + 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