using System; using System.Collections.Generic; using Shared.Common; using Shared.Phone.Device.CommonForm; using ZigBee.Device; namespace Shared.Phone.Device.Room { public class RoomHumiditySetting:FrameLayout { #region ◆ 变量____________________________ /// /// bodyFrameLayout /// private FrameLayout bodyFrameLayout; /// /// verticalScrolView /// private VerticalScrolViewLayout verticalScrolView; /// /// The room. /// public Shared.Common.Room room; /// /// The action. /// public Action selectDeviceAction; /// /// tempDeviceRow /// private DeviceInfoWithZoneRow tempDeviceRow = null; /// /// tempDevice /// public CommonDevice tempDevice; #endregion public RoomHumiditySetting() { BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor; } /// /// Show this instance. /// public void Show(Shared.Common.Room r) { room = r; AddTop(); AddBodyView(); } #region Add____________________________________ /// /// AddTop /// public void AddTop() { var top = new TopFrameLayout(); AddChidren(top); top.InitTopview(); top.SetTopTitle(R.MyInternationalizationString.Humidity); top.backButton.MouseUpEventHandler += (sender, e) => { RemoveFromParent(); }; } /// /// AddBodyView /// public void AddBodyView() { bodyFrameLayout = new FrameLayout() { Y = Application.GetRealHeight(184), Height = Application.GetRealHeight(1737), BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor, }; AddChidren(bodyFrameLayout); verticalScrolView = new VerticalScrolViewLayout { Height = Application.GetRealHeight(1737) }; bodyFrameLayout.AddChidren(verticalScrolView); var confirm = new Device.CommonForm.CompleteButton(1700, 900, 127); confirm.SetTitle(R.MyInternationalizationString.Save); AddChidren(confirm); confirm.MouseUpEventHandler += (sender, e) => { RemoveFromParent(); if (tempDevice != null) { selectDeviceAction?.Invoke(tempDevice); } }; var deviceList = GetHumidityDevice(); 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(Common.Room.CurrentRoom.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; }; } } /// /// 湿度传感器列表 /// private List GetHumidityDevice() { var listDevice = new List(); foreach (var device in Common.LocalDevice.Current.listAllDevice) { //获取湿度传感器 if (device is ZigBee.Device.TemperatureSensor && ((ZigBee.Device.TemperatureSensor)device).SensorDiv == 2) { listDevice.Add(device); } } return listDevice; } #endregion } }