| | |
| | | using System; |
| | | using Shared.Common; |
| | | using Shared.Phone.Device.DeviceLogic; |
| | | using Shared.Phone.UserCenter; |
| | | using ZigBee.Device; |
| | | |
| | | namespace Shared.Phone.Device.CommonForm |
| | | { |
| | | public class RoomView : FrameLayout |
| | | public class RoomView : FrameLayoutBase |
| | | { |
| | | /// <summary> |
| | | /// Room |
| | |
| | | Button temperatureText; |
| | | |
| | | Button humidityText; |
| | | /// <summary>
|
| | | /// 温度设备
|
| | | /// <summary> |
| | | /// 温度设备 |
| | | /// </summary> |
| | | private CommonDevice temperDevice = null; |
| | | /// <summary>
|
| | | /// 湿度设备
|
| | | /// <summary> |
| | | /// 湿度设备 |
| | | /// </summary> |
| | | private CommonDevice humidDevice = null; |
| | | |
| | |
| | | |
| | | this.room = r; |
| | | |
| | | this.temperDevice = Common.LocalDevice.Current.GetDevice(room.TemperatrueDevice); |
| | | this.temperDevice = HdlDeviceCommonLogic.Current.GetDevice(room.TemperatrueDevice); |
| | | |
| | | this.humidDevice = Common.LocalDevice.Current.GetDevice(room.HumidityDevice); |
| | | this.humidDevice = HdlDeviceCommonLogic.Current.GetDevice(room.HumidityDevice); |
| | | |
| | | var roomBackView = new FrameLayout() |
| | | { |
| | |
| | | var temperatureIcon = new Button |
| | | { |
| | | X = Application.GetRealWidth(12), |
| | | Width = Application.GetMinRealAverage(58), |
| | | Height = Application.GetMinRealAverage(58), |
| | | Width = this.GetPictrueRealSize(58), |
| | | Height = this.GetPictrueRealSize(58), |
| | | Gravity = Gravity.CenterVertical, |
| | | UnSelectedImagePath = "Room/Temperature.png" |
| | | }; |
| | |
| | | TextSize = 14, |
| | | TextAlignment = TextAlignment.CenterLeft |
| | | }; |
| | | if (LocalDevice.Current.GetDevice(room.TemperatrueDevice) != null) |
| | | {
|
| | | //这个设备要存在本地才行
|
| | | temperatureText.Text = room.Temperatrue == 0 ? "0.0℃" : room.Temperatrue.ToString() + "℃"; |
| | | if (this.temperDevice != null) |
| | | { |
| | | //这个设备要存在本地才行 |
| | | decimal temperatrue = (decimal)temperDevice.GetType().InvokeMember("currentTemperature", System.Reflection.BindingFlags.GetField, null, temperDevice, null); |
| | | temperatureText.Text = temperatrue == 0 ? "0.0℃" : temperatrue.ToString() + "℃"; |
| | | } |
| | | roomTemperatureBackground.AddChidren(temperatureText); |
| | | temperatureText.Width = temperatureText.GetTextWidth() + Application.GetRealWidth(60); |
| | |
| | | var humidityIcon = new Button |
| | | { |
| | | X = temperatureText.Right, |
| | | Width = Application.GetMinRealAverage(58), |
| | | Height = Application.GetMinRealAverage(58), |
| | | Width = this.GetPictrueRealSize(58), |
| | | Height = this.GetPictrueRealSize(58), |
| | | Gravity = Gravity.CenterVertical, |
| | | UnSelectedImagePath = "Room/Humidity.png" |
| | | }; |
| | |
| | | TextSize = 14, |
| | | TextAlignment = TextAlignment.CenterLeft |
| | | }; |
| | | if (LocalDevice.Current.GetDevice(room.HumidityDevice) != null) |
| | | {
|
| | | //这个设备要存在本地才行
|
| | | humidityText.Text = room.Humidity == 0 ? "0.0%" : room.Humidity.ToString() + "%"; |
| | | |
| | | if (this.humidDevice != null) |
| | | { |
| | | //这个设备要存在本地才行 |
| | | decimal humidity = (decimal)humidDevice.GetType().InvokeMember("currentHumidity", System.Reflection.BindingFlags.GetField, null, humidDevice, null); |
| | | humidityText.Text = humidity == 0 ? "0.0%" : humidity.ToString() + "%"; |
| | | } |
| | | roomTemperatureBackground.AddChidren(humidityText); |
| | | humidityText.Width = humidityText.GetTextWidth() + Application.GetRealWidth(60); |
| | | roomTemperatureBackground.Width = (humidityText.Width + temperatureText.Width + Application.GetRealWidth(150)) > Application.GetRealWidth(600) ? Application.GetRealWidth(600) : (humidityText.Width + temperatureText.Width + Application.GetRealWidth(150)); |
| | | |
| | | if (string.IsNullOrEmpty(room.TemperatrueDevice) == false) |
| | | {
|
| | | { |
| | | //发送获取温度的命令 |
| | | var dev = Common.LocalDevice.Current.GetDevice(room.TemperatrueDevice); |
| | | ReadDeviceAttributeLogic.Instance.SendTemperatureStatuComand(dev); |
| | | var dev = HdlDeviceCommonLogic.Current.GetDevice(room.TemperatrueDevice); |
| | | HdlDeviceAttributeLogic.Current.SendTemperatureStatuComand(dev); |
| | | } |
| | | |
| | | if (string.IsNullOrEmpty(room.HumidityDevice) == false) |
| | | { |
| | | var dev = Common.LocalDevice.Current.GetDevice(room.HumidityDevice); |
| | | ReadDeviceAttributeLogic.Instance.SendHumidityStatuComand(dev); |
| | | var dev = HdlDeviceCommonLogic.Current.GetDevice(room.HumidityDevice); |
| | | HdlDeviceAttributeLogic.Current.SendHumidityStatuComand(dev); |
| | | } |
| | | |
| | | roomListBtn = new Button() |
| | | { |
| | | X = roomBackView.Width - Application.GetRealWidth(100 + 20), |
| | | Y = Application.GetRealHeight(20), |
| | | Width = Application.GetMinRealAverage(100), |
| | | Height = Application.GetMinRealAverage(100), |
| | | Width = this.GetPictrueRealSize(100), |
| | | Height = this.GetPictrueRealSize(100), |
| | | UnSelectedImagePath = "Room/List.png", |
| | | }; |
| | | roomBackView.AddChidren(roomListBtn); |
| | |
| | | |
| | | var form = new UserCenter.Residence.EditorRoomInforForm(); |
| | | form.AddForm(room); |
| | | form.FinishEditorEvent += (roomName2) =>
|
| | | {
|
| | | //重新刷新控件
|
| | | this.Init(this.room);
|
| | | form.FinishEditorEvent += (roomName2) => |
| | | { |
| | | //重新刷新控件 |
| | | this.Init(this.room); |
| | | }; |
| | | }; |
| | | //设备属性上报 |
| | | HdlGatewayReceiveLogic.Current.AddAttributeEvent("RoomView" + this.room.Id, ReceiveComandDiv.A设备属性上报, (report) =>
|
| | | HdlGatewayReceiveLogic.Current.AddAttributeEvent("RoomView" + this.room.Id, ReceiveComandDiv.A设备属性上报, (report) => |
| | | { |
| | | if (this.temperDevice != null)
|
| | | {
|
| | | //温度设备
|
| | | if (report.DeviceAddr == temperDevice.DeviceAddr && report.DeviceEpoint == temperDevice.DeviceEpoint)
|
| | | {
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | if (((TemperatureSensor)temperDevice).Temperatrue == 0)
|
| | | {
|
| | | temperatureText.Text = "0.0℃";
|
| | | }
|
| | | else
|
| | | {
|
| | | temperatureText.Text = ((TemperatureSensor)temperDevice).Temperatrue + "℃";
|
| | | }
|
| | | }, ShowErrorMode.NO);
|
| | | }
|
| | | if (this.temperDevice != null) |
| | | { |
| | | //温度设备 |
| | | if (report.DeviceAddr == temperDevice.DeviceAddr && report.DeviceEpoint == temperDevice.DeviceEpoint) |
| | | { |
| | | HdlThreadLogic.Current.RunMain(() => |
| | | { |
| | | decimal temperatrue = (decimal)temperDevice.GetType().InvokeMember("currentTemperature", System.Reflection.BindingFlags.GetField, null, temperDevice, null); |
| | | if (temperatrue == 0) |
| | | { |
| | | temperatureText.Text = "0.0℃"; |
| | | } |
| | | else |
| | | { |
| | | temperatureText.Text = temperatrue + "℃"; |
| | | } |
| | | }, ShowErrorMode.NO); |
| | | } |
| | | } |
| | | if (this.humidDevice != null)
|
| | | {
|
| | | //湿度设备
|
| | | if (report.DeviceAddr == humidDevice.DeviceAddr && report.DeviceEpoint == humidDevice.DeviceEpoint)
|
| | | {
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | if (((TemperatureSensor)temperDevice).Humidity == 0)
|
| | | {
|
| | | humidityText.Text = "--%";
|
| | | }
|
| | | else
|
| | | {
|
| | | humidityText.Text = ((TemperatureSensor)temperDevice).Humidity + "%";
|
| | | }
|
| | | }, ShowErrorMode.NO);
|
| | | }
|
| | | if (this.humidDevice != null) |
| | | { |
| | | //湿度设备 |
| | | if (report.DeviceAddr == humidDevice.DeviceAddr && report.DeviceEpoint == humidDevice.DeviceEpoint) |
| | | { |
| | | HdlThreadLogic.Current.RunMain(() => |
| | | { |
| | | decimal humidity = (decimal)humidDevice.GetType().InvokeMember("currentHumidity", System.Reflection.BindingFlags.GetField, null, humidDevice, null); |
| | | if (humidity == 0) |
| | | { |
| | | humidityText.Text = "--%"; |
| | | } |
| | | else |
| | | { |
| | | humidityText.Text = humidity + "%"; |
| | | } |
| | | }, ShowErrorMode.NO); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | |
| | | public void HideName(bool statu) |
| | | { |
| | | roomNameBackground.Visible = roomTemperatureBackground.Visible = roomListBtn.Visible = !statu; |
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// |
| | | /// </summary>
|
| | | public override void RemoveFromParent()
|
| | | {
|
| | | HdlGatewayReceiveLogic.Current.RemoveEvent("RoomView" + this.room.Id);
|
| | | base.RemoveFromParent();
|
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public override void RemoveFromParent() |
| | | { |
| | | HdlGatewayReceiveLogic.Current.RemoveEvent("RoomView" + this.room.Id); |
| | | base.RemoveFromParent(); |
| | | } |
| | | } |
| | | } |