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/Common/Room.cs |  469 ++++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 324 insertions(+), 145 deletions(-)

diff --git a/ZigbeeApp/Shared/Common/Room.cs b/ZigbeeApp/Shared/Common/Room.cs
old mode 100755
new mode 100644
index c7ef0ed..4d255ea
--- a/ZigbeeApp/Shared/Common/Room.cs
+++ b/ZigbeeApp/Shared/Common/Room.cs
@@ -36,7 +36,7 @@
         /// 妤煎眰Id
         /// 鏂板鏃朵娇鐢℅uid
         /// </summary>
-        public string FloorId = "Floor1";
+        public string FloorId = string.Empty;
         /// <summary>
         /// 妤煎眰鍚嶇О
         /// </summary>
@@ -44,7 +44,7 @@
         {
             get
             {
-               return GetFloorNameById(FloorId);
+               return Config.Instance.Home.GetFloorNameById(FloorId);
             }
         }
         /// <summary>
@@ -67,10 +67,35 @@
         /// </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>
+        /// 褰撳墠閫夋嫨鐨勬埧闂�
+        /// </summary>
+        private static Room m_CurrentRoom = null;
         /// <summary>
         /// 褰撳墠閫夋嫨鐨勬埧闂�
         /// </summary>
-        public static Room CurrentRoom;
+        [Newtonsoft.Json.JsonIgnore]
+        public static Room CurrentRoom
+        {
+            get
+            {
+                if (m_CurrentRoom == null && Lists.Count > 0)
+                {
+                    return Lists[0];
+                }
+                return m_CurrentRoom;
+            }
+            set { m_CurrentRoom = value; }
+        }
 
         /// <summary>
         /// 鎴块棿閲屾墍鏈夌殑璁惧鍒楄〃
@@ -107,12 +132,6 @@
         public bool IsSharedRoom = false;
 
         /// <summary>
-        /// 鏄惁鍙互鍒锋柊鎴块棿鏁版嵁浜�
-        /// 闇�瑕佺瓑鍒濆鍖栨湰鍦拌澶囨暟鎹悗鍦ㄥ彲浠ュ垵濮嬪寲鎴块棿鏁版嵁
-        /// </summary>
-        public static bool CanInitAllRoom;
-
-        /// <summary>
         /// 鑾峰彇鍠滅埍鎴块棿鐨勬墍鏈夎澶囪矾寰�
         /// </summary>
         /// <value>The love room device list.</value>
@@ -125,17 +144,34 @@
                 {
                     return new List<string> { };
                 }
-                return GetLoveRoom().DeviceUIFilePathList;
+                return CurrentRoom.GetLoveRoom().DeviceUIFilePathList;
             }
         }
 
         /// <summary>
         /// 鎵�鏈夋埧闂寸殑鎵�鏈夎澶囩被鍨�
-        /// 鍏堣皟鐢� GetAllRoomDeviceTypeList()
         /// </summary>
         /// <value>All room device type list.</value>
         [Newtonsoft.Json.JsonIgnore]
-        public static List<DeviceType> AllRoomDeviceTypeList = new List<DeviceType> { };
+        public static List<DeviceType> AllRoomDeviceTypeList
+        {
+            get
+            {
+                var typeList = new List<DeviceType> { };
+                foreach (var deviceUI in AllRoomDeviceUIList)
+                {
+                    if (deviceUI == null || deviceUI.CommonDevice == null)
+                    {
+                        continue;
+                    }
+                    if (!typeList.Contains(deviceUI.CommonDevice.Type))
+                    {
+                        typeList.Add(deviceUI.CommonDevice.Type);
+                    }
+                }
+                return typeList;
+            }
+        }
 
         /// <summary>
         /// 鑾峰彇鎵�鏈夋埧闂寸殑鎵�鏈夊満鏅�
@@ -182,11 +218,41 @@
 
         /// <summary>
         /// 鑾峰彇鎵�鏈夋埧闂寸殑鎵�鏈夎澶�
-        /// 璇峰厛璋冪敤 GetAllRoomDeviceUIList()鏂规硶
         /// </summary>
         /// <value>All room device UIL ist.</value>
         [Newtonsoft.Json.JsonIgnore]
