From 94e4e5b9fd3da964c44b7b14227d6fe2bbb426d7 Mon Sep 17 00:00:00 2001
From: WJC <wjc@hdlchina.com.cn>
Date: 星期四, 02 四月 2020 13:56:39 +0800
Subject: [PATCH] 2020-04-02-2

---
 ZigbeeApp/Shared/Phone/Device/Room/EditRoom.cs |   86 +++++++++++++++++++------------------------
 1 files changed, 38 insertions(+), 48 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Device/Room/EditRoom.cs b/ZigbeeApp/Shared/Phone/Device/Room/EditRoom.cs
index ced7498..1a22030 100755
--- a/ZigbeeApp/Shared/Phone/Device/Room/EditRoom.cs
+++ b/ZigbeeApp/Shared/Phone/Device/Room/EditRoom.cs
@@ -46,9 +46,9 @@
         /// </summary>
         public int OldIconPathType;
 
-        CommonDevice temperDevice;
+        public CommonDevice temperDevice;
 
-        CommonDevice humidDevice;
+        public CommonDevice humidDevice;
 
         DeviceInfoRow temperatureRow;
 
@@ -57,31 +57,7 @@
         #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>
@@ -107,7 +83,7 @@
                         //鏄惁涓哄綋鍓嶈澶�
                         if ((temperDevice?.DeviceEpoint != common.DeviceEpoint || temperDevice?.DeviceAddr != common.DeviceAddr) && (humidDevice?.DeviceEpoint != common.DeviceEpoint || humidDevice?.DeviceAddr != common.DeviceAddr))
                         {
-                            //return;
+                            return;
                         }
 
                         //if (common.Type == DeviceType.TemperatureSensor)
@@ -131,7 +107,7 @@
                                         //灏忔暟鐐归渶瑕佷竴浣�
                                         strValue = strValue.Substring(0, strValue.Length - 1);
                                         temperatureRow.NameText.Text = strValue.Insert(strValue.Length - 1, ".") + "鈩�";
-                                        room.Temperatrue = int.Parse(strValue) * 0.1;
+                                        room.Temperatrue = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
                                     }
                                     else
                                     {
@@ -139,7 +115,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;
+                                        room.Temperatrue = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
                                     }
                                 }
                             }
@@ -162,7 +138,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;
+                                        room.Humidity = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
                                     }
                                 }
                             }
@@ -193,7 +169,7 @@
         {
             room = r;
             IconPathType = r.BackgroundImageType;
-            OldIconPathType= r.BackgroundImageType;
+            OldIconPathType = r.BackgroundImageType;
             if (IconPathType != 0)
             {
                 OldBackgroundImagePath = r.BackgroundImage;
@@ -241,17 +217,27 @@
             };
             AddChidren(bodyFrameLayout);
 
+            var backGround1 = new ImageView()
+            {
+                Y = Application.GetRealHeight(60),
+                Width = Application.GetMinRealAverage(916),
+                Height = Application.GetMinRealAverage(487),
+                Gravity = Gravity.CenterHorizontal,
+                ImagePath = "Room/Room_Rectangle.png"
+            };
+            bodyFrameLayout.AddChidren(backGround1);
+
             backGround = new ImageView()
             {
                 Y = Application.GetRealHeight(60),
                 Width = Application.GetMinRealAverage(887),
                 Height = Application.GetMinRealAverage(444),
                 Gravity = Gravity.CenterHorizontal,
-                Radius = (uint)Application.GetRealHeight(CommonFormResouce.BigFormRadius),
+                Radius = (uint)Application.GetMinRealAverage(CommonFormResouce.BigFormRadius),
                 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);
@@ -286,7 +272,7 @@
             nameRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.RoomName)} :");
             nameRow.SetTitle(room.Name);
             infoFL.AddChidren(nameRow);
-            if(room.IsLove)
+            if (room.IsLove)
             {
                 nameRow.NameText.Enable = false;
             }
@@ -298,7 +284,7 @@
             {
                 infoFL.AddChidren(floorRow);
             }
-            floorRow.SetTitle(room.FloorName);
+            floorRow.SetTitle(HdlResidenceLogic.Current.GetFloorNameById(room.FloorId));
             floorRow.ClickBtn.MouseUpEventHandler += (sender, e) =>
             {
                 if (Config.Instance.Home.FloorDics != null)
@@ -314,7 +300,7 @@
                     PickerView.Show(floorNames, (index) =>
                     {
                         room.FloorId = floorIds[index];
-                        floorRow.SetTitle(room.FloorName);
+                        floorRow.SetTitle(HdlResidenceLogic.Current.GetFloorNameById(room.FloorId));
                     }, floorIds.IndexOf(room.FloorId), Language.StringByID(R.MyInternationalizationString.BelongFloor), Language.StringByID(R.MyInternationalizationString.Confrim), Language.StringByID(R.MyInternationalizationString.Cancel));
                 }
             };
