From 2bf5ec775cb57d8015bee58c745a1e48081ff1b1 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期二, 15 十月 2019 11:06:05 +0800
Subject: [PATCH] 首次合并了全部的代码

---
 ZigbeeApp/Shared/Common/Room.cs |  135 ++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 114 insertions(+), 21 deletions(-)

diff --git a/ZigbeeApp/Shared/Common/Room.cs b/ZigbeeApp/Shared/Common/Room.cs
index e3440a1..d29e34b 100755
--- a/ZigbeeApp/Shared/Common/Room.cs
+++ b/ZigbeeApp/Shared/Common/Room.cs
@@ -38,12 +38,22 @@
         /// </summary>
         public string FloorId = string.Empty;
         /// <summary>
+        /// 妤煎眰鍚嶇О
+        /// </summary>
+        public string FloorName
+        {
+            get
+            {
+               return GetFloorNameById(FloorId);
+            }
+        }
+        /// <summary>
         /// 鎴块棿鍚�
         /// </summary>
         public string Name = string.Empty;
 
         /// <summary>
-        /// 鎴块棿鐨勬椂鍊欒儗鏅浘
+        /// 鎴块棿鑳屾櫙鍥�
         /// </summary>
         public string BackgroundImage = string.Empty;
 
@@ -56,6 +66,15 @@
         /// 妤煎眰--澶囩敤
         /// </summary>
         public Dictionary<string, string> FloorList = new Dictionary<string, string> { };
+
+        /// <summary>
+        /// 娓╁害浼犳劅鍣�(璁惧涓婚敭)
+        /// </summary>
+        public string TemperatrueDevice = string.Empty;
+        /// <summary>
+        /// 婀垮害浼犳劅鍣�(璁惧涓婚敭)
+        /// </summary>
+        public string HumidityDevice = string.Empty;
 
         /// <summary>
         /// 褰撳墠閫夋嫨鐨勬埧闂�
@@ -73,6 +92,11 @@
         public readonly List<string> DeviceUIFilePathList = new List<string>();
 
         /// <summary>
+        /// 鍠滅埍鎴块棿id
+        /// </summary>
+        public const string LoveRoomId= "Favorite";
+
+        /// <summary>
         /// 鏄惁鏄粯璁ゅ枩鐖辨埧闂�
         /// </summary>
         /// <value><c>true</c> if is love; otherwise, <c>false</c>.</value>
@@ -81,7 +105,7 @@
         {
             get
             {
-                return Id == "Favorite";
+                return Id == LoveRoomId;
             }
         }
 
@@ -110,8 +134,7 @@
                 {
                     return new List<string> { };
                 }
-                var loveRoom = Lists[0];
-                return loveRoom.DeviceUIFilePathList;
+                return GetLoveRoom().DeviceUIFilePathList;
             }
         }
 
@@ -204,7 +227,7 @@
             if (Config.Instance.Home.RoomFilePathList.Contains("Room_Favorite.json") == false)
             {
                 //榛樿娣诲姞鍠滅埍鐨勬埧闂�--绂佹淇敼鎴块棿鍚�
-                var love = new Room { Name = Language.StringByID(R.MyInternationalizationString.Favorite), BackgroundImage = "Room/r0.png", Id = "Favorite" };
+                var love = new Room { Name = Language.StringByID(R.MyInternationalizationString.Favorite), BackgroundImage = "Room/r0.png", Id = LoveRoomId };
                 love.Save(true);
                 //娣诲姞鍒癶ouse 鎴块棿璺緞鍒楄〃
                 var currentHome = Config.Instance.Home;
@@ -323,6 +346,15 @@
         #region 鈼� 鑾峰彇鎴块棿________________________
 
         /// <summary>
+        /// 鑾峰彇鍠滅埍鎴块棿
+        /// </summary>
+        /// <returns></returns>
+        public static Room GetLoveRoom()
+        {
+            return CurrentRoom.GetRoomById(LoveRoomId);
+        }
+
+        /// <summary>
         /// 閫氳繃璺緞鑾峰彇鎴块棿
         /// </summary>
         /// <returns>The room by file path.</returns>
@@ -350,21 +382,8 @@
                     //璁惧锛坉eviceUI锛�
                     beforeRoom.DeviceUIList.Clear();
                     foreach (var deviceFilePath in beforeRoom.DeviceUIFilePathList)
-                    {
-                        var jsonInfo = Encoding.UTF8.GetString(Global.ReadFileByHomeId(deviceFilePath));
-                        var tempDeviceUI = Newtonsoft.Json.JsonConvert.DeserializeObject<DeviceUI>(jsonInfo);
-                        if (tempDeviceUI != null)
-                        {
-                            var delCommon = tempDeviceUIList.Find((obj) => obj.CommonDevice != null && tempDeviceUI.CommonDevice != null && obj.CommonDevice.Type == tempDeviceUI.CommonDevice.Type && obj.CommonDevice.CommonDeviceAddrEpoint == tempDeviceUI.CommonDevice.CommonDeviceAddrEpoint);
-                            if (delCommon != null)
-                            {
-                                beforeRoom.DeviceUIList.Add(delCommon);
-                            }
-                            else
-                            {
-                                beforeRoom.AddDevice(deviceFilePath);
-                            }
-                        }
+                    {
+                        beforeRoom.DeviceUIList.Add(Common.LocalDevice.Current.GetDeviceUI(deviceFilePath));
                     }
                     //鍦烘櫙(SceneUI)
                     beforeRoom.SceneUIList.Clear();
@@ -786,6 +805,28 @@
             }
         }
 
