From eb424d24e39bab4a245725f35deab3f234ea0f13 Mon Sep 17 00:00:00 2001 From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local> Date: 星期五, 13 十二月 2019 10:48:50 +0800 Subject: [PATCH] 2019.12.13 --- ZigbeeApp/Shared/Phone/Device/Room/EditRoom.cs | 92 ++++++++++++++++++++++++++------------------- 1 files changed, 53 insertions(+), 39 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Device/Room/EditRoom.cs b/ZigbeeApp/Shared/Phone/Device/Room/EditRoom.cs old mode 100755 new mode 100644 index 21b0e95..589c395 --- 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> @@ -60,7 +60,7 @@ room = r; IconPathType = r.BackgroundImageType; OldIconPathType= r.BackgroundImageType; - if (IconPathType != 1) + if (IconPathType != 0) { OldBackgroundImagePath = r.BackgroundImage; } @@ -75,7 +75,7 @@ HdlGatewayReceiveLogic.Current.RemoveEvent("TemperatrueDevice"); HdlGatewayReceiveLogic.Current.RemoveEvent("HumidityDevice"); - CommonPage.Instance.IsDrawerLockMode = false; + CommonPage.Instance.IsDrawerLockMode = false; base.RemoveFromParent(); } @@ -109,17 +109,21 @@ }; AddChidren(bodyFrameLayout); - 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 @@ -150,35 +154,40 @@ 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); @@ -200,7 +209,7 @@ room.TemperatrueDevice = $"{selectTemp.DeviceAddr}{selectTemp.DeviceEpoint}"; HdlGatewayReceiveLogic.Current.RemoveEvent("TemperatrueDevice"); - HdlGatewayReceiveLogic.Current.AddAttributeEvent("TemperatrueDevice", ReceiveComandDiv.A璁惧灞炴�т笂鎶�, ((report) => + HdlGatewayReceiveLogic.Current.AddAttributeEvent("TemperatrueDevice", ReceiveComandDiv.A璁惧灞炴�т笂鎶�, (Action<ZigBee.Device.CommonDevice>)((report) => { string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(report); if (room.TemperatrueDevice != mainKeys) @@ -241,7 +250,6 @@ (selectTemp as ZigBee.Device.TemperatureSensor).ReadTemperatureOrHumidity(); }; }; - if (string.IsNullOrEmpty(room.TemperatrueDevice) == false) { HdlGatewayReceiveLogic.Current.RemoveEvent("TemperatrueDevice"); @@ -289,6 +297,7 @@ (dev as ZigBee.Device.TemperatureSensor).ReadTemperatureOrHumidity(); } } + var humidityRow = new DeviceInfoRow(585); humidityRow.Init(); @@ -382,6 +391,11 @@ } } + 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); confirm.SetTitle(R.MyInternationalizationString.Confrim); @@ -391,18 +405,18 @@ var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo); 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(); @@ -509,7 +523,7 @@ { IconPathType = 0; backGround.ImageBytes = null; - backGround.UnSelectedImagePath = imgPath; + backGround.ImagePath = imgPath; }; }; selectPhotographBtn.MouseUpEventHandler += (send, ee) => @@ -522,12 +536,12 @@ { 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); @@ -543,12 +557,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