@@ -339,6 +325,7 @@
                         return;
                     }
                     room.TemperatrueDevice = $"{selectTemp.DeviceAddr}{selectTemp.DeviceEpoint}";
+                    temperDevice=Common.LocalDevice.Current.GetDevice(room.TemperatrueDevice);
                     temperatureRow.SetTitle(R.MyInternationalizationString.Getting);
                     //鍙戦�佽幏鍙栨俯搴︾殑鍛戒护
                     ReadDeviceAttributeLogic.Instance.SendTemperatureStatuComand(selectTemp);
@@ -346,10 +333,10 @@
             };
             if (string.IsNullOrEmpty(room.TemperatrueDevice) == false)
             {
-                temperatureRow.SetTitle(R.MyInternationalizationString.Getting);
+                temperatureRow.SetTitle(room.Temperatrue == 0 ? "--鈩�" : $"{room.Temperatrue}鈩�");
                 //鍙戦�佽幏鍙栨俯搴︾殑鍛戒护
-                var dev = Common.LocalDevice.Current.GetDevice(room.TemperatrueDevice);
-                ReadDeviceAttributeLogic.Instance.SendTemperatureStatuComand(dev);
+                temperDevice = Common.LocalDevice.Current.GetDevice(room.TemperatrueDevice);
+                ReadDeviceAttributeLogic.Instance.SendTemperatureStatuComand(temperDevice);
             }
             else
             {
@@ -376,6 +363,7 @@
                         return;
                     }
                     room.HumidityDevice = $"{selectTemp.DeviceAddr}{selectTemp.DeviceEpoint}";
+                    humidDevice = Common.LocalDevice.Current.GetDevice(room.HumidityDevice);
                     humidityRow.SetTitle(R.MyInternationalizationString.Getting);
 
                     //鍙戦�佽幏鍙栨箍搴︾殑鍛戒护
@@ -384,10 +372,10 @@
             };
             if (string.IsNullOrEmpty(room.HumidityDevice) == false)
             {
-                humidityRow.SetTitle(R.MyInternationalizationString.Getting);
+                humidityRow.SetTitle(room.Humidity == 0 ? "--%" : $"{room.Humidity}%");
                 //鍙戦�佽幏鍙栨箍搴︾殑鍛戒护
-                var dev = Common.LocalDevice.Current.GetDevice(room.HumidityDevice);
-                ReadDeviceAttributeLogic.Instance.SendHumidityStatuComand(dev);
+                humidDevice = Common.LocalDevice.Current.GetDevice(room.HumidityDevice);
+                ReadDeviceAttributeLogic.Instance.SendHumidityStatuComand(humidDevice);
             }
             else
             {
@@ -397,11 +385,11 @@
             if (Config.Instance.Home.FloorDics.Count == 0 || room.IsLove)
             {
                 temperatureRow.Y = Application.GetRealHeight(308);
-                humidityRow.Y= Application.GetRealHeight(446);
+                humidityRow.Y = Application.GetRealHeight(446);
             }
 
             var confirm = new Device.CommonForm.CompleteButton(1700, 900, 127);
-            confirm.SetTitle(R.MyInternationalizationString.Confrim);
+            confirm.SetTitle(R.MyInternationalizationString.Save);
             AddChidren(confirm);
             confirm.MouseUpEventHandler += (sender, e) =>
             {
@@ -410,7 +398,8 @@
                 room.Name = nameRow.NameText.Text.Trim();
                 if (OldIconPathType != 0)
                 {
-                    Shared.IO.FileUtils.DeleteFile(System.IO.Path.Combine(Config.Instance.FullPath,OldBackgroundImagePath));
+                    Shared.IO.FileUtils.DeleteFile(System.IO.Path.Combine(Config.Instance.FullPath, OldBackgroundImagePath));
+                    HdlAutoBackupLogic.DeleteFile(OldBackgroundImagePath);
                 }
                 if (IconPathType == 0)
                 {
@@ -419,6 +408,7 @@
                 else
                 {
                     Shared.IO.FileUtils.WriteFileByBytes(System.IO.Path.Combine(Config.Instance.FullPath, fileName), backGround.ImageBytes);
+                    HdlAutoBackupLogic.AddOrEditorFile(fileName);
                     room.BackgroundImage = fileName;
                 }
                 room.BackgroundImageType = IconPathType;
@@ -540,7 +530,7 @@
                 //閫氳繃鐩告満鎷嶇収瑁佸壀
                 CropImage.TakePicture((imagePath) =>
                 {
-                    if (string.IsNullOrEmpty(imagePath) == true)
+                    if (string.IsNullOrEmpty(imagePath))
                     {
                         return;
                     }
@@ -565,7 +555,7 @@
                 //浠庣浉鍐岄�夋嫨鍥剧墖瑁佸壀
                 CropImage.SelectPicture((imagePath) =>
                 {
-                    if (string.IsNullOrEmpty(imagePath) == true)
+                    if (string.IsNullOrEmpty(imagePath))
                     {
                         return;
                     }

--
Gitblit v1.8.0