+        /// <summary>
+        /// 鑾峰彇褰撳墠鎴块棿涓嬬殑鍏ㄩ儴璁惧
+        /// </summary>
+        /// <returns></returns>
+        public List<CommonDevice> GetRoomListDevice()
+        {
+            var listDevice = new List<CommonDevice>();
+            foreach (var device in this.DeviceUIList)
+            {
+                if (device == null || device.CommonDevice == null)
+                {
+                    continue;
+                }
+                listDevice.Add(device.CommonDevice);
+            }
+            if (listDevice.Count == 0)
+            {
+                return listDevice;
+            }
+            return Common.LocalDevice.Current.SortDevice(listDevice);
+        }
+
         #endregion
 
         #region 鈼� 娣诲姞鍦烘櫙_________________________
@@ -895,6 +936,28 @@
             Save();
         }
 
+        #endregion
+
+        #region 鈼� 璁惧鏄惁鏀惰棌______________________
+
+        /// <summary>
+        /// 鏄惁鏄敹钘忚澶�
+        /// </summary>
+        /// <param name="room"></param>
+        /// <param name="filePath"></param>
+        /// <returns></returns>
+        public bool IsCollectInRoom(Room room,string filePath)
+        {
+            if(room.IsLove)
+            {
+                return true;
+            }
+            if (GetLoveRoom().DeviceUIFilePathList.Find((obj) => obj == filePath) == null)
+            {
+                return false;
+            }
+            return true;
+        }
         #endregion
 
         #region 鈼� 淇敼鍦烘櫙________________________
@@ -1121,7 +1184,7 @@
             var dicRoom = new Dictionary<string, Common.Room>();
             foreach (var room in Common.Room.Lists)
             {
-                if (room.FloorId != i_floorKeys)
+                if (room.FloorId != i_floorKeys || room.IsLove == true)
                 {
                     //涓嶆槸鍚屼竴涓ゼ灞�
                     continue;
@@ -1237,6 +1300,8 @@
             //鍏嬮殕灞炴��
             newRoom.Id = this.Id;
             newRoom.FloorId = this.FloorId;
+            newRoom.TemperatrueDevice = this.TemperatrueDevice;
+            newRoom.HumidityDevice = this.HumidityDevice;
             newRoom.Name = this.Name;
             newRoom.BackgroundImage = this.BackgroundImage;
             newRoom.BackgroundImageType = this.BackgroundImageType;
@@ -1245,5 +1310,33 @@
         }
 
         #endregion
+
+        #region 鈼� 妤煎眰___________________________
+
+        /// <summary>
+        /// 鑾峰彇妤煎眰鍚嶇О
+        /// </summary>
+        /// <param name="floorId"></param>
+        /// <returns></returns>
+        public string GetFloorNameById(string floorId)
+        {
+            if (Config.Instance.Home.FloorDics.Count == 0)
+            {
+                return null;
+            }
+
+            foreach (var floor in Config.Instance.Home.FloorDics)
+            {
+                if (floorId == floor.Key)
+                {
+                    return floor.Value;
+                }
+            }
+            return null;
+        }
+
+        #endregion
+
+       
     }
 }

--
Gitblit v1.8.0