-        public static List<DeviceUI> AllRoomDeviceUIList = new List<DeviceUI> { };
+        public static List<DeviceUI> AllRoomDeviceUIList
+        {
+            get
+            {
+                List<DeviceUI> deviceList = new List<DeviceUI>();
+                for (int i = 0; i < Lists.Count; i++)
+                {
+                    var room = Lists[i];
+                    if (room.IsSharedRoom)
+                    {
+                        continue;
+                    }
+                    if (room.DeviceUIList.Count == 0)
+                    {
+                        continue;
+                    }
+                    for (int j = 0; j < room.DeviceUIList.Count; j++)
+                    {
+                        var device = room.DeviceUIList[j];
+                        if (device == null || device.CommonDevice == null)
+                        {
+                            continue;
+                        }
+                        if (deviceList.Find((obj) => obj.FileName == device.FileName) == null)
+                        {
+                            deviceList.Add(device);
+                        }
+                    }
+                }
+                return deviceList;
+            }
+        }
 
         #endregion
 
@@ -210,20 +276,16 @@
         /// </summary>
         public static void InitAllRoom()
         {
-            if (CanInitAllRoom == false)
-            {
-                return;
-            }
             Lists.Clear();
             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 = LoveRoomId };
-                love.Save(true);
+                var love = new Room { Name = Language.StringByID(R.MyInternationalizationString.Favorite), BackgroundImage = "RoomIcon/0.JPG", Id = LoveRoomId };
+                love.Save(false);
                 //娣诲姞鍒癶ouse 鎴块棿璺緞鍒楄〃
                 var currentHome = Config.Instance.Home;
                 currentHome.RoomFilePathList.Insert(0, love.FileName);
-                currentHome.Save();
+                currentHome.Save(false);
             }
             foreach (var roomFilePath in Config.Instance.Home.RoomFilePathList)
             {
@@ -233,11 +295,13 @@
                 {
                     if (room.IsSharedRoom)
                     {
-                        room.Name = $"({Language.StringByID(R.MyInternationalizationString.Shared)}){room.Name}";
+                        room.Name = $"{room.Name}";
                     }
                     Lists.Add(room);
+                   
                 }
             }
+            Config.Instance.Home.InitFloor();
         }
 
         /// <summary>
@@ -267,7 +331,6 @@
                 }
             }
             homeTemp.Save(false);
-            CanInitAllRoom = true;
             InitAllRoom();
         }
 
@@ -340,7 +403,7 @@
         /// 鑾峰彇鍠滅埍鎴块棿
         /// </summary>
         /// <returns></returns>
-        public static Room GetLoveRoom()
+        public Room GetLoveRoom()
         {
             return CurrentRoom.GetRoomById(LoveRoomId);
         }
@@ -450,7 +513,21 @@
         /// <param name="roomId">鎴块棿ID</param>
         public Room GetRoomById(string roomId)
         {
+            if (string.IsNullOrEmpty(roomId))
+            {
+                return null;
+            }
             return Lists.Find((obj) => obj.Id == roomId);
+        }
+
+        /// <summary>
+        /// 鏍规嵁鎴块棿鍚嶅瓧锛岃幏鍙栨埧闂村璞�
+        /// </summary>
+        /// <returns>The room by name.</returns>
+        /// <param name="roomName">鎴块棿鍚�</param>
+        public Room GetRoomByName(string roomName)
+        {
+            return Lists.Find((obj) => obj.Name == roomName);
         }
 
         /// <summary>
@@ -481,11 +558,8 @@
         /// <param name="device">璁惧瀵硅薄</param>
         public Room GetRoomByDevice(CommonDevice device)
         {
-            var deviceUI = new DeviceUI { };
-            deviceUI.DeviceAddr = device.DeviceAddr;
-            deviceUI.DeviceEpoint = device.DeviceEpoint;
-
-            return Lists.Find((obj) => obj.DeviceUIFilePathList.Contains(deviceUI.FileName));
+            string deviceFile = device.FilePath;
+            return Lists.Find((obj) => obj.IsLove == false && obj.DeviceUIFilePathList.Contains(deviceFile));
         }
 
         /// <summary>
@@ -523,6 +597,67 @@
             return null;
         }
 
+        /// <summary>
+        /// 鑾峰彇褰撳墠妤煎眰鐨勬埧闂�
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        public List<Room> GetRoomsByFloorId(string id)
+        {
+            if (Config.Instance.Home.FloorDics.Count == 0)
+            {
+                return Lists;
+            }
+            return Lists.FindAll((obj) => obj.FloorId == id);
+        }
+        /// <summary>
+        /// 鑾峰彇褰撳墠妤煎眰鐨勬埧闂村悕绉�
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        public List<string> GetRoomNamesByFloorId(string id)
+        {
+            List<string> names = new List<string> { };
+            foreach (var r in Lists)
+            {
+                if (r.FloorId == id)
+                {
+                    names.Add(r.Name);
+                }
+            }
+            return names;
+        }
+
+        /// <summary>
+        /// 鑾峰彇褰撳墠妤煎眰鐨勬埧闂�(鎷兼帴浜嗐�愬父鐢ㄣ�戝湪绗竴浣�)
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        public  List<Room> GetRoomsByFloorIdAppendLoveRoom(string id)
+        {
+            if (Config.Instance.Home.FloorDics.Count == 0)
+            {
+                return Lists;
+            }
+            var r= Lists.FindAll((obj) => obj.FloorId == id);
+            r.Insert(0, GetLoveRoom());
+            return r;
+        }
+
+        /// <summary>
+        /// 鑾峰彇褰撳墠妤煎眰鐨勬埧闂�(鎷兼帴浜嗐�愬父鐢ㄣ�戝湪绗竴浣�)
+        /// </summary>
+        /// <returns></returns>
+        public  List<Room> GetRoomsByCurrentFloorIdAppendLoveRoom()
+        {
+            if(Config.Instance.Home.FloorDics.Count==0)
+            {
+                return Lists;
+            }
+            var r = Lists.FindAll((obj) => obj.FloorId == Config.Instance.Home.CurrentFloorId);
+            r.Insert(0, GetLoveRoom());
+            return r;
+        }
 
         #endregion
 
@@ -533,7 +668,8 @@
         /// </summary>
         /// <param name="device">璁惧瀵硅薄</param>
         /// <param name="roomId">鏂版埧闂碔d</param>
-        public void ChangedRoom(CommonDevice device, string roomId)
+        /// <param name="saveRealRoom">鏄惁淇敼鐪熷疄鐗╃悊璁惧鐨勬埧闂�,涓嶅嚭鎰忓,杩欎釜鍊奸粯璁や负true鍗冲彲</param>
+        public void ChangedRoom(CommonDevice device, string roomId, bool saveRealRoom = true)
         {
             //鎴块棿鏄惁淇敼
             if (this.IsRoomChanged(device, roomId) == false)
@@ -547,7 +683,7 @@
             var room = this.GetRoomById(roomId);
             if (room != null)
             {
-                room.AddDevice(device);
+                room.AddDevice(device, saveRealRoom);
             }
         }
 
@@ -636,18 +772,18 @@
         #region 鈼� 娣诲姞璁惧________________________
 
         /// <summary>
-        /// 娣诲姞璁惧
+        /// 娣诲姞璁惧(姝ゆ柟娉曠洰鍓嶅彧缁欍�愭垜鐨勫枩鐖便�戜娇鐢�)
         /// </summary>
         /// <param name="deviceUIFilePath">Device UIF ile path.</param>
         public void AddDevice(string deviceUIFilePath)
         {
             if (string.IsNullOrEmpty(deviceUIFilePath))
-            {
-                return;
+
+             {
+                 return;
             }
-            var jsonInfo = Encoding.UTF8.GetString(Global.ReadFileByHomeId(deviceUIFilePath));
-            var deviceUI = Newtonsoft.Json.JsonConvert.DeserializeObject<DeviceUI>(jsonInfo);
-            if (null == deviceUI || null == deviceUI.CommonDevice)
+            var deviceUI = Common.LocalDevice.Current.GetDeviceUI(deviceUIFilePath);
+            if (null == deviceUI.CommonDevice)
             {
                 //褰撳墠瀵硅薄鏁版嵁鏃犳晥
                 return;
@@ -662,10 +798,11 @@
         }
 
         /// <summary>
-        /// 娣诲姞璁惧
+        /// 娣诲姞璁惧(姝ゆ柟娉曠洰鍓嶅彧缁橰oom閲岄潰浣跨敤)
         /// </summary>
         /// <param name="device">瑕佹坊鍔犵殑璁惧瀵硅薄</param>
-        public void AddDevice(CommonDevice device)
+        /// <param name="saveRealRoom">鏄惁淇敼鐪熷疄鐗╃悊璁惧鐨勬埧闂�,涓嶅嚭鎰忓,杩欎釜鍊奸粯璁や负true鍗冲彲</param>
+        public void AddDevice(CommonDevice device, bool saveRealRoom)
         {
             if (device == null)
             {
@@ -674,10 +811,7 @@
             //璁惧淇℃伅淇濆瓨鍒版湰鍦�
             device.Save();
 
-            //娣诲姞鑷姩澶囦唤
-            HdlAutoBackupLogic.AddOrEditorFile(device.FilePath);
-
-            DeviceUI deviceUI = Common.LocalDevice.Current.GetDeviceUI(device);
+            var deviceUI = Common.LocalDevice.Current.GetDeviceUI(device);
             if (DeviceUIFilePathList.Contains(deviceUI.FileName) == false)
             {
                 DeviceUIFilePathList.Add(deviceUI.FileName);
@@ -687,13 +821,17 @@
 
                 //娣诲姞鑷姩澶囦唤
                 HdlAutoBackupLogic.AddOrEditorFile(FileName);
+                if (saveRealRoom == true && LocalDevice.Current.GetDevicesCountByMac(device.DeviceAddr) == 1)
+                {
+                    //濡傛灉鍙湁涓�涓洖璺�,鍒欎慨鏀圭湡瀹炵墿鐞嗚澶囩殑鎴块棿
+                    LocalDevice.Current.SaveRealDeviceRoomId(new List<CommonDevice>() { device }, this.Id, false);
+                }
             }
         }
 
         #endregion
 
         #region 鈼� 鍒犻櫎璁惧_________________________
-
         /// <summary>
         /// 鍒犻櫎鍔熻兘-璁惧
         /// </summary>
@@ -701,11 +839,10 @@
         public void DeleteDevice(string deviceUIFilePath)
         {
             if (deviceUIFilePath == null) return;
-            if (DeviceUIFilePathList.Contains(deviceUIFilePath) && Global.IsExistsByHomeId(deviceUIFilePath))
+            if (DeviceUIFilePathList.Contains(deviceUIFilePath))
             {
                 DeviceUIFilePathList.Remove(deviceUIFilePath);
                 DeviceUIList.RemoveAll((obj) => obj.FileName == deviceUIFilePath);
-                HdlAutoBackupLogic.DeleteFile(deviceUIFilePath);
                 Save();
             }
         }
@@ -720,24 +857,21 @@
             {
                 return;
             }
-            DeviceUI deviceUI = new DeviceUI();
-            deviceUI.DeviceAddr = device.DeviceAddr;
-            deviceUI.DeviceEpoint = device.DeviceEpoint;
-
             //鏍规嵁璁惧锛岃幏鍙栨墍鍦ㄧ殑鎴块棿
             var room = this.GetRoomByDevice(device);
             if (room == null)
             {
                 return;
             }
+            string deviceFile = device.FilePath;
             //绉婚櫎缂撳瓨
-            if (room.DeviceUIFilePathList.Contains(deviceUI.FileName) == false)
+            if (room.DeviceUIFilePathList.Contains(deviceFile) == false)
             {
                 return;
             }
-            room.DeviceUIFilePathList.Remove(deviceUI.FileName);
+            room.DeviceUIFilePathList.Remove(deviceFile);
 
-            room.DeviceUIList.RemoveAll((obj) => obj.FileName == deviceUI.FileName);
+            room.DeviceUIList.RemoveAll((obj) => obj.FileName == deviceFile);
             room.Save();
             //鏇存敼鑷姩澶囦唤
             HdlAutoBackupLogic.AddOrEditorFile(room.FileName);
@@ -746,39 +880,6 @@
         #endregion
 
         #region 鈼� 鑾峰彇璁惧_________________________
-
-        /// <summary>
-        /// 鑾峰彇鎵�鏈夋埧闂寸殑鎵�鏈夎澶�
-        /// </summary>
-        public static void GetAllRoomDeviceUIList()
-        {
-            List<string> devicePathList = new List<string>();
-            //鎵�鏈夋埧闂寸殑鎵�鏈夎澶�
-            AllRoomDeviceUIList.Clear();
-            foreach (var room in Shared.Common.Room.Lists)
-            {
-                if(room.IsSharedRoom)
-                {
-                    continue;
-                }
-                if (room.DeviceUIList.Count == 0)
-                {
-                    continue;
-                }
-                foreach (var device in room.DeviceUIList)
-                {
-                    if (device == null || device.CommonDevice == null)
-                    {
-                        continue;
-                    }
-                    if (!devicePathList.Contains(device.FileName))
-                    {
-                        AllRoomDeviceUIList.Add(device);
-                        devicePathList.Add(device.FileName);
-                    }
-                }
-            }
-        }
 
         /// <summary>
         /// 鏍规嵁璁惧鑾峰彇瀹冪殑UI瀵硅薄锛屽鏋滀笉瀛樺湪鍒欐柊寤�
@@ -790,23 +891,102 @@
             return Common.LocalDevice.Current.GetDeviceUI(device);
         }
 
+        /// <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);
+            }
+            return listDevice;
+        }
+
         /// <summary>
