old mode 100755
new mode 100644
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Globalization; |
| | | using Shared.Common; |
| | | using Shared.Phone.Device.CommonForm; |
| | | using Shared.Phone.Device.DeviceLogic; |
| | | using Shared.Phone.UserCenter; |
| | | using Shared.Phone.UserView; |
| | | using ZigBee.Device; |
| | | |
| | | namespace Shared.Phone.Device.Room |
| | | { |
| | | public class EditRoom : FrameLayout |
| | | public class EditRoom : FrameLayout, ZigBee.Common.IStatus |
| | | { |
| | | #region ◆ 变量____________________________ |
| | | /// <summary> |
| | |
| | | /// <summary> |
| | | /// The room. |
| | | /// </summary> |
| | | public Shared.Common.Room room; |
| | | public Shared.Common.Room room; |
| | | |
| | | /// <summary> |
| | | /// The action. |
| | | /// </summary> |
| | | public Action action; |
| | | |
| | | /// <summary> |
| | | /// backGround |
| | | /// </summary> |
| | | private ImageView backGround; |
| | | /// <summary> |
| | | /// IconPathType |
| | | /// </summary> |
| | | public int IconPathType; |
| | | /// <summary> |
| | | /// OldBackgroundImagePath |
| | | /// </summary> |
| | | private string OldBackgroundImagePath; |
| | | |
| | | /// <summary> |
| | | /// OldIconPathType |
| | | /// </summary> |
| | | public int OldIconPathType; |
| | | |
| | | public CommonDevice temperDevice; |
| | | |
| | | public CommonDevice humidDevice; |
| | | |
| | | DeviceInfoRow temperatureRow; |
| | | |
| | | DeviceInfoRow humidityRow; |
| | | |
| | | #endregion |
| | | |
| | | #region ◆ 接口__________________________ |
| | | /// <summary> |
| | | /// 处理变化事件 --将弃用 改用DeviceInfoChange() |
| | | /// </summary> |
| | | /// <returns>The changed.</returns> |
| | | /// <param name="common">Common.</param> |
| | | public void Changed(CommonDevice common) |
| | | { |
| | | |
| | | } |
| | | /// <summary> |
| | | /// Changeds the IL ogic status. |
| | | /// </summary> |
| | | /// <param name="logic">Logic.</param> |
| | | public void ChangedILogicStatus(ZigBee.Device.Logic logic) |
| | | { |
| | | //throw new NotImplementedException(); |
| | | } |
| | | /// <summary> |
| | | /// Changeds the IS cene status. |
| | | /// </summary> |
| | | /// <param name="scene">Scene.</param> |
| | | public void ChangedISceneStatus(Scene scene) |
| | | { |
| | | //throw new NotImplementedException(); |
| | | } |
| | | /// <summary> |
| | | /// 设备状态更新接口 |
| | | /// <para>type:如果为 DeviceInComingRespon:设备新上报</para> |
| | | /// <para>type:如果为 IASInfoReport:RemoveDeviceRespon</para> |
| | | /// <para>type:如果为 DeviceStatusReport:设备上报</para> |
| | | /// <para>type:如果为 IASInfoReport:IAS安防信息上报</para> |
| | | /// <para>type:如果为 OnlineStatusChange: 设备在线状态更新</para> |
| | | /// </summary> |
| | | /// <param name="common">Common.</param> |
| | | /// <param name="typeTag">Type tag.</param> |
| | | public void DeviceInfoChange(CommonDevice common, string typeTag) |
| | | { |
| | | if (typeTag == "DeviceStatusReport") |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | try |
| | | { |
| | | if (common.DeviceStatusReport.AttriBute == null || common.DeviceStatusReport.AttriBute.Count == 0) |
| | | { |
| | | return; |
| | | } |
| | | //是否为当前设备 |
| | | if ((temperDevice?.DeviceEpoint != common.DeviceEpoint || temperDevice?.DeviceAddr != common.DeviceAddr) && (humidDevice?.DeviceEpoint != common.DeviceEpoint || humidDevice?.DeviceAddr != common.DeviceAddr)) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | //if (common.Type == DeviceType.TemperatureSensor) |
| | | //{ |
| | | if (common.DeviceStatusReport.CluterID == 1026) |
| | | { |
| | | foreach (var data in common.DeviceStatusReport.AttriBute) |
| | | { |
| | | if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue) |
| | | { |
| | | if (data.AttriButeData == 0) |
| | | { |
| | | //0℃ |
| | | temperatureRow.NameText.Text = "--℃"; |
| | | room.Temperatrue = 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, ".") + "℃"; |
| | | room.Temperatrue = Convert.ToDecimal(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, ".") + "℃"; |
| | | room.Temperatrue = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, ".")); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | else if (common.DeviceStatusReport.CluterID == 1029) |
| | | { |
| | | foreach (var data in common.DeviceStatusReport.AttriBute) |
| | | { |
| | | if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue) |
| | | { |
| | | if (data.AttriButeData == 0) |
| | | { |
| | | //0 |
| | | humidityRow.NameText.Text = "--%"; |
| | | room.Humidity = 0; |
| | | } |
| | | else |
| | | { |
| | | //小数点需要一位(湿度没有负数) |
| | | string strValue = data.AttriButeData.ToString(); |
| | | strValue = strValue.Substring(0, strValue.Length - 1); |
| | | humidityRow.NameText.Text = strValue.Insert(strValue.Length - 1, ".") + "%"; |
| | | room.Humidity = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, ".")); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //} |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | System.Console.WriteLine($"Error:{ex.Message}"); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | |
| | | public EditRoom() |
| | | { |
| | | ZbGateway.StatusList.Add(this); |
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor; |
| | | } |
| | | |
| | |
| | | public void Show(Shared.Common.Room r) |
| | | { |
| | | room = r; |
| | | |
| | | IconPathType = r.BackgroundImageType; |
| | | OldIconPathType = r.BackgroundImageType; |
| | | if (IconPathType != 0) |
| | | { |
| | | OldBackgroundImagePath = r.BackgroundImage; |
| | | } |
| | | AddTop(); |
| | | |
| | | AddBodyView(); |
| | | |
| | | } |
| | | |
| | | public override void RemoveFromParent()
|
| | | {
|
| | | HdlDeviceAttributeLogic.Current.RemoveEvent("TemperatrueDevice");
|
| | | HdlDeviceAttributeLogic.Current.RemoveEvent("HumidityDevice");
|
| | |
|
| | | base.RemoveFromParent();
|
| | | public override void RemoveFromParent() |
| | | { |
| | | ZbGateway.StatusList.Remove(this); |
| | | CommonPage.Instance.IsDrawerLockMode = false; |
| | | base.RemoveFromParent(); |
| | | } |
| | | |
| | | #region Add____________________________________ |
| | |
| | | }; |
| | | AddChidren(bodyFrameLayout); |
| | | |
| | | var imgFL = new FrameLayout |
| | | var backGround1 = new ImageView() |
| | | { |
| | | Y=Application.GetRealHeight(60), |
| | | Width=Application.GetMinRealAverage(916), |
| | | Height = Application.GetMinRealAverage(478), |
| | | Gravity=Gravity.CenterHorizontal, |
| | | BackgroundImagePath= "Room/Room_Rectangle.png" |
| | | Y = Application.GetRealHeight(60), |
| | | Width = Application.GetMinRealAverage(916), |
| | | Height = Application.GetMinRealAverage(487), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | ImagePath = "Room/Room_Rectangle.png" |
| | | }; |
| | | bodyFrameLayout.AddChidren(imgFL); |
| | | bodyFrameLayout.AddChidren(backGround1); |
| | | |
| | | var backGround = new Button() |
| | | backGround = new ImageView() |
| | | { |
| | | Y = Application.GetRealHeight(60), |
| | | Width = Application.GetMinRealAverage(887), |
| | | Height = Application.GetMinRealAverage(444), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | Radius = (uint)Application.GetRealHeight(CommonFormResouce.BigFormRadius), |
| | | UnSelectedImagePath = room.BackgroundImage |
| | | Radius = (uint)Application.GetMinRealAverage(CommonFormResouce.BigFormRadius), |
| | | ImagePath = room.BackgroundImageType == 0 ? room.BackgroundImage : System.IO.Path.Combine(Config.Instance.FullPath, room.BackgroundImage) |
| | | }; |
| | | bodyFrameLayout.AddChidren(backGround); |
| | | |
| | | if (room.BackgroundImageType != 0) |
| | | { |
| | | backGround.ImageBytes = Shared.IO.FileUtils.ReadFile(backGround.ImagePath); |
| | | } |
| | | backGround.MouseUpEventHandler += backGroundIMGHander; |
| | | |
| | | var infoFL = new FrameLayout |
| | | { |
| | |
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor |
| | | }; |
| | | bodyFrameLayout.AddChidren(infoFL); |
| | | var rectCornerID = HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerTopRight; |
| | | infoFL.SetCornerWithSameRadius(Application.GetRealHeight(50), rectCornerID); |
| | | |
| | | var infoEdit = new Button |
| | | { |
| | | X = Application.GetRealWidth(CommonFormResouce.X_Left), |
| | | Y=Application.GetRealHeight(80), |
| | | Y = Application.GetRealHeight(80), |
| | | Height = Application.GetRealHeight(60), |
| | | Width = Application.GetRealWidth(700), |
| | | TextID = R.MyInternationalizationString.EditInfo, |
| | |
| | | nameRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.RoomName)} :"); |
| | | nameRow.SetTitle(room.Name); |
| | | infoFL.AddChidren(nameRow); |
| | | if (room.IsLove) |
| | | { |
| | | nameRow.NameText.Enable = false; |
| | | } |
| | | |
| | | var floorRow = new DeviceInfoRow(308); |
| | | floorRow.Init(); |
| | | floorRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.BelongFloor)} :"); |
| | | if (Config.Instance.Home.FloorDics.Count > 0 && room.IsLove == false) |
| | | { |
| | | infoFL.AddChidren(floorRow); |
| | | } |
| | | floorRow.SetTitle(room.FloorName); |
| | | infoFL.AddChidren(floorRow); |
| | | floorRow.ClickBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | if (Config.Instance.Home.FloorDics != null) |
| | |
| | | } |
| | | |
| | | PickerView.Show(floorNames, (index) => |
| | | { |
| | | room.FloorId = floorIds[index]; |
| | | floorRow.SetTitle(room.FloorName); |
| | | }, floorIds.IndexOf(room.FloorId), Language.StringByID(R.MyInternationalizationString.BelongFloor), Language.StringByID(R.MyInternationalizationString.Confrim), Language.StringByID(R.MyInternationalizationString.Cancel)); |
| | | { |
| | | room.FloorId = floorIds[index]; |
| | | floorRow.SetTitle(room.FloorName); |
| | | }, floorIds.IndexOf(room.FloorId), Language.StringByID(R.MyInternationalizationString.BelongFloor), Language.StringByID(R.MyInternationalizationString.Confrim), Language.StringByID(R.MyInternationalizationString.Cancel)); |
| | | } |
| | | }; |
| | | |
| | | |
| | | var temperatureRow = new DeviceInfoRow(446); |
| | | temperatureRow = new DeviceInfoRow(446); |
| | | temperatureRow.Init(); |
| | | temperatureRow.SetTipTitle(R.MyInternationalizationString.Temperature); |
| | | temperatureRow.SetTitle("26.8℃"); |
| | | temperatureRow.NameText.TextAlignment = TextAlignment.CenterRight; |
| | | infoFL.AddChidren(temperatureRow); |
| | | temperatureRow.ClickBtn.MouseUpEventHandler += (sender, e) => |
| | |
| | | tem.Show(room); |
| | | tem.selectDeviceAction = (selectTemp) => |
| | | { |
| | | if(selectTemp==null) |
| | | 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, ".") + "℃"; |
| | | } |
| | | } |
| | | } |
| | | })); |
| | | room.TemperatrueDevice = $"{selectTemp.DeviceAddr}{selectTemp.DeviceEpoint}"; |
| | | temperDevice=Common.LocalDevice.Current.GetDevice(room.TemperatrueDevice); |
| | | temperatureRow.SetTitle(R.MyInternationalizationString.Getting); |
| | | //发送获取温度的命令 |
| | | (selectTemp as ZigBee.Device.TemperatureSensor).ReadTemperatureOrHumidity(); |
| | | ReadDeviceAttributeLogic.Instance.SendTemperatureStatuComand(selectTemp); |
| | | }; |
| | | }; |
| | | |
| | | 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, ".") + "℃"; |
| | | } |
| | | } |
| | | } |
| | | })); |
| | | temperatureRow.SetTitle(room.Temperatrue == 0 ? "--℃" : $"{room.Temperatrue}℃"); |
| | | //发送获取温度的命令 |
| | | var dev = Common.LocalDevice.Current.GetDevice(room.TemperatrueDevice); |
| | | if (dev != null) |
| | | { |
| | | (dev as ZigBee.Device.TemperatureSensor).ReadTemperatureOrHumidity(); |
| | | } |
| | | temperDevice = Common.LocalDevice.Current.GetDevice(room.TemperatrueDevice); |
| | | ReadDeviceAttributeLogic.Instance.SendTemperatureStatuComand(temperDevice); |
| | | } |
| | | else |
| | | { |
| | | temperatureRow.SetTitle(R.MyInternationalizationString.No); |
| | | } |
| | | |
| | | var humidityRow = new DeviceInfoRow(585); |
| | | |
| | | humidityRow = new DeviceInfoRow(585); |
| | | humidityRow.Init(); |
| | | humidityRow.SetTipTitle(R.MyInternationalizationString.Humidity); |
| | | humidityRow.SetTitle("66.5%"); |
| | | humidityRow.NameText.TextAlignment = TextAlignment.CenterRight; |
| | | infoFL.AddChidren(humidityRow); |
| | | humidityRow.ClickBtn.MouseUpEventHandler += (sender, e) => |
| | |
| | | var tem = new RoomHumiditySetting { }; |
| | | HomePage.Instance.AddChidren(tem); |
| | | HomePage.Instance.PageIndex += 1; |
| | | tem.tempDevice = Common.LocalDevice.Current.GetDevice(room.HumidityDevice); |
| | | tem.Show(room); |
| | | tem.selectDeviceAction = (selectTemp) => |
| | | { |
| | |
| | | return; |
| | | } |
| | | room.HumidityDevice = $"{selectTemp.DeviceAddr}{selectTemp.DeviceEpoint}"; |
| | | humidDevice = Common.LocalDevice.Current.GetDevice(room.HumidityDevice); |
| | | humidityRow.SetTitle(R.MyInternationalizationString.Getting); |
| | | |
| | | 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(); |
| | | ReadDeviceAttributeLogic.Instance.SendHumidityStatuComand(selectTemp); |
| | | }; |
| | | }; |
| | | 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, ".") + "%"; |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | humidityRow.SetTitle(room.Humidity == 0 ? "--%" : $"{room.Humidity}%"); |
| | | //发送获取湿度的命令 |
| | | var dev = Common.LocalDevice.Current.GetDevice(room.HumidityDevice); |
| | | if (dev != null) |
| | | { |
| | | (dev as ZigBee.Device.TemperatureSensor).ReadTemperatureOrHumidity(); |
| | | } |
| | | humidDevice = Common.LocalDevice.Current.GetDevice(room.HumidityDevice); |
| | | ReadDeviceAttributeLogic.Instance.SendHumidityStatuComand(humidDevice); |
| | | } |
| | | else |
| | | { |
| | | humidityRow.SetTitle(R.MyInternationalizationString.No); |
| | | } |
| | | |
| | | var shareRow = new DeviceInfoRow(723); |
| | | shareRow.Init(); |
| | | shareRow.SetTipTitle(R.MyInternationalizationString.Share); |
| | | shareRow.SetTitle("2 人"); |
| | | shareRow.NameText.TextAlignment = TextAlignment.CenterRight; |
| | | infoFL.AddChidren(shareRow); |
| | | shareRow.NextBtn.MouseUpEventHandler += (sender, e) => |
| | | if (Config.Instance.Home.FloorDics.Count == 0 || room.IsLove) |
| | | { |
| | | var tem = new RoomShareSetting { }; |
| | | HomePage.Instance.AddChidren(tem); |
| | | HomePage.Instance.PageIndex += 1; |
| | | tem.Show(room); |
| | | tem.action = (selectTemp) => |
| | | { |
| | | temperatureRow.Y = Application.GetRealHeight(308); |
| | | humidityRow.Y = Application.GetRealHeight(446); |
| | | } |
| | | |
| | | }; |
| | | }; |
| | | |
| | | |
| | | var confirm = new Device.CommonForm.CompleteButton(1700, 700, 127); |
| | | confirm.SetTitle(R.MyInternationalizationString.Confrim); |
| | | var confirm = new Device.CommonForm.CompleteButton(1700, 900, 127); |
| | | confirm.SetTitle(R.MyInternationalizationString.Save); |
| | | AddChidren(confirm); |
| | | confirm.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo); |
| | | var fileName = $"RoomIcon_{tradeTime}.png"; |
| | | room.Name = nameRow.NameText.Text.Trim(); |
| | | if (OldIconPathType != 0) |
| | | { |
| | | Shared.IO.FileUtils.DeleteFile(System.IO.Path.Combine(Config.Instance.FullPath, OldBackgroundImagePath)); |
| | | HdlAutoBackupLogic.DeleteFile(OldBackgroundImagePath); |
| | | } |
| | | if (IconPathType == 0) |
| | | { |
| | | room.BackgroundImage = backGround.ImagePath; |
| | | } |
| | | else |
| | | { |
| | | Shared.IO.FileUtils.WriteFileByBytes(System.IO.Path.Combine(Config.Instance.FullPath, fileName), backGround.ImageBytes); |
| | | HdlAutoBackupLogic.AddOrEditorFile(fileName); |
| | | room.BackgroundImage = fileName; |
| | | } |
| | | room.BackgroundImageType = IconPathType; |
| | | room.Save(); |
| | | action?.Invoke(); |
| | | RemoveFromParent(); |
| | | }; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 选择背景图 |
| | | /// </summary> |
| | | /// <param name="sender"></param> |
| | | /// <param name="e"></param> |
| | | private void backGroundIMGHander(object sender, MouseEventArgs e) |
| | | { |
| | | if (room != null && room.IsSharedRoom) |
| | | { |
| | | RoomCommon.ShowTipRoomIsShared(); |
| | | return; |
| | | } |
| | | |
| | | int selectRow_Height = 150; |
| | | int selectRow_Width = 1034; |
| | | var selectFL = new FrameLayout() |
| | | { |
| | | BackgroundColor = ZigbeeColor.Current.GXCDailogBackGroundColor |
| | | }; |
| | | AddChidren(selectFL); |
| | | |
| | | var itemFL = new FrameLayout() |
| | | { |
| | | Y = Application.GetRealHeight(1276), |
| | | Height = Application.GetRealHeight(450), |
| | | Width = Application.GetRealWidth(selectRow_Width), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | Radius = (uint)Application.GetRealHeight(35), |
| | | BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor |
| | | }; |
| | | selectFL.AddChidren(itemFL); |
| | | //itemFL.Animate = Animate.DownToUp; |
| | | |
| | | var selectLocalPicture = new Button() |
| | | { |
| | | Height = Application.GetRealHeight(selectRow_Height) - 1, |
| | | TextID = R.MyInternationalizationString.LocalPicture, |
| | | TextColor = ZigbeeColor.Current.GXCTextSelectedColor4, |
| | | TextSize = 17 |
| | | }; |
| | | itemFL.AddChidren(selectLocalPicture); |
| | | var selectLocalLine = new Button() |
| | | { |
| | | Y = selectLocalPicture.Bottom, |
| | | Height = 1, |
| | | BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor2 |
| | | }; |
| | | itemFL.AddChidren(selectLocalLine); |
| | | |
| | | var selectPhotographBtn = new Button() |
| | | { |
| | | Y = selectLocalLine.Bottom, |
| | | Height = Application.GetRealHeight(selectRow_Height) - 1, |
| | | TextID = R.MyInternationalizationString.Photograph, |
| | | TextColor = ZigbeeColor.Current.GXCTextSelectedColor4, |
| | | TextSize = 17 |
| | | }; |
| | | itemFL.AddChidren(selectPhotographBtn); |
| | | var selectPhotographLine = new Button() |
| | | { |
| | | Y = selectPhotographBtn.Bottom, |
| | | Height = 1, |
| | | BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor2, |
| | | }; |
| | | itemFL.AddChidren(selectPhotographLine); |
| | | |
| | | var selectAblumsBtn = new Button() |
| | | { |
| | | Y = selectPhotographLine.Bottom, |
| | | Height = Application.GetRealHeight(selectRow_Height) - 1, |
| | | TextID = R.MyInternationalizationString.MyAblums, |
| | | TextColor = ZigbeeColor.Current.GXCTextSelectedColor4, |
| | | TextSize = 17 |
| | | }; |
| | | itemFL.AddChidren(selectAblumsBtn); |
| | | |
| | | var cancelBtn = new Button() |
| | | { |
| | | Y = Application.GetRealHeight(1742), |
| | | Height = Application.GetRealHeight(selectRow_Height), |
| | | Width = Application.GetRealWidth(selectRow_Width), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | TextID = R.MyInternationalizationString.Cancel, |
| | | TextColor = ZigbeeColor.Current.GXCTextSelectedColor4, |
| | | BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor, |
| | | Radius = (uint)Application.GetRealHeight(35), |
| | | TextSize = 17 |
| | | }; |
| | | selectFL.AddChidren(cancelBtn); |
| | | |
| | | selectLocalPicture.MouseUpEventHandler += (send, ee) => |
| | | { |
| | | selectFL.RemoveFromParent(); |
| | | var localPic = new AddRoomSelectPicByLocal(); |
| | | Shared.Phone.UserView.HomePage.Instance.AddChidren(localPic); |
| | | Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; |
| | | localPic.Show(); |
| | | localPic.action = (imgPath) => |
| | | { |
| | | IconPathType = 0; |
| | | backGround.ImageBytes = null; |
| | | backGround.ImagePath = imgPath; |
| | | }; |
| | | }; |
| | | selectPhotographBtn.MouseUpEventHandler += (send, ee) => |
| | | { |
| | | selectFL.RemoveFromParent(); |
| | | var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo); |
| | | var fileName = $"RoomIcon_{tradeTime}.png"; |
| | | //通过相机拍照裁剪 |
| | | CropImage.TakePicture((imagePath) => |
| | | { |
| | | if (string.IsNullOrEmpty(imagePath)) |
| | | { |
| | | return; |
| | | } |
| | | if (IconPathType != 0) |
| | | { |
| | | Global.DeleteFilebyHomeId(backGround.ImagePath); |
| | | } |
| | | |
| | | IconPathType = 1; |
| | | backGround.ImageBytes = Shared.IO.FileUtils.ReadFile(imagePath); |
| | | backGround.ImagePath = imagePath; |
| | | System.IO.File.Delete(imagePath); |
| | | |
| | | }, fileName, 2, 1); |
| | | }; |
| | | |
| | | selectAblumsBtn.MouseUpEventHandler += (send, ee) => |
| | | { |
| | | selectFL.RemoveFromParent(); |
| | | var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo); |
| | | var fileName = $"RoomIcon_{tradeTime}.png"; |
| | | //从相册选择图片裁剪 |
| | | CropImage.SelectPicture((imagePath) => |
| | | { |
| | | if (string.IsNullOrEmpty(imagePath)) |
| | | { |
| | | return; |
| | | } |
| | | if (IconPathType != 0) |
| | | { |
| | | Global.DeleteFilebyHomeId(backGround.ImagePath); |
| | | } |
| | | |
| | | IconPathType = 2; |
| | | backGround.ImageBytes = Shared.IO.FileUtils.ReadFile(imagePath); |
| | | backGround.ImagePath = imagePath; |
| | | System.IO.File.Delete(imagePath); |
| | | |
| | | }, fileName, 2, 1); |
| | | }; |
| | | |
| | | cancelBtn.MouseUpEventHandler += (send, ee) => |
| | | { |
| | | selectFL.RemoveFromParent(); |
| | | }; |
| | | selectFL.MouseUpEventHandler += (send, ee) => |
| | | { |
| | | selectFL.RemoveFromParent(); |
| | | }; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | } |