1
wxr
2023-03-31 7e42cc13a14b7de31c9f5d5c61cdf24f3246335d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json.Linq;
using Shared.SimpleControl;
 
namespace Shared
{
    [System.Serializable]
    /// <summary>
    /// 房间对象
    /// </summary>
    public class Room 
    {
        public static string FavoriteRoom = "FavoriteRoom";
 
        /// <summary>
        /// 房间里面灯光设备的延迟时间
        /// </summary>
        public Dictionary<string, byte> DelayTime = new Dictionary<string, byte> ();
 
        public static void UpdateMemorry (string roomFilePath)
        {
            GetRoomByFilePath (roomFilePath);
        }
 
        // 房间命名规则 typeof (Room).Name + "_" + etNameBox.Text.Trim ();
        /// <summary>
        /// 根据房间路径恢复房间对象
        /// </summary>
        /// <returns>The by file path.</returns>
        /// <param name="roomFilePath">Room file path.</param>
        public static Room GetRoomByFilePath (string roomFilePath)
        {
            try {
                var sdf = IO.FileUtils.ReadFile (roomFilePath);
                var nowRoom = Newtonsoft.Json.JsonConvert.DeserializeObject<Room> (System.Text.Encoding.UTF8.GetString (sdf));
 
                if (null == nowRoom) {
                    System.Console.WriteLine ("房间文件路径不对,文件路径为:" + roomFilePath);
                    return null;
                }
 
                var beforeRoom = Lists.Find ((obj) => obj.Name == nowRoom.Name);
                if (beforeRoom != null) {
                   List<Common> tempCommomList = new List<Common> ();
                    tempCommomList.AddRange (beforeRoom.DeviceList);
                    beforeRoom.DeviceList.Clear ();
                    foreach (var filePath in beforeRoom.DeviceFilePathList) {
                        var jsonInfo = CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (filePath));
                        var tempCommon = Newtonsoft.Json.JsonConvert.DeserializeObject<Common> (jsonInfo);
                        if (tempCommon != null) {
                            Common delCommon = tempCommomList.Find ((obj) => obj.Type == tempCommon.Type && obj.SubnetID == tempCommon.SubnetID && obj.DeviceID == tempCommon.DeviceID && obj.LoopID == tempCommon.LoopID);
                            if (delCommon != null) {
                                beforeRoom.DeviceList.Add (delCommon);
                            } else {
                                addDevice (beforeRoom, filePath);
                            }
                        }
                    }
 
                    beforeRoom.SceneFilePathList.Clear ();
                    foreach (var filePath in nowRoom.SceneFilePathList) {
                        beforeRoom.SceneFilePathList.Add (filePath);
                    }
 
                    return beforeRoom;
                }
 
                nowRoom.DeviceList.Clear ();
                foreach (string deviceFilePath in nowRoom.DeviceFilePathList) {
                    addDevice (nowRoom, deviceFilePath);
                }
 
                for (int i = UserConfig.Instance.HideDeviceTypes.Count - 1; i >= 0; i--) {
                    var hideType = UserConfig.Instance.HideDeviceTypes [i];
                    var devices = nowRoom.DeviceList.Find ((obj) => {
                        return obj.DeviceTextID == hideType;
                    });
                    if (devices != null) {
                        UserConfig.Instance.HideDeviceTypes.Remove (hideType);
                        UserConfig.Instance.SaveUserConfig ();
                        break;
                    }
                }
                return nowRoom;
            } catch {
                return null;
            }
        }
 