-        /// 閲嶆柊鑾峰彇-鎵�鏈夋埧闂寸殑鎵�鏈夎澶囩被鍨�
+        /// 鑾峰彇鎴块棿璁惧绫诲瀷
         /// </summary>
-        public static void GetAllRoomDeviceTypeList()
+        /// <param name="room"></param>
+        /// <returns></returns>
+        public static List<DeviceType> GetdeviceTypes(Room room)
         {
-            AllRoomDeviceTypeList.Clear();
-            foreach (var deviceUI in AllRoomDeviceUIList)
+            List<DeviceType> typeList = new List<DeviceType> { };
+            foreach (var deviceUI in room.DeviceUIList)
             {
                 if (deviceUI == null || deviceUI.CommonDevice == null)
                 {
                     continue;
                 }
-                if (!AllRoomDeviceTypeList.Contains(deviceUI.CommonDevice.Type))
+                if (!typeList.Contains(deviceUI.CommonDevice.Type))
                 {
-                    AllRoomDeviceTypeList.Add(deviceUI.CommonDevice.Type);
+                    typeList.Add(deviceUI.CommonDevice.Type);
                 }
             }
+            return typeList;
+        }
+
+        /// <summary>
+        /// 鑾峰彇璇ョ被鍨嬬殑璁惧
+        /// </summary>
+        /// <param name="room"></param>
+        /// <param name="deviceType"></param>
+        /// <returns></returns>
+        public static List<DeviceUI> GetDeviceUIs(Room room ,DeviceType deviceType)
+        {
+            List<DeviceUI> typeList = new List<DeviceUI> { };
+            foreach (var deviceUI in room.DeviceUIList)
+            {
+                if (deviceUI == null || deviceUI.CommonDevice == null)
+                {
+                    continue;
+                }
+                if(deviceUI.CommonDevice.Type!=deviceType)
+                {
+                    continue;
+                }
+                if (!typeList.Contains(deviceUI))
+                {
+                    typeList.Add(deviceUI);
+                }
+            }
+            return typeList;
+        }
+
+        /// <summary>
+        /// 鑾峰彇璇ユゼ灞傜殑鍦烘櫙
+        /// </summary>
+        /// <param name="floorId"></param>
+        /// <returns></returns>
+        public List<SceneUI> GetSceneUIsByFloorId(string floorId)
+        {
+            var rooms = GetRoomsByFloorId(floorId);
+            if (rooms == null)
+            {
+                return null;
+            }
+            var sceneList = new List<SceneUI> { };
+            foreach (var r in rooms)
+            {
+                if (r.SceneUIList.Count == 0)
+                {
+                    continue;
+                }
+                foreach (var sceneUI in r.SceneUIList)
+                {
+                    if (sceneUI == null)
+                    {
+                        continue;
+                    }
+                    sceneList.Add(sceneUI);
+                }
+            }
+            return sceneList;
         }
 
         #endregion
