From 944b87b6bcccb095cd73f13f4410fb20faf48f74 Mon Sep 17 00:00:00 2001 From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local> Date: 星期三, 25 十二月 2019 11:21:06 +0800 Subject: [PATCH] 2019.12.25 --- ZigbeeApp/Shared/Phone/Device/Room/EditRoom.cs | 185 +++++++++++++++++++++++++++------------------- 1 files changed, 109 insertions(+), 76 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Device/Room/EditRoom.cs b/ZigbeeApp/Shared/Phone/Device/Room/EditRoom.cs index 019f512..15ae5d4 100644 --- a/ZigbeeApp/Shared/Phone/Device/Room/EditRoom.cs +++ b/ZigbeeApp/Shared/Phone/Device/Room/EditRoom.cs @@ -29,7 +29,7 @@ /// <summary> /// backGround /// </summary> - private Button backGround; + private ImageView backGround; /// <summary> /// IconPathType /// </summary> @@ -44,7 +44,7 @@ /// </summary> public int OldIconPathType; - + #endregion public EditRoom() @@ -60,7 +60,7 @@ room = r; IconPathType = r.BackgroundImageType; OldIconPathType= r.BackgroundImageType; - if (IconPathType != 1) + if (IconPathType != 0) { OldBackgroundImagePath = r.BackgroundImage; } @@ -72,9 +72,10 @@ public override void RemoveFromParent() { - HdlDeviceAttributeLogic.Current.RemoveEvent("TemperatrueDevice"); - HdlDeviceAttributeLogic.Current.RemoveEvent("HumidityDevice"); + HdlGatewayReceiveLogic.Current.RemoveEvent("TemperatrueDevice"); + HdlGatewayReceiveLogic.Current.RemoveEvent("HumidityDevice"); + CommonPage.Instance.IsDrawerLockMode = false; base.RemoveFromParent(); } @@ -108,26 +109,21 @@ }; AddChidren(bodyFrameLayout); - var imgFL = new Button - { - Y = Application.GetRealHeight(60), - Width = Application.GetMinRealAverage(916), - Height = Application.GetMinRealAverage(487), - Gravity = Gravity.CenterHorizontal, - UnSelectedImagePath = "Room/Room_Rectangle.png" - }; - bodyFrameLayout.AddChidren(imgFL); - - 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 + ImagePath = room.BackgroundImageType == 0 ? room.BackgroundImage : System.IO.Path.Combine(Config.Instance.FullPath, room.BackgroundImage) }; bodyFrameLayout.AddChidren(backGround); + backGround.SetViewShadow(true); + if (room.BackgroundImageType != 0) + { + backGround.ImageBytes = Shared.IO.FileUtils.ReadFile(backGround.ImagePath); + } backGround.MouseUpEventHandler += backGroundIMGHander; var infoFL = new FrameLayout @@ -137,6 +133,8 @@ BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor }; bodyFrameLayout.AddChidren(infoFL); + var rectCornerID = HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerTopRight; + infoFL.SetCornerWithSameRadius(Application.GetRealHeight(50), rectCornerID); var infoEdit = new Button { @@ -156,39 +154,43 @@ 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)} :"); - infoFL.AddChidren(floorRow); - if (!room.IsLove) + if (Config.Instance.Home.FloorDics.Count > 0 && room.IsLove == false) { - floorRow.SetTitle(room.FloorName); - floorRow.ClickBtn.MouseUpEventHandler += (sender, e) => - { - if (Config.Instance.Home.FloorDics != null) - { - List<string> floorIds = new List<string> { }; - List<string> floorNames = new List<string> { }; - foreach (var floor in Config.Instance.Home.FloorDics) - { - floorIds.Add(floor.Key); - floorNames.Add(floor.Value); - } - - 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)); - } - }; + infoFL.AddChidren(floorRow); } - + floorRow.SetTitle(room.FloorName); + floorRow.ClickBtn.MouseUpEventHandler += (sender, e) => + { + if (Config.Instance.Home.FloorDics != null) + { + List<string> floorIds = new List<string> { }; + List<string> floorNames = new List<string> { }; + foreach (var floor in Config.Instance.Home.FloorDics) + { + floorIds.Add(floor.Key); + floorNames.Add(floor.Value); + } + + 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)); + } + }; + + 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.ClickBtn.MouseUpEventHandler += (sender, e) => @@ -205,9 +207,10 @@ return; } room.TemperatrueDevice = $"{selectTemp.DeviceAddr}{selectTemp.DeviceEpoint}"; + temperatureRow.SetTitle(R.MyInternationalizationString.Getting); - HdlDeviceAttributeLogic.Current.RemoveEvent("TemperatrueDevice"); - HdlDeviceAttributeLogic.Current.AddAttributeEvent("TemperatrueDevice", "DeviceStatusReport", (Action<ZigBee.Device.CommonDevice>)((report) => + HdlGatewayReceiveLogic.Current.RemoveEvent("TemperatrueDevice"); + HdlGatewayReceiveLogic.Current.AddAttributeEvent("TemperatrueDevice", ReceiveComandDiv.A璁惧灞炴�т笂鎶�, (Action<ZigBee.Device.CommonDevice>)((report) => { string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(report); if (room.TemperatrueDevice != mainKeys) @@ -215,7 +218,7 @@ return; } //绉婚櫎鎺変簨浠� - HdlDeviceAttributeLogic.Current.RemoveEvent("TemperatrueDevice"); + HdlGatewayReceiveLogic.Current.RemoveEvent("TemperatrueDevice"); foreach (var data in report.DeviceStatusReport.AttriBute) { @@ -225,6 +228,7 @@ { //0鈩� temperatureRow.NameText.Text = "0.0鈩�"; + room.Temperatrue = 0; } else if (data.AttriButeData > 32767) { @@ -233,6 +237,7 @@ //灏忔暟鐐归渶瑕佷竴浣� strValue = strValue.Substring(0, strValue.Length - 1); temperatureRow.NameText.Text = strValue.Insert(strValue.Length - 1, ".") + "鈩�"; + room.Temperatrue = int.Parse(strValue) * 0.1; } else { @@ -240,6 +245,7 @@ string strValue = data.AttriButeData.ToString(); strValue = strValue.Substring(0, strValue.Length - 1); temperatureRow.NameText.Text = strValue.Insert(strValue.Length - 1, ".") + "鈩�"; + room.Temperatrue = int.Parse(strValue) *0.1; } } } @@ -248,11 +254,11 @@ (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) => + temperatureRow.SetTitle(R.MyInternationalizationString.Getting); + HdlGatewayReceiveLogic.Current.RemoveEvent("TemperatrueDevice"); + HdlGatewayReceiveLogic.Current.AddAttributeEvent("TemperatrueDevice", ReceiveComandDiv.A璁惧灞炴�т笂鎶�, (Action<ZigBee.Device.CommonDevice>)((report) => { string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(report); if (room.TemperatrueDevice != mainKeys) @@ -260,7 +266,7 @@ return; } //绉婚櫎鎺変簨浠� - HdlDeviceAttributeLogic.Current.RemoveEvent("TemperatrueDevice"); + HdlGatewayReceiveLogic.Current.RemoveEvent("TemperatrueDevice"); foreach (var data in report.DeviceStatusReport.AttriBute) { @@ -270,6 +276,7 @@ { //0鈩� temperatureRow.NameText.Text = "0.0鈩�"; + room.Temperatrue = 0; } else if (data.AttriButeData > 32767) { @@ -278,6 +285,7 @@ //灏忔暟鐐归渶瑕佷竴浣� strValue = strValue.Substring(0, strValue.Length - 1); temperatureRow.NameText.Text = strValue.Insert(strValue.Length - 1, ".") + "鈩�"; + room.Temperatrue = int.Parse(strValue) * 0.1; } else { @@ -285,6 +293,7 @@ string strValue = data.AttriButeData.ToString(); strValue = strValue.Substring(0, strValue.Length - 1); temperatureRow.NameText.Text = strValue.Insert(strValue.Length - 1, ".") + "鈩�"; + room.Temperatrue = int.Parse(strValue) * 0.1; } } } @@ -296,11 +305,15 @@ (dev as ZigBee.Device.TemperatureSensor).ReadTemperatureOrHumidity(); } } + else + { + temperatureRow.SetTitle(R.MyInternationalizationString.No); + } + var 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) => @@ -308,6 +321,7 @@ 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) => { @@ -316,9 +330,10 @@ return; } room.HumidityDevice = $"{selectTemp.DeviceAddr}{selectTemp.DeviceEpoint}"; + humidityRow.SetTitle(R.MyInternationalizationString.Getting); - HdlDeviceAttributeLogic.Current.RemoveEvent("HumidityDevice"); - HdlDeviceAttributeLogic.Current.AddAttributeEvent("HumidityDevice", "DeviceStatusReport", (report) => + HdlGatewayReceiveLogic.Current.RemoveEvent("HumidityDevice"); + HdlGatewayReceiveLogic.Current.AddAttributeEvent("HumidityDevice", ReceiveComandDiv.A璁惧灞炴�т笂鎶�, (report) => { string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(report); if (room.HumidityDevice != mainKeys) @@ -326,7 +341,7 @@ return; } //绉婚櫎鎺変簨浠� - HdlDeviceAttributeLogic.Current.RemoveEvent("HumidityDevice"); + HdlGatewayReceiveLogic.Current.RemoveEvent("HumidityDevice"); foreach (var data in report.DeviceStatusReport.AttriBute) { if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue) @@ -335,6 +350,7 @@ { //0 humidityRow.NameText.Text = "0.0%"; + room.Humidity = 0; } else { @@ -342,6 +358,7 @@ string strValue = data.AttriButeData.ToString(); strValue = strValue.Substring(0, strValue.Length - 1); humidityRow.NameText.Text = strValue.Insert(strValue.Length - 1, ".") + "%"; + room.Humidity = int.Parse(strValue) * 0.1; } } } @@ -352,8 +369,9 @@ }; if (string.IsNullOrEmpty(room.HumidityDevice) == false) { - HdlDeviceAttributeLogic.Current.RemoveEvent("HumidityDevice"); - HdlDeviceAttributeLogic.Current.AddAttributeEvent("HumidityDevice", "DeviceStatusReport", (report) => + humidityRow.SetTitle(R.MyInternationalizationString.Getting); + HdlGatewayReceiveLogic.Current.RemoveEvent("HumidityDevice"); + HdlGatewayReceiveLogic.Current.AddAttributeEvent("HumidityDevice", ReceiveComandDiv.A璁惧灞炴�т笂鎶�, (report) => { string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(report); if (room.HumidityDevice != mainKeys) @@ -361,7 +379,7 @@ return; } //绉婚櫎鎺変簨浠� - HdlDeviceAttributeLogic.Current.RemoveEvent("HumidityDevice"); + HdlGatewayReceiveLogic.Current.RemoveEvent("HumidityDevice"); foreach (var data in report.DeviceStatusReport.AttriBute) { if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue) @@ -370,6 +388,7 @@ { //0 humidityRow.NameText.Text = "0.0%"; + room.Humidity = 0; } else { @@ -377,6 +396,7 @@ string strValue = data.AttriButeData.ToString(); strValue = strValue.Substring(0, strValue.Length - 1); humidityRow.NameText.Text = strValue.Insert(strValue.Length - 1, ".") + "%"; + room.Humidity = int.Parse(strValue) * 0.1; } } } @@ -388,35 +408,43 @@ (dev as ZigBee.Device.TemperatureSensor).ReadTemperatureOrHumidity(); } } + else + { + humidityRow.SetTitle(R.MyInternationalizationString.No); + } + if (Config.Instance.Home.FloorDics.Count == 0 || room.IsLove) + { + temperatureRow.Y = Application.GetRealHeight(308); + humidityRow.Y= Application.GetRealHeight(446); + } - var confirm = new Device.CommonForm.CompleteButton(1700, 700, 127); + var confirm = new Device.CommonForm.CompleteButton(1700, 900, 127); confirm.SetTitle(R.MyInternationalizationString.Confrim); AddChidren(confirm); confirm.MouseUpEventHandler += (sender, e) => { var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo); - var fileName = $"Room_{tradeTime}"; + var fileName = $"RoomIcon_{tradeTime}.png"; room.Name = nameRow.NameText.Text.Trim(); - if (OldIconPathType != 1) + if (OldIconPathType != 0) { - Shared.IO.FileUtils.DeleteFile(OldBackgroundImagePath); + Shared.IO.FileUtils.DeleteFile(System.IO.Path.Combine(Config.Instance.FullPath,OldBackgroundImagePath)); } if (IconPathType == 0) { - room.BackgroundImage = backGround.UnSelectedImagePath; + room.BackgroundImage = backGround.ImagePath; } else { Shared.IO.FileUtils.WriteFileByBytes(System.IO.Path.Combine(Config.Instance.FullPath, fileName), backGround.ImageBytes); - room.BackgroundImage = System.IO.Path.Combine(Config.Instance.FullPath, fileName); + room.BackgroundImage = fileName; } room.BackgroundImageType = IconPathType; room.Save(); action?.Invoke(); RemoveFromParent(); }; - } /// <summary> @@ -446,24 +474,25 @@ Height = Application.GetRealHeight(450), Width = Application.GetRealWidth(selectRow_Width), Gravity = Gravity.CenterHorizontal, - Radius = (uint)Application.GetRealHeight(17), + Radius = (uint)Application.GetRealHeight(35), BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor }; selectFL.AddChidren(itemFL); - itemFL.Animate = Animate.DownToUp; + //itemFL.Animate = Animate.DownToUp; var selectLocalPicture = new Button() { Height = Application.GetRealHeight(selectRow_Height) - 1, TextID = R.MyInternationalizationString.LocalPicture, - TextColor = ZigbeeColor.Current.GXCTextSelectedColor4 + TextColor = ZigbeeColor.Current.GXCTextSelectedColor4, + TextSize = 17 }; itemFL.AddChidren(selectLocalPicture); var selectLocalLine = new Button() { Y = selectLocalPicture.Bottom, Height = 1, - BackgroundColor = ZigbeeColor.Current.GXCLineColor + BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor2 }; itemFL.AddChidren(selectLocalLine); @@ -472,14 +501,15 @@ Y = selectLocalLine.Bottom, Height = Application.GetRealHeight(selectRow_Height) - 1, TextID = R.MyInternationalizationString.Photograph, - TextColor = ZigbeeColor.Current.GXCTextSelectedColor4 + TextColor = ZigbeeColor.Current.GXCTextSelectedColor4, + TextSize = 17 }; itemFL.AddChidren(selectPhotographBtn); var selectPhotographLine = new Button() { Y = selectPhotographBtn.Bottom, Height = 1, - BackgroundColor = ZigbeeColor.Current.GXCLineColor, + BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor2, }; itemFL.AddChidren(selectPhotographLine); @@ -488,7 +518,8 @@ Y = selectPhotographLine.Bottom, Height = Application.GetRealHeight(selectRow_Height) - 1, TextID = R.MyInternationalizationString.MyAblums, - TextColor = ZigbeeColor.Current.GXCTextSelectedColor4 + TextColor = ZigbeeColor.Current.GXCTextSelectedColor4, + TextSize = 17 }; itemFL.AddChidren(selectAblumsBtn); @@ -501,7 +532,8 @@ TextID = R.MyInternationalizationString.Cancel, TextColor = ZigbeeColor.Current.GXCTextSelectedColor4, BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor, - Radius = (uint)Application.GetRealHeight(17) + Radius = (uint)Application.GetRealHeight(35), + TextSize = 17 }; selectFL.AddChidren(cancelBtn); @@ -515,25 +547,26 @@ localPic.action = (imgPath) => { IconPathType = 0; - backGround.UnSelectedImagePath = imgPath; + backGround.ImageBytes = null; + backGround.ImagePath = imgPath; }; }; selectPhotographBtn.MouseUpEventHandler += (send, ee) => { selectFL.RemoveFromParent(); var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo); - var fileName = $"Room_{tradeTime}"; + var fileName = $"RoomIcon_{tradeTime}.png"; //閫氳繃鐩告満鎷嶇収瑁佸壀 CropImage.TakePicture((imagePath) => { if (IconPathType != 0) { - Global.DeleteFilebyHomeId(backGround.UnSelectedImagePath); + Global.DeleteFilebyHomeId(backGround.ImagePath); } IconPathType = 1; backGround.ImageBytes = Shared.IO.FileUtils.ReadFile(imagePath); - backGround.UnSelectedImagePath = imagePath; + backGround.ImagePath = imagePath; System.IO.File.Delete(imagePath); }, fileName, 2, 1); @@ -549,12 +582,12 @@ { if (IconPathType != 0) { - Global.DeleteFilebyHomeId(backGround.UnSelectedImagePath); + Global.DeleteFilebyHomeId(backGround.ImagePath); } IconPathType = 2; backGround.ImageBytes = Shared.IO.FileUtils.ReadFile(imagePath); - backGround.UnSelectedImagePath = imagePath; + backGround.ImagePath = imagePath; System.IO.File.Delete(imagePath); }, fileName, 2, 1); -- Gitblit v1.8.0