        static void addDevice (Room room, string deviceFilePath)
        {
            if (deviceFilePath.Split ('_').Length < 2) {
                return;
            }
            var jsonInfo = CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath));
            var jsonInfoCommon = Newtonsoft.Json.JsonConvert.DeserializeObject<Common> (jsonInfo);
            if (null == jsonInfoCommon) {
                //当前对象数据无效
                return;
            }
            var deviceType = deviceFilePath.Split ('_') [1];
 
            //判断设备,使其在用户界面数量和从设备进入到界面上有相关的设备显示
            if (deviceType == DeviceType.LightDimming.ToString ()) {
                var common = Newtonsoft.Json.JsonConvert.DeserializeObject<LightDimming> (jsonInfo);
                common.CurrentBrightness = 0;
                string keyString = common.CommonLoopID;
                var delayTime = room.DelayTime.ContainsKey (keyString + "Open");
                if (delayTime) {
                    common.CustomDelayTimeOpen = room.DelayTime [keyString + "Open"];
                    common.CustomDelayTimeClose = room.DelayTime [keyString + "Close"];
                } else {
                    common.CustomDelayTimeOpen = 0;
                    common.CustomDelayTimeClose = 0;
                }
                room.DeviceList.Add (common);
            } else if (deviceType == DeviceType.LightMixDimming.ToString ()) {
                var common = Newtonsoft.Json.JsonConvert.DeserializeObject<LightMixDimming> (jsonInfo);
                common.CurrentBrightness = 0;
                string keyString = common.CommonLoopID;
                var delayTime = room.DelayTime.ContainsKey (keyString + "Open");
                if (delayTime) {
                    common.CustomDelayTimeOpen = room.DelayTime [keyString + "Open"];
                    common.CustomDelayTimeClose = room.DelayTime [keyString + "Close"];
                } else {
                    common.CustomDelayTimeOpen = 0;
                    common.CustomDelayTimeClose = 0;
                }
                room.DeviceList.Add (common);
            } else if (deviceType == DeviceType.LightDALI.ToString ()) {
                var common = Newtonsoft.Json.JsonConvert.DeserializeObject<LightDALI> (jsonInfo);
                common.CurrentBrightness = 0;
                string keyString = common.CommonLoopID;
                var delayTime = room.DelayTime.ContainsKey (keyString + "Open");
                if (delayTime) {
                    common.CustomDelayTimeOpen = room.DelayTime [keyString + "Open"];
                    common.CustomDelayTimeClose = room.DelayTime [keyString + "Close"];
                } else {
                    common.CustomDelayTimeOpen = 0;
                    common.CustomDelayTimeClose = 0;
                }
                room.DeviceList.Add (common);
            }  else if (deviceType == DeviceType.LightRGB.ToString ()) {
                var common = Newtonsoft.Json.JsonConvert.DeserializeObject<LightLogic> (jsonInfo);
                common.CurrentBrightness = 0;
                string keyString = common.SubnetID.ToString () + "_" + common.DeviceID.ToString () + "_" + common.LoopID.ToString ();
                var delayTime = room.DelayTime.ContainsKey (keyString + "Open");
                if (delayTime) {
                    common.CustomDelayTimeOpen = room.DelayTime [keyString + "Open"];
                    common.CustomDelayTimeClose = room.DelayTime [keyString + "Close"];
                } else {
                    common.CustomDelayTimeOpen = 0;
                    common.CustomDelayTimeClose = 0;
                }
                room.DeviceList.Add (common);
            } else if (deviceType == DeviceType.LightSwitch.ToString ()){
                var common = Newtonsoft.Json.JsonConvert.DeserializeObject<LightSwitch> (jsonInfo);
                room.DeviceList.Add (common);
            } else if (deviceType == DeviceType.LightMixSwitch.ToString () ){
                var common = Newtonsoft.Json.JsonConvert.DeserializeObject<LightMixSwitch> (jsonInfo);
                room.DeviceList.Add (common);
            } else if ( deviceType == DeviceType.LightEnergySocket.ToString ()) {
                var common = Newtonsoft.Json.JsonConvert.DeserializeObject<LightEnergySocket> (jsonInfo);
                room.DeviceList.Add (common);
            } else if (deviceType == DeviceType.LightEnergySwitch.ToString ()) {
                var common = Newtonsoft.Json.JsonConvert.DeserializeObject<LightEnergySwitch> (jsonInfo);
                room.DeviceList.Add (common);
            } else if (deviceType == DeviceType.CurtainModel.ToString ()) {
                room.DeviceList.Add (Newtonsoft.Json.JsonConvert.DeserializeObject<CurtainModel> (jsonInfo));
            } else if (deviceType == DeviceType.CurtainTrietex.ToString ()) {
                room.DeviceList.Add (Newtonsoft.Json.JsonConvert.DeserializeObject<CurtainTrietex> (jsonInfo));
            } else if (deviceType == DeviceType.CurtainRoller.ToString ()) {
                room.DeviceList.Add (Newtonsoft.Json.JsonConvert.DeserializeObject<CurtainRoller> (jsonInfo));
            } else if (deviceType == DeviceType.MusicModel.ToString ()) {
                room.DeviceList.Add (Newtonsoft.Json.JsonConvert.DeserializeObject<MusicModel> (jsonInfo));
            } else if (deviceType == DeviceType.HVAC.ToString ()) {
                room.DeviceList.Add (Newtonsoft.Json.JsonConvert.DeserializeObject<HVAC> (jsonInfo));
            } else if (deviceType == DeviceType.ACPanel.ToString ()) {
                room.DeviceList.Add (Newtonsoft.Json.JsonConvert.DeserializeObject<ACPanel> (jsonInfo));
            } else if (deviceType == DeviceType.ACInfrared.ToString ()) {
                room.DeviceList.Add (Newtonsoft.Json.JsonConvert.DeserializeObject<ACInfrared> (jsonInfo));
            } else if (deviceType == DeviceType.FoolHeat.ToString ()) {
                room.DeviceList.Add (Newtonsoft.Json.JsonConvert.DeserializeObject<FoolHeat> (jsonInfo));
            } else if (deviceType == DeviceType.FoolHeatPanel.ToString ()) {
                room.DeviceList.Add (Newtonsoft.Json.JsonConvert.DeserializeObject<FoolHeatPanel> (jsonInfo));
            } else if (deviceType == DeviceType.DryContact.ToString ()) {
                room.DeviceList.Add (Newtonsoft.Json.JsonConvert.DeserializeObject<DryContact> (jsonInfo));
            } else if (deviceType == DeviceType.Scene.ToString ()) {
                room.DeviceList.Add (Newtonsoft.Json.JsonConvert.DeserializeObject<Scene> (jsonInfo));
            } else if (deviceType == DeviceType.InfraredMode.ToString ()) {
                room.DeviceList.Add (Newtonsoft.Json.JsonConvert.DeserializeObject<InfraredMode> (jsonInfo));
            } else if (deviceType == DeviceType.FanModule.ToString ()) {
                room.DeviceList.Add (Newtonsoft.Json.JsonConvert.DeserializeObject<FanModule> (jsonInfo));
            } else if (deviceType == DeviceType.DoorLock.ToString ()) {
                room.DeviceList.Add (Newtonsoft.Json.JsonConvert.DeserializeObject<DoorLock> (jsonInfo));//门锁111
            } else if (deviceType == DeviceType.UniversalDevice.ToString ()) {
                room.DeviceList.Add (Newtonsoft.Json.JsonConvert.DeserializeObject<UniversalDevice> (jsonInfo));
            } else if (deviceType == DeviceType.SensorCO2.ToString ()) {
                room.DeviceList.Add (Newtonsoft.Json.JsonConvert.DeserializeObject<SensorCO2> (jsonInfo));
            } else if (deviceType == DeviceType.SensorTVOC.ToString ()) {
                room.DeviceList.Add (Newtonsoft.Json.JsonConvert.DeserializeObject<SensorTVOC> (jsonInfo));
            } else if (deviceType == DeviceType.SensorPM25.ToString ()) { 
                room.DeviceList.Add (Newtonsoft.Json.JsonConvert.DeserializeObject<SensorPM25> (jsonInfo));
            } else if (deviceType == DeviceType.SensorTemperature.ToString ()) { 
                room.DeviceList.Add (Newtonsoft.Json.JsonConvert.DeserializeObject<SensorTemperature> (jsonInfo));
            } else if (deviceType == DeviceType.SensorHumidity.ToString ()) {
                room.DeviceList.Add (Newtonsoft.Json.JsonConvert.DeserializeObject<SensorHumidity> (jsonInfo));
            } else if (deviceType == DeviceType.FreshAir.ToString ()) {
                room.DeviceList.Add (Newtonsoft.Json.JsonConvert.DeserializeObject<FreshAir> (jsonInfo));
            } 
 
            for (int i = UserConfig.Instance.HideDeviceTypes.Count - 1; i >= 0; i--) {
                var hideType = UserConfig.Instance.HideDeviceTypes [i];
                var devices = room.DeviceList.Find ((obj) => {
                    return obj.DeviceTextID == hideType;
                });
                if (devices != null) {
                    UserConfig.Instance.HideDeviceTypes.Remove (hideType);
                    UserConfig.Instance.SaveUserConfig ();
                    break;
                }
            }
        }
 
        /// <summary>
        /// 房间名
        /// </summary>
        public string Name { get; set; }
 
        public string RoomFilePath {
            get {
                if (string.IsNullOrEmpty (Name)) { return "FavoriteRoom"; } else {
                    return "Room_" + Name;
                }
            }
        }
 
        /// <summary>
        /// 不选择到房间时候的背景图
        /// </summary>
        public string UnSelectedBackgroundImage {
            get;
            set;
        }
 
        /// <summary>
        /// 选择到房间的时候背景图
        /// </summary>
        public string SelectedBackgroundImage {
            get;
            set;
        }
 
        /// <summary>
        /// 不选择到房间下拉列表时候的背景图
        /// </summary>
        public string UnSelectedListBackgroundImage {
            get;
            set;
        }
 
        /// <summary>
        /// 选择到房间的下拉列表时候背景图
        /// </summary>
        public string SelectedListBackgroundImage {
            get;
            set;
        }
 
        /// <summary>
        /// 图标
        /// </summary>
        public string IconPath = "DefaultRoomIcon.png";
        /// <summary>
        /// 房间背景
        /// </summary>
        public string BackGroundImage = "Room/r1.png";
        /// <summary>
        /// 楼层
        /// </summary>
        public string Floor = "ALL ROOMS";
 
        /// <summary>
        /// 当前选择的房间
        /// </summary>
        public static Room CurrentRoom;
 
        [Newtonsoft.Json.JsonIgnore]
        /// <summary>
        /// 房间里所有的视图类型
        /// </summary>
        public List<Common> DeviceList = new List<Common> { };
 
        /// <summary>
        ///设备文件路径列表
        /// </summary>
        public readonly List<string> DeviceFilePathList = new List<string> ();
 
        /// <summary>
        /// 场景文件名列表
        /// </summary>
        public readonly List<string> SceneFilePathList = new List<string> ();
 
 
        /// <summary>
        /// 房间列表的文件名称 
        /// </summary>
        static string roomListFilePath = "RoomList";
 
        /// <summary>
        /// 所有的房间信息
        /// </summary>
        public static System.Collections.Generic.List<Room> Lists = new System.Collections.Generic.List<Room> ();
 
        /// <summary>
        /// 删除房间
        /// </summary>
        public static void Remove (string roomFilePath)
        {
            var room = GetRoomByFilePath (roomFilePath);
 
            if (null == room) {
                return;
            }
            var roomFilePathList = Newtonsoft.Json.JsonConvert.DeserializeObject<System.Collections.Generic.List<string>> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (roomListFilePath)));
 
            roomFilePathList.Remove (roomFilePath);
            IO.FileUtils.WriteFileByBytes (roomListFilePath, System.Text.Encoding.UTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (roomFilePathList)));
 
            IO.FileUtils.DeleteFile (roomFilePath);
            //删除和房间相关的场景所有数据
            foreach (var sceneFilePath in room.SceneFilePathList) {
                IO.FileUtils.DeleteFile (sceneFilePath);
            }
            Room.Lists.Remove (room);
        }
        /// <summary>
        /// 增加房间
        /// </summary>
        public void Add (string roomFilePath)
        {
            if (string.IsNullOrEmpty (roomFilePath) || IO.FileUtils.Exists (roomFilePath)) {
                return;
            }
            var roomFilePathList = Newtonsoft.Json.JsonConvert.DeserializeObject<System.Collections.Generic.List<string>> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (roomListFilePath)));
            if(roomFilePathList == null)
            {
                roomFilePathList = new List<string> ();
            }
            roomFilePathList.Add (roomFilePath);
 
            //var sssddsa = IO.FileUtils.ReadFiles ().FindAll ((obj) => obj.Contains ("Room_"));
            //foreach (var sd in sssddsa) {
            //    roomFilePathList.Add (sd);
            //}
 
            //保存房间列表
            IO.FileUtils.WriteFileByBytes (roomListFilePath, System.Text.Encoding.UTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (roomFilePathList)));
            Save (roomFilePath);
        }
 
        /// <summary>
        /// 保存
        /// </summary>
        public void Save (string roomFilePath)
        {
            if (string.IsNullOrEmpty (roomFilePath)) {
                return;
            }
 
            var list = DeviceList;
            //不需要保存当前设备
            DeviceList = new List<Common> ();
            //保存房间信息
            IO.FileUtils.WriteFileByBytes (roomFilePath, System.Text.Encoding.UTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (this)));
            DeviceList = list;
 
            for (int i = UserConfig.Instance.HideDeviceTypes.Count - 1; i >= 0; i--) {
                var hideType = UserConfig.Instance.HideDeviceTypes [i];
                    var devices = DeviceList.Find ((obj) => {
                        return obj.DeviceTextID == hideType;
                    });
                    if (devices != null) {
                        UserConfig.Instance.HideDeviceTypes.Remove (hideType);
                        UserConfig.Instance.SaveUserConfig ();
                        break;
                    }
            }
        }
        /// <summary>
        /// 更新房间名
        /// </summary>
        /// <param name="oldRoomFilePath">Old room file path.</param>
        /// <param name="newRoomFilePath">New room file path.</param>
        public void ReName (string oldRoomFilePath, string newRoomFilePath)
        {
            if (string.IsNullOrEmpty (newRoomFilePath)) {
                return;
            }
            //场景名已经更改
            if (oldRoomFilePath != newRoomFilePath && 2 <= oldRoomFilePath.Split ('_').Length) {
 
                var roomFilePathList = Newtonsoft.Json.JsonConvert.DeserializeObject<System.Collections.Generic.List<string>> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (roomListFilePath))); ;
                for (int i = 0; i < roomFilePathList.Count; i++) {
                    var roomFilePath = roomFilePathList [i];
                    if (roomFilePath == oldRoomFilePath) {
                        roomFilePathList [i] = newRoomFilePath;
                        break;
                    }
                }
                //保存房间列表
                IO.FileUtils.WriteFileByBytes (roomListFilePath, System.Text.Encoding.UTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (roomFilePathList)));
                //这里还需要更改场景的引用 
                var oldRoomName = oldRoomFilePath.Split ('_') [1];
                IO.FileUtils.DeleteFile (oldRoomFilePath);
                for (int i = 0; i < SceneFilePathList.Count; i++) {
                    string oldSceneFilePath = SceneFilePathList [i];
                    string newfile = oldSceneFilePath.Replace ("RoomScene_" + oldRoomName + "_", "RoomScene_" + Name + "_");
                    SceneFilePathList [i] = newfile;
                    IO.FileUtils.ReNameFile (oldSceneFilePath, newfile);
                }
            }
 
            Save (newRoomFilePath);
        }
 
        /// <summary>
        /// 所有的房间列表路径
        /// </summary>
        /// <value>The room file path list.</value>
        public static System.Collections.Generic.List<string> FilePathList {
            get {
                var roomBytes = IO.FileUtils.ReadFile (roomListFilePath);
                string roombyteString = System.Text.Encoding.UTF8.GetString (roomBytes);
                var ddds = Newtonsoft.Json.JsonConvert.DeserializeObject<System.Collections.Generic.List<string>> (roombyteString);
                if (ddds == null)
                    ddds = new List<string> ();
                if (!ddds.Contains (FavoriteRoom)) {
                    ddds.Add (FavoriteRoom);
                    if (!IO.FileUtils.Exists (FavoriteRoom)) {
                        //默认添加对应的房间
                        new Room () { Name = "" }.Save (FavoriteRoom);
                    }
                    IO.FileUtils.WriteFileByBytes (roomListFilePath, System.Text.Encoding.UTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (ddds)));
                }
                return ddds;
            }
        }
 
        /// <summary>
        /// 从文件中全部读取所有的房间数据到内存
        /// </summary>
        public static void InitAllRoom ()
        {
            Lists.Clear ();
            if (null == Newtonsoft.Json.JsonConvert.DeserializeObject<System.Collections.Generic.List<string>> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (roomListFilePath)))) {
                //初始化房间列表
                Shared.IO.FileUtils.WriteFileByBytes (roomListFilePath, System.Text.Encoding.UTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (new System.Collections.Generic.List<string> ())));
            }
            var roomFilePathList = Newtonsoft.Json.JsonConvert.DeserializeObject<System.Collections.Generic.List<string>> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (roomListFilePath)));
            if (!roomFilePathList.Contains (FavoriteRoom)) {
                roomFilePathList.Add (FavoriteRoom);
                if (!IO.FileUtils.Exists (FavoriteRoom)) {
                    //默认添加对应的房间
                    new Room () { Name = "" }.Save (FavoriteRoom);
                }
 
                IO.FileUtils.WriteFileByBytes (roomListFilePath, System.Text.Encoding.UTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (roomFilePathList)));
 
            }
 
            foreach (var roomFilePath in roomFilePathList) {
                var room = GetRoomByFilePath (roomFilePath);
                if (null != room) {
                    Lists.Add (room);
                }
            }
 
            for (int i = UserConfig.Instance.HideDeviceTypes.Count - 1; i >= 0; i--) {
                var hideType = UserConfig.Instance.HideDeviceTypes [i];
                foreach (var room in Room.Lists) {
                    var devices = room.DeviceList.Find ((obj) => {
                        return obj.DeviceTextID == hideType;
                    });
                    if (devices != null) {
                        UserConfig.Instance.HideDeviceTypes.Remove (hideType);
                        UserConfig.Instance.SaveUserConfig ();
                        break;
                    }
                }
            }
        }
 
        public void SaveLightScene (string roomFilePath, string SceneRemark, Scene scene)
        {
            IO.FileUtils.WriteFileByBytes (roomFilePath + "_" + SceneRemark, Encoding.UTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (scene)));
            IO.FileUtils.WriteFileByBytes (roomFilePath, System.Text.Encoding.UTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (this)));
        }
 
        /// <summary>
        /// 灯光场景列表
        /// </summary>
        public List<string> LightScenePathList = new List<string> ();
    }
}