using System;
|
using System.Collections.Generic;
|
using Shared.Common;
|
using Shared.Phone.Device.CommonForm;
|
using ZigBee.Device;
|
|
namespace Shared.Phone.Device.Room
|
{
|
public class RoomTemperatureSetting : FrameLayout
|
{
|
#region ◆ 变量____________________________
|
/// <summary>
|
/// bodyFrameLayout
|
/// </summary>
|
private FrameLayout bodyFrameLayout;
|
/// <summary>
|
/// The action.
|
/// </summary>
|
public Action<CommonDevice> selectDeviceAction;
|
/// <summary>
|
/// verticalScrolView
|
/// </summary>
|
private VerticalScrolViewLayout verticalScrolView;
|
/// <summary>
|
/// The room.
|
/// </summary>
|
public Shared.Common.Room room;
|
/// <summary>
|
/// tempDeviceRow
|
/// </summary>
|
private DeviceInfoWithZoneRow tempDeviceRow = null;
|
/// <summary>
|
/// tempDevice
|
/// </summary>
|
public CommonDevice tempDevice;
|
|
#endregion
|
|
public RoomTemperatureSetting()
|
{
|
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor;
|
}
|
|
/// <summary>
|
/// Show this instance.
|
/// </summary>
|
public void Show(Shared.Common.Room r)
|
{
|
room = r;
|
|
AddTop();
|
|
AddBodyView();
|
|
}
|
|
#region Add____________________________________
|
|
/// <summary>
|
/// AddTop
|
/// </summary>
|
public void AddTop()
|
{
|
var top = new TopFrameLayout();
|
AddChidren(top);
|
top.InitTopview();
|
top.SetTopTitle(R.MyInternationalizationString.Temperature);
|
top.backButton.MouseUpEventHandler += (sender, e) =>
|
{
|
RemoveFromParent();
|
};
|
}
|
|
/// <summary>
|
/// AddBodyView
|
/// </summary>
|
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, 700, 127);
|
confirm.SetTitle(R.MyInternationalizationString.Save);
|
AddChidren(confirm);
|
confirm.MouseUpEventHandler += (sender, e) =>
|
{
|
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>
|
/// 温度传感器列表
|
/// </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
|
}
|
}
|