@@ -823,25 +1003,21 @@
         /// <param name="iconPathType">I鍦烘櫙鑳屾櫙鍥剧墖鏉ユ簮绫诲瀷 鍥剧墖鏉ユ簮 0--鏈湴鍥惧簱 1--鎷嶇収 2--绯荤粺鍥惧簱 榛樿0</param>
         public async System.Threading.Tasks.Task<int> AddScene(string sceneName, string sceneIconPath, List<ZigBee.Device.Scene.AddSceneMemberData> commons, int iconPathType = 0)
         {
-            if (AllRoomSceneUIList.Find(s => s.Name == sceneName) != null)
+            var scenes = GetSceneUIsByFloorId(FloorId);
+            if(scenes!=null && scenes.Count>0)
             {
-                return -1;
+                if (scenes.Find(s => s.Name == sceneName) != null)
+                {
+                    return -1;
+                }
             }
+
             var getSceneIdAllData = await ZigBee.Device.Scene.GetSceneNewIdAsync(sceneName);
             if (getSceneIdAllData == null || getSceneIdAllData.getSceneIdData == null)
             {
                 return 0;
             }
             var getSceneIdData = getSceneIdAllData.getSceneIdData;
-            //寰幆鐩稿悓鎶ラ敊
-            foreach (var tempSceneUI in AllRoomSceneUIList)
-            {
-                if (tempSceneUI.Id == getSceneIdAllData.getSceneIdData.NewScenesId)
-                {
-                    //鍦烘櫙宸插瓨鍦�
-                    return -1;
-                }
-            }
 
             bool result = true;
             foreach (var common in commons)
@@ -849,12 +1025,13 @@
                 //娣诲姞鏂版垚鍛�
                 var addSceneMemberData = new ZigBee.Device.Scene.AddSceneMemberData
                 {
-                    DeviceAddr = common.DeviceAddr,
                     Type = common.Type,
+                    DeviceAddr = common.DeviceAddr,
                     Epoint = common.Epoint,
                     ScenesId = getSceneIdData.NewScenesId,
                     TaskList = common.TaskList,
                     DelayTime = common.DelayTime,
+                    MemberNumber=common.MemberNumber,
                     ElseScenesId = common.ElseScenesId
                 };
                 //common.ScenesId = getSceneIdData.NewScenesId;
@@ -904,17 +1081,30 @@
         /// <param name="scene">Scene.</param>
         public void AddScene(SceneUI scene)
         {
-            var sceneUI = new SceneUI
-            {
-                Name = scene.Name,
-                Id = scene.Id,
-                IconPath = scene.IconPath,
-                IconPathType = scene.IconPathType,
-                AddSceneMemberDataList = scene.AddSceneMemberDataList
-            };
-            SceneUIList.Add(sceneUI);
-            SceneUIFilePathList.Add(sceneUI.FileName);
-            sceneUI.Save();
+            //var sceneUI = new SceneUI
+            //{
+            //    Name = scene.Name,
+            //    Id = scene.Id,
+            //    IconPath = scene.IconPath,
+            //    IconPathType = scene.IconPathType,
+            //    AddSceneMemberDataList = scene.AddSceneMemberDataList
+            //};
+            SceneUIList.Add(scene);
+            SceneUIFilePathList.Add(scene.FileName);
+            scene.Save();
+            Save();
+        }
+
+        /// <summary>
+        /// 鍒犻櫎鍦烘櫙
+        /// </summary>
+        /// <param name="scene"></param>
+        public void DeleteScene(SceneUI scene)
+        {
+            //scene.IsCollected = false;
+            scene.Save();
+            SceneUIList.Remove(scene);
+            SceneUIFilePathList.Remove(scene.FileName);
             Save();
         }
 
@@ -986,7 +1176,8 @@
                     ScenesId = sceneUI.Id,
                     TaskList = addCommon.TaskList,
                     DelayTime = addCommon.DelayTime,
-                    ElseScenesId = addCommon.ElseScenesId
+                    ElseScenesId = addCommon.ElseScenesId,
+                    MemberNumber=addCommon.MemberNumber
                 };
                 //娣诲姞鏂版垚鍛� 杩斿洖缁撴灉
                 var addSceneMemberResponseAllData = await ZigBee.Device.Scene.AddSceneMemberAsync(addSceneMemberData);
@@ -1031,7 +1222,6 @@
             Save();
             Global.DeleteFilebyHomeId(sceneUI.FileName);
             HdlAutoBackupLogic.DeleteFile(sceneUI.FileName);
-            HdlAutoBackupLogic.AddOrEditorFile(FileName);
         }
 
         #endregion
@@ -1057,7 +1247,21 @@
             }
             return null;
         }
-
+        /// <summary>
+        /// 鑾峰彇璇ユゼ灞傛墍鏈夊満鏅�
+        /// </summary>
+        /// <param name="floorId"></param>
+        /// <returns></returns>
+        public List<SceneUI> GetSameFloorScenes(string floorId)
+        {
+            List<SceneUI> sceneUIs = new List<SceneUI> { };
+            var rooms= CurrentRoom.GetRoomsByFloorId(floorId);
+            foreach(var r in rooms)
+            {
+                sceneUIs.AddRange(r.SceneUIList);
+            }
+            return sceneUIs;
+        }
         #endregion
 
         #region 鈼� 鍒锋柊鍦烘櫙_________________________
@@ -1282,6 +1486,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;
@@ -1291,32 +1497,5 @@
 
         #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