| | |
| | | using System.Collections.Generic; |
| | | using Shared.Common; |
| | | using Shared.Phone.Device.CommonForm; |
| | | using Shared.Phone.UserCenter; |
| | | using Shared.Phone.UserView; |
| | | |
| | | namespace Shared.Phone.Device.Room |
| | |
| | | |
| | | AddBodyView(); |
| | | |
| | | } |
| | | |
| | | public override void RemoveFromParent()
|
| | | {
|
| | | HdlDeviceAttributeLogic.Current.RemoveEvent("TemperatrueDevice");
|
| | | HdlDeviceAttributeLogic.Current.RemoveEvent("HumidityDevice");
|
| | |
|
| | | base.RemoveFromParent();
|
| | | } |
| | | |
| | | #region Add____________________________________ |
| | |
| | | var nameRow = new DeviceInfoEditRow(170); |
| | | nameRow.Init(); |
| | | nameRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.RoomName)} :"); |
| | | nameRow.SetPlaceHoldText(room.Name); |
| | | nameRow.SetTitle(room.Name); |
| | | infoFL.AddChidren(nameRow); |
| | | |
| | | var floorRow = new DeviceInfoRow(308); |
| | |
| | | floorRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.BelongFloor)} :"); |
| | | floorRow.SetTitle(room.FloorName); |
| | | infoFL.AddChidren(floorRow); |
| | | floorRow.NextBtn.MouseUpEventHandler += (sender, e) => |
| | | floorRow.ClickBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | if (Config.Instance.Home.FloorDics != null) |
| | | { |
| | |
| | | } |
| | | }; |
| | | |
| | | |
| | | var temperatureRow = new DeviceInfoRow(446); |
| | | temperatureRow.Init(); |
| | | temperatureRow.SetTipTitle(R.MyInternationalizationString.Temperature); |
| | | temperatureRow.SetTitle("26.8℃"); |
| | | temperatureRow.NameText.TextAlignment = TextAlignment.CenterRight; |
| | | infoFL.AddChidren(temperatureRow); |
| | | temperatureRow.NextBtn.MouseUpEventHandler += (sender, e) => |
| | | temperatureRow.ClickBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | var tem = new RoomTemperatureSetting { }; |
| | | HomePage.Instance.AddChidren(tem); |
| | | HomePage.Instance.PageIndex += 1; |
| | | tem.tempDevice = Common.LocalDevice.Current.GetDevice(room.TemperatrueDevice); |
| | | tem.Show(room); |
| | | tem.action = (selectTemp) => |
| | | tem.selectDeviceAction = (selectTemp) => |
| | | { |
| | | if(selectTemp==null) |
| | | { |
| | | return; |
| | | } |
| | | room.TemperatrueDevice =$"{selectTemp.DeviceAddr}{selectTemp.DeviceEpoint}"; |
| | | |
| | | HdlDeviceAttributeLogic.Current.RemoveEvent("TemperatrueDevice"); |
| | | HdlDeviceAttributeLogic.Current.AddAttributeEvent("TemperatrueDevice", "DeviceStatusReport", (Action<ZigBee.Device.CommonDevice>)((report) => |
| | | { |
| | | string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(report); |
| | | if (room.TemperatrueDevice != mainKeys) |
| | | { |
| | | return; |
| | | } |
| | | //移除掉事件 |
| | | HdlDeviceAttributeLogic.Current.RemoveEvent("TemperatrueDevice"); |
| | | |
| | | foreach (var data in report.DeviceStatusReport.AttriBute) |
| | | { |
| | | if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue) |
| | | { |
| | | if (data.AttriButeData == 0) |
| | | { |
| | | //0℃ |
| | | temperatureRow.NameText.Text = "0.0℃"; |
| | | } |
| | | else if (data.AttriButeData > 32767) |
| | | { |
| | | //负数(特殊处理) |
| | | string strValue = (data.AttriButeData - 65536).ToString(); |
| | | //小数点需要一位 |
| | | strValue = strValue.Substring(0, strValue.Length - 1); |
| | | temperatureRow.NameText.Text = strValue.Insert(strValue.Length - 1, ".") + "℃"; |
| | | } |
| | | else |
| | | { |
| | | //小数点需要一位 |
| | | string strValue = data.AttriButeData.ToString(); |
| | | strValue = strValue.Substring(0, strValue.Length - 1); |
| | | temperatureRow.NameText.Text = strValue.Insert(strValue.Length - 1, ".") + "℃"; |
| | | } |
| | | } |
| | | } |
| | | })); |
| | | //发送获取温度的命令 |
| | | (selectTemp as ZigBee.Device.TemperatureSensor).ReadTemperatureOrHumidity(); |
| | | }; |
| | | |
| | | }; |
| | | |
| | | if (string.IsNullOrEmpty(room.TemperatrueDevice) == false) |
| | | { |
| | | HdlDeviceAttributeLogic.Current.RemoveEvent("TemperatrueDevice"); |
| | | HdlDeviceAttributeLogic.Current.AddAttributeEvent("TemperatrueDevice", "DeviceStatusReport", (Action<ZigBee.Device.CommonDevice>)((report) => |
| | | { |
| | | string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(report); |
| | | if (room.TemperatrueDevice != mainKeys) |
| | | { |
| | | return; |
| | | } |
| | | //移除掉事件 |
| | | HdlDeviceAttributeLogic.Current.RemoveEvent("TemperatrueDevice"); |
| | | |
| | | foreach (var data in report.DeviceStatusReport.AttriBute) |
| | | { |
| | | if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue) |
| | | { |
| | | if (data.AttriButeData == 0) |
| | | { |
| | | //0℃ |
| | | temperatureRow.NameText.Text = "0.0℃"; |
| | | } |
| | | else if (data.AttriButeData > 32767) |
| | | { |
| | | //负数(特殊处理) |
| | | string strValue = (data.AttriButeData - 65536).ToString(); |
| | | //小数点需要一位 |
| | | strValue = strValue.Substring(0, strValue.Length - 1); |
| | | temperatureRow.NameText.Text = strValue.Insert(strValue.Length - 1, ".") + "℃"; |
| | | } |
| | | else |
| | | { |
| | | //小数点需要一位 |
| | | string strValue = data.AttriButeData.ToString(); |
| | | strValue = strValue.Substring(0, strValue.Length - 1); |
| | | temperatureRow.NameText.Text = strValue.Insert(strValue.Length - 1, ".") + "℃"; |
| | | } |
| | | } |
| | | } |
| | | })); |
| | | //发送获取温度的命令 |
| | | var dev = Common.LocalDevice.Current.GetDevice(room.TemperatrueDevice); |
| | | if (dev != null) |
| | | { |
| | | (dev as ZigBee.Device.TemperatureSensor).ReadTemperatureOrHumidity(); |
| | | } |
| | | } |
| | | |
| | | var humidityRow = new DeviceInfoRow(585); |
| | | humidityRow.Init(); |
| | |
| | | humidityRow.SetTitle("66.5%"); |
| | | humidityRow.NameText.TextAlignment = TextAlignment.CenterRight; |
| | | infoFL.AddChidren(humidityRow); |
| | | humidityRow.NextBtn.MouseUpEventHandler += (sender, e) => |
| | | humidityRow.ClickBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | var tem = new RoomHumiditySetting { }; |
| | | HomePage.Instance.AddChidren(tem); |
| | | HomePage.Instance.PageIndex += 1; |
| | | tem.Show(room); |
| | | tem.action = (selectTemp) => |
| | | tem.selectDeviceAction = (selectTemp) => |
| | | { |
| | | if (selectTemp == null) |
| | | { |
| | | return; |
| | | } |
| | | room.HumidityDevice = $"{selectTemp.DeviceAddr}{selectTemp.DeviceEpoint}"; |
| | | |
| | | HdlDeviceAttributeLogic.Current.RemoveEvent("HumidityDevice"); |
| | | HdlDeviceAttributeLogic.Current.AddAttributeEvent("HumidityDevice", "DeviceStatusReport", (report) => |
| | | { |
| | | string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(report); |
| | | if (room.HumidityDevice != mainKeys) |
| | | { |
| | | return; |
| | | } |
| | | //移除掉事件 |
| | | HdlDeviceAttributeLogic.Current.RemoveEvent("HumidityDevice"); |
| | | foreach (var data in report.DeviceStatusReport.AttriBute) |
| | | { |
| | | if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue) |
| | | { |
| | | if (data.AttriButeData == 0) |
| | | { |
| | | //0 |
| | | humidityRow.NameText.Text = "0.0%"; |
| | | } |
| | | else |
| | | { |
| | | //小数点需要一位(湿度没有负数) |
| | | string strValue = data.AttriButeData.ToString(); |
| | | strValue = strValue.Substring(0, strValue.Length - 1); |
| | | humidityRow.NameText.Text = strValue.Insert(strValue.Length - 1, ".") + "%"; |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | //发送获取湿度的命令 |
| | | (selectTemp as ZigBee.Device.TemperatureSensor).ReadTemperatureOrHumidity(); |
| | | }; |
| | | }; |
| | | if (string.IsNullOrEmpty(room.HumidityDevice) == false) |
| | | { |
| | | HdlDeviceAttributeLogic.Current.RemoveEvent("HumidityDevice"); |
| | | HdlDeviceAttributeLogic.Current.AddAttributeEvent("HumidityDevice", "DeviceStatusReport", (report) => |
| | | { |
| | | string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(report); |
| | | if (room.HumidityDevice != mainKeys) |
| | | { |
| | | return; |
| | | } |
| | | //移除掉事件 |
| | | HdlDeviceAttributeLogic.Current.RemoveEvent("HumidityDevice"); |
| | | foreach (var data in report.DeviceStatusReport.AttriBute) |
| | | { |
| | | if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue) |
| | | { |
| | | if (data.AttriButeData == 0) |
| | | { |
| | | //0 |
| | | humidityRow.NameText.Text = "0.0%"; |
| | | } |
| | | else |
| | | { |
| | | //小数点需要一位(湿度没有负数) |
| | | string strValue = data.AttriButeData.ToString(); |
| | | strValue = strValue.Substring(0, strValue.Length - 1); |
| | | humidityRow.NameText.Text = strValue.Insert(strValue.Length - 1, ".") + "%"; |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | //发送获取湿度的命令 |
| | | var dev = Common.LocalDevice.Current.GetDevice(room.HumidityDevice); |
| | | if (dev != null) |
| | | { |
| | | (dev as ZigBee.Device.TemperatureSensor).ReadTemperatureOrHumidity(); |
| | | } |
| | | } |
| | | |
| | | var shareRow = new DeviceInfoRow(723); |
| | | shareRow.Init(); |
| | |
| | | { |
| | | |
| | | }; |
| | | |
| | | }; |
| | | |
| | | |
| | | var confirm = new Device.CommonForm.CompleteButton(1700, 700, 127); |
| | | confirm.SetTitle(R.MyInternationalizationString.Confrim); |
| | | AddChidren(confirm); |
| | | |
| | | confirm.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | room.Name = nameRow.NameText.Text.Trim(); |
| | | room.Save(); |
| | | RemoveFromParent(); |
| | | }; |
| | | } |
| | | |
| | | #endregion |