From fdf2472a13873ab3570e3c82de50896b8f5ac1cb Mon Sep 17 00:00:00 2001 From: WJC <wjc@hdlchina.com.cn> Date: 星期五, 18 十月 2019 17:34:53 +0800 Subject: [PATCH] 2019-10-18-2 --- ZigbeeApp/Shared/Phone/Device/Logic/LogicIfon.cs | 33 ZigbeeApp/.vs/GateWay/xs/UserPrefs.xml | 44 ZigbeeApp/.vs/GateWay/xs/sqlite3/storage.ide-shm | 0 ZigbeeApp/Shared/Phone/Device/Logic/DeviceStateCondition.cs | 70 + ZigbeeApp/Shared/Phone/Device/Logic/LogicCommunalPage.cs | 20 ZigbeeApp/.vs/GateWay/xs/sqlite3/storage.ide | 0 .DS_Store | 0 ZigbeeApp/GateWay.Ios/Resources/Phone/.DS_Store | 0 ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs | 6 ZigbeeApp/Shared/Common/Room.cs | 2461 ++++++++++++++++++++++++++-------------------------- ZigbeeApp/Shared/Phone/Device/Category/Category.cs | 101 +- ZigbeeApp/.vs/GateWay/xs/sqlite3/storage.ide-wal | 0 12 files changed, 1,422 insertions(+), 1,313 deletions(-) diff --git a/.DS_Store b/.DS_Store index 1b560ee..7944d79 100644 --- a/.DS_Store +++ b/.DS_Store Binary files differ diff --git a/ZigbeeApp/.vs/GateWay/xs/UserPrefs.xml b/ZigbeeApp/.vs/GateWay/xs/UserPrefs.xml index 1373f9b..6c87c53 100644 --- a/ZigbeeApp/.vs/GateWay/xs/UserPrefs.xml +++ b/ZigbeeApp/.vs/GateWay/xs/UserPrefs.xml @@ -2,32 +2,42 @@ <MonoDevelop.Ide.ItemProperties.GateWay.Droid PreferredExecutionTarget="Android.SelectDevice" /> <MonoDevelop.Ide.ItemProperties.GateWay.Ios automaticSigning="False" PreferredExecutionTarget="MonoDevelop.IPhone.IPhoneDeviceTarget.913cb77b0eef11c9119c61a02bc00fec01bf67d6" /> <MonoDevelop.Ide.ItemProperties.ShardLib PreferredExecutionTarget="Android.M7BBB18B19152766" /> - <MonoDevelop.Ide.Workbench ActiveDocument="Shared/Phone/Device/Logic/Send.cs"> + <MonoDevelop.Ide.Workbench ActiveDocument="Shared/Phone/ZigBee/Device/CommonDevice.cs"> <Files> - <File FileName="Shared/Phone/Device/Logic/DeviceStateCondition.cs" Line="243" Column="42" /> - <File FileName="Shared/Phone/Device/Logic/MemberList.cs" /> - <File FileName="Shared/Phone/ZigBee/Device/DeviceType.cs" /> - <File FileName="Shared/Phone/ZigBee/Device/TemperatureSensor.cs" /> - <File FileName="Shared/Phone/Device/Logic/LogicDevicePage.cs" Line="230" Column="57" /> - <File FileName="Shared/Phone/Device/Category/Category.cs" /> - <File FileName="Shared/Phone/Device/Logic/TemplateDeviceCondition.cs" Line="225" Column="57" /> - <File FileName="Shared/Phone/Device/Logic/TemplateDeviceAction.cs" Line="230" Column="57" /> - <File FileName="Shared/Phone/Device/Logic/Send.cs" Line="689" Column="1" /> + <File FileName="Shared/Phone/Device/Logic/LogicCommunalPage.cs" Line="250" Column="59" /> + <File FileName="Shared/Phone/Device/Logic/DeviceStateCondition.cs" Line="1509" Column="45" /> + <File FileName="Shared/Phone/ZigBee/Device/TemperatureSensor.cs" Line="11" Column="29" /> + <File FileName="Shared/Phone/Device/Category/Category.cs" Line="2601" Column="26" /> + <File FileName="../../../Downloads/ZigbeeApp-6/Shared/Phone/Device/Category/Category.cs" Line="9" Column="39" /> + <File FileName="Shared/Phone/Device/Logic/Send.cs" Line="1" Column="1" /> + <File FileName="Shared/Common/Room.cs" Line="1" Column="1" /> + <File FileName="GateWay.Ios/Main.cs" Line="14" Column="1" /> + <File FileName="GateWay.Ios/Main.cs" Line="14" Column="1" /> + <File FileName="Shared/Phone/Device/Logic/LogicIfon.cs" Line="22" Column="37" /> + <File FileName="Shared/Phone/ZigBee/Device/CommonDevice.cs" Line="294" Column="27" /> </Files> <Pads> <Pad Id="ProjectPad"> <State name="__root__"> <Node name="GateWay" expanded="True"> - <Node name="GateWay.Ios" expanded="True" /> + <Node name="GateWay.Ios" expanded="True"> + <Node name="Resources" expanded="True"> + <Node name="Phone" expanded="True"> + <Node name="ZigeeLogic" expanded="True" /> + </Node> + </Node> + </Node> <Node name="Shared" expanded="True"> + <Node name="Common" expanded="True" /> <Node name="Phone" expanded="True"> <Node name="Device" expanded="True"> - <Node name="Logic" expanded="True"> - <Node name="Send.cs" selected="True" /> - </Node> + <Node name="Category" expanded="True" /> + <Node name="Logic" expanded="True" /> </Node> <Node name="ZigBee" expanded="True"> - <Node name="Device" expanded="True" /> + <Node name="Device" expanded="True"> + <Node name="CommonDevice.cs" selected="True" /> + </Node> </Node> </Node> </Node> @@ -39,9 +49,7 @@ <MonoDevelop.Ide.DebuggingService.PinnedWatches /> <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug|iPhone" /> <MonoDevelop.Ide.DebuggingService.Breakpoints> - <BreakpointStore> - <Breakpoint file="/Users/hdl/Desktop/HomeApp/ZigbeeApp/Shared/Phone/Device/Logic/Send.cs" relfile="Shared/Phone/Device/Logic/Send.cs" line="689" column="1" /> - </BreakpointStore> + <BreakpointStore /> </MonoDevelop.Ide.DebuggingService.Breakpoints> <MultiItemStartupConfigurations /> </Properties> \ No newline at end of file diff --git a/ZigbeeApp/.vs/GateWay/xs/sqlite3/storage.ide b/ZigbeeApp/.vs/GateWay/xs/sqlite3/storage.ide index e459aef..d9582f3 100644 --- a/ZigbeeApp/.vs/GateWay/xs/sqlite3/storage.ide +++ b/ZigbeeApp/.vs/GateWay/xs/sqlite3/storage.ide Binary files differ diff --git a/ZigbeeApp/.vs/GateWay/xs/sqlite3/storage.ide-shm b/ZigbeeApp/.vs/GateWay/xs/sqlite3/storage.ide-shm index 58256e3..5c2e9a3 100644 --- a/ZigbeeApp/.vs/GateWay/xs/sqlite3/storage.ide-shm +++ b/ZigbeeApp/.vs/GateWay/xs/sqlite3/storage.ide-shm Binary files differ diff --git a/ZigbeeApp/.vs/GateWay/xs/sqlite3/storage.ide-wal b/ZigbeeApp/.vs/GateWay/xs/sqlite3/storage.ide-wal index ea573fa..27094e6 100644 --- a/ZigbeeApp/.vs/GateWay/xs/sqlite3/storage.ide-wal +++ b/ZigbeeApp/.vs/GateWay/xs/sqlite3/storage.ide-wal Binary files differ diff --git a/ZigbeeApp/GateWay.Ios/Resources/Phone/.DS_Store b/ZigbeeApp/GateWay.Ios/Resources/Phone/.DS_Store index c99430d..0991416 100644 --- a/ZigbeeApp/GateWay.Ios/Resources/Phone/.DS_Store +++ b/ZigbeeApp/GateWay.Ios/Resources/Phone/.DS_Store Binary files differ diff --git a/ZigbeeApp/Shared/Common/Room.cs b/ZigbeeApp/Shared/Common/Room.cs index 69d46f4..c168e50 100644 --- a/ZigbeeApp/Shared/Common/Room.cs +++ b/ZigbeeApp/Shared/Common/Room.cs @@ -7,1336 +7,1335 @@ namespace Shared.Common { - /// <summary> - /// 鎴块棿瀵硅薄 - /// </summary> - [System.Serializable] - public class Room - { - #region 鈼� 鍙橀噺____________________________ + /// <summary> + /// 鎴块棿瀵硅薄 + /// </summary> + [System.Serializable] + public class Room + { + #region 鈼� 鍙橀噺____________________________ - /// <summary> - /// 鎴块棿鏂囦欢 - /// </summary> - /// <value>The name of the file.</value> - [Newtonsoft.Json.JsonIgnore] - public string FileName - { - get - { - return $"Room_{Id}.json"; - } - } - /// <summary> - /// 鎴块棿id--浣跨敤guid - /// Guid.NewGuid().ToString() - /// </summary> - public string Id = Guid.NewGuid().ToString(); - /// <summary> - /// 妤煎眰Id - /// 鏂板鏃朵娇鐢℅uid - /// </summary> - public string FloorId = "Floor1"; - /// <summary> - /// 妤煎眰鍚嶇О - /// </summary> - public string FloorName - { - get - { - return GetFloorNameById(FloorId); - } - } - /// <summary> - /// 鎴块棿鍚� - /// </summary> - public string Name = string.Empty; + /// <summary> + /// 鎴块棿鏂囦欢 + /// </summary> + /// <value>The name of the file.</value> + [Newtonsoft.Json.JsonIgnore] + public string FileName + { + get + { + return $"Room_{Id}.json"; + } + } + /// <summary> + /// 鎴块棿id--浣跨敤guid + /// Guid.NewGuid().ToString() + /// </summary> + public string Id = Guid.NewGuid().ToString(); + /// <summary> + /// 妤煎眰Id + /// 鏂板鏃朵娇鐢℅uid + /// </summary> + public string FloorId = "Floor1"; + /// <summary> + /// 妤煎眰鍚嶇О + /// </summary> + public string FloorName + { + get + { + return GetFloorNameById(FloorId); + } + } + /// <summary> + /// 鎴块棿鍚� + /// </summary> + public string Name = string.Empty; - /// <summary> - /// 鎴块棿鑳屾櫙鍥� - /// </summary> - public string BackgroundImage = string.Empty; + /// <summary> + /// 鎴块棿鑳屾櫙鍥� + /// </summary> + public string BackgroundImage = string.Empty; - /// <summary> - /// 鍥剧墖鏉ユ簮 0--鏈湴鍥惧簱 1--鎷嶇収 2--绯荤粺鍥惧簱 - /// </summary> - public int BackgroundImageType = 0; + /// <summary> + /// 鍥剧墖鏉ユ簮 0--鏈湴鍥惧簱 1--鎷嶇収 2--绯荤粺鍥惧簱 + /// </summary> + public int BackgroundImageType = 0; - /// <summary> - /// 妤煎眰--澶囩敤 - /// </summary> - public Dictionary<string, string> FloorList = new Dictionary<string, string> { }; + /// <summary> + /// 妤煎眰--澶囩敤 + /// </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> + public string TemperatrueDevice = string.Empty; + /// <summary> + /// 婀垮害浼犳劅鍣�(璁惧涓婚敭) + /// </summary> + public string HumidityDevice = string.Empty; - /// <summary> - /// 褰撳墠閫夋嫨鐨勬埧闂� - /// </summary> - public static Room CurrentRoom; + /// <summary> + /// 褰撳墠閫夋嫨鐨勬埧闂� + /// </summary> + public static Room CurrentRoom; - /// <summary> - /// 鎴块棿閲屾墍鏈夌殑璁惧鍒楄〃 - /// </summary> - [Newtonsoft.Json.JsonIgnore] - public List<DeviceUI> DeviceUIList = new List<DeviceUI> { }; - /// <summary> - ///璁惧鏂囦欢璺緞鍒楄〃 - /// </summary> - public readonly List<string> DeviceUIFilePathList = new List<string>(); + /// <summary> + /// 鎴块棿閲屾墍鏈夌殑璁惧鍒楄〃 + /// </summary> + [Newtonsoft.Json.JsonIgnore] + public List<DeviceUI> DeviceUIList = new List<DeviceUI> { }; + /// <summary> + ///璁惧鏂囦欢璺緞鍒楄〃 + /// </summary> + public readonly List<string> DeviceUIFilePathList = new List<string>(); - /// <summary> - /// 鍠滅埍鎴块棿id - /// </summary> - public const string LoveRoomId= "Favorite"; + /// <summary> + /// 鍠滅埍鎴块棿id + /// </summary> + public const string LoveRoomId = "Favorite"; - /// <summary> - /// 鏄惁鏄粯璁ゅ枩鐖辨埧闂� - /// </summary> - /// <value><c>true</c> if is love; otherwise, <c>false</c>.</value> - [Newtonsoft.Json.JsonIgnore] - public bool IsLove - { - get - { - return Id == LoveRoomId; - } - } + /// <summary> + /// 鏄惁鏄粯璁ゅ枩鐖辨埧闂� + /// </summary> + /// <value><c>true</c> if is love; otherwise, <c>false</c>.</value> + [Newtonsoft.Json.JsonIgnore] + public bool IsLove + { + get + { + return Id == LoveRoomId; + } + } - /// <summary> - /// 鏄惁鏄垎浜繃鏉ョ殑鎴块棿 - /// 娉細鍒嗕韩杩囨潵鐨勬埧闂翠笉鑳藉垹闄わ紝涓嶈兘缂栬緫璇ユ埧闂达紝涓嶈兘瀵硅澶囷紙鍔熻兘锛夈�佸満鏅繘琛屽鍒犳敼 - /// </summary> - public bool IsSharedRoom = false; + /// <summary> + /// 鏄惁鏄垎浜繃鏉ョ殑鎴块棿 + /// 娉細鍒嗕韩杩囨潵鐨勬埧闂翠笉鑳藉垹闄わ紝涓嶈兘缂栬緫璇ユ埧闂达紝涓嶈兘瀵硅澶囷紙鍔熻兘锛夈�佸満鏅繘琛屽鍒犳敼 + /// </summary> + public bool IsSharedRoom = false; - /// <summary> - /// 鏄惁鍙互鍒锋柊鎴块棿鏁版嵁浜� - /// 闇�瑕佺瓑鍒濆鍖栨湰鍦拌澶囨暟鎹悗鍦ㄥ彲浠ュ垵濮嬪寲鎴块棿鏁版嵁 - /// </summary> - public static bool CanInitAllRoom; + /// <summary> + /// 鏄惁鍙互鍒锋柊鎴块棿鏁版嵁浜� + /// 闇�瑕佺瓑鍒濆鍖栨湰鍦拌澶囨暟鎹悗鍦ㄥ彲浠ュ垵濮嬪寲鎴块棿鏁版嵁 + /// </summary> + public static bool CanInitAllRoom; - /// <summary> - /// 鑾峰彇鍠滅埍鎴块棿鐨勬墍鏈夎澶囪矾寰� - /// </summary> - /// <value>The love room device list.</value> - [Newtonsoft.Json.JsonIgnore] - public static List<string> LoveRoomDeviceUIFilePathList - { - get - { - if (Lists.Count == 0) - { - return new List<string> { }; - } - return GetLoveRoom().DeviceUIFilePathList; - } - } + /// <summary> + /// 鑾峰彇鍠滅埍鎴块棿鐨勬墍鏈夎澶囪矾寰� + /// </summary> + /// <value>The love room device list.</value> + [Newtonsoft.Json.JsonIgnore] + public static List<string> LoveRoomDeviceUIFilePathList + { + get + { + if (Lists.Count == 0) + { + return new List<string> { }; + } + return GetLoveRoom().DeviceUIFilePathList; + } + } - /// <summary> - /// 鎵�鏈夋埧闂寸殑鎵�鏈夎澶囩被鍨� - /// 鍏堣皟鐢� GetAllRoomDeviceTypeList() - /// </summary> - /// <value>All room device type list.</value> - [Newtonsoft.Json.JsonIgnore] - public static List<DeviceType> AllRoomDeviceTypeList = new List<DeviceType> { }; + /// <summary> + /// 鎵�鏈夋埧闂寸殑鎵�鏈夎澶囩被鍨� + /// 鍏堣皟鐢� GetAllRoomDeviceTypeList() + /// </summary> + /// <value>All room device type list.</value> + [Newtonsoft.Json.JsonIgnore] + public static List<DeviceType> AllRoomDeviceTypeList = new List<DeviceType> { }; - /// <summary> - /// 鑾峰彇鎵�鏈夋埧闂寸殑鎵�鏈夊満鏅� - /// </summary> - /// <value>All room scene UIL ist.</value> - [Newtonsoft.Json.JsonIgnore] - public static List<SceneUI> AllRoomSceneUIList - { - get - { - var sceneList = new List<SceneUI> { }; - foreach (var r in Shared.Common.Room.Lists) - { - if (r.SceneUIList.Count == 0) - { - continue; - } - foreach (var sceneUI in r.SceneUIList) - { - if (sceneUI == null) - { - continue; - } - sceneList.Add(sceneUI); - } - } - return sceneList; - } - } - /// <summary> - /// 鍦烘櫙鍒楄〃---涓嶅啀搴忓垪鍖� - /// </summary> - [Newtonsoft.Json.JsonIgnore] - public List<SceneUI> SceneUIList = new List<SceneUI> { }; - /// <summary> - ///鍦烘櫙鏂囦欢鍒楄〃 - /// </summary> - public readonly List<string> SceneUIFilePathList = new List<string>(); + /// <summary> + /// 鑾峰彇鎵�鏈夋埧闂寸殑鎵�鏈夊満鏅� + /// </summary> + /// <value>All room scene UIL ist.</value> + [Newtonsoft.Json.JsonIgnore] + public static List<SceneUI> AllRoomSceneUIList + { + get + { + var sceneList = new List<SceneUI> { }; + foreach (var r in Shared.Common.Room.Lists) + { + if (r.SceneUIList.Count == 0) + { + continue; + } + foreach (var sceneUI in r.SceneUIList) + { + if (sceneUI == null) + { + continue; + } + sceneList.Add(sceneUI); + } + } + return sceneList; + } + } + /// <summary> + /// 鍦烘櫙鍒楄〃---涓嶅啀搴忓垪鍖� + /// </summary> + [Newtonsoft.Json.JsonIgnore] + public List<SceneUI> SceneUIList = new List<SceneUI> { }; + /// <summary> + ///鍦烘櫙鏂囦欢鍒楄〃 + /// </summary> + public readonly List<string> SceneUIFilePathList = new List<string>(); - /// <summary> - /// 鎵�鏈夌殑鎴块棿淇℃伅 - /// </summary> - public static List<Room> Lists = new List<Room>(); + /// <summary> + /// 鎵�鏈夌殑鎴块棿淇℃伅 + /// </summary> + public static List<Room> Lists = new List<Room>(); - /// <summary> - /// 鑾峰彇鎵�鏈夋埧闂寸殑鎵�鏈夎澶� - /// 璇峰厛璋冪敤 GetAllRoomDeviceUIList()鏂规硶 - /// </summary> - /// <value>All room device UIL ist.</value> - [Newtonsoft.Json.JsonIgnore] - public static List<DeviceUI> AllRoomDeviceUIList = new List<DeviceUI> { }; + /// <summary> + /// 鑾峰彇鎵�鏈夋埧闂寸殑鎵�鏈夎澶� + /// 璇峰厛璋冪敤 GetAllRoomDeviceUIList()鏂规硶 + /// </summary> + /// <value>All room device UIL ist.</value> + [Newtonsoft.Json.JsonIgnore] + public static List<DeviceUI> AllRoomDeviceUIList = new List<DeviceUI> { }; - #endregion + #endregion - #region 鈼� 鏋勯�犳柟娉昣_______________________ + #region 鈼� 鏋勯�犳柟娉昣_______________________ - /// <summary> - /// 鏋勯�犳柟娉� - /// </summary> - static Room() - { - InitAllRoom(); - } + /// <summary> + /// 鏋勯�犳柟娉� + /// </summary> + static Room() + { + InitAllRoom(); + } - #endregion + #endregion - #region 鈼� 鍒濆鍖朹_________________________ + #region 鈼� 鍒濆鍖朹_________________________ - /// <summary> - /// 鍒濆鍖栨埧闂翠俊鎭� - /// 浠庢枃浠朵腑鍏ㄩ儴璇诲彇鎵�鏈夌殑鎴块棿鏁版嵁鍒板唴瀛� - /// </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); - //娣诲姞鍒癶ouse 鎴块棿璺緞鍒楄〃 - var currentHome = Config.Instance.Home; - currentHome.RoomFilePathList.Insert(0, love.FileName); - currentHome.Save(); - } - foreach (var roomFilePath in Config.Instance.Home.RoomFilePathList) - { - var room = GetRoomByFilePath(roomFilePath); + /// <summary> + /// 鍒濆鍖栨埧闂翠俊鎭� + /// 浠庢枃浠朵腑鍏ㄩ儴璇诲彇鎵�鏈夌殑鎴块棿鏁版嵁鍒板唴瀛� + /// </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); + //娣诲姞鍒癶ouse 鎴块棿璺緞鍒楄〃 + var currentHome = Config.Instance.Home; + currentHome.RoomFilePathList.Insert(0, love.FileName); + currentHome.Save(); + } + foreach (var roomFilePath in Config.Instance.Home.RoomFilePathList) + { + var room = GetRoomByFilePath(roomFilePath); - if (null != room) - { - if (room.IsSharedRoom) - { - room.Name = $"({Language.StringByID(R.MyInternationalizationString.Shared)}){room.Name}"; - } - Lists.Add(room); - } - } - } + if (null != room) + { + if (room.IsSharedRoom) + { + room.Name = $"({Language.StringByID(R.MyInternationalizationString.Shared)}){room.Name}"; + } + Lists.Add(room); + } + } + } - /// <summary> - /// 浠庢湰鍦伴噸鏂板姞杞藉叏閮ㄧ殑鎴块棿 - /// </summary> - public static void RefreshAllRoomByLocation() - { - Lists.Clear(); - var homeTemp = Config.Instance.Home; - homeTemp.RoomFilePathList.Clear(); - - var listFile = Global.FileListByHomeId(); - - //鎴戠殑鍠滅埍鐨勬埧闂村繀椤昏鍦ㄧ0浣嶆墠琛� - string fRoom = "Room_Favorite.json"; - if (listFile.Contains(fRoom) == true) - { - listFile.Remove(fRoom); - homeTemp.AddRoomListFilePath(fRoom); - } - - foreach (string fileName in listFile) - { - if (fileName.StartsWith("Room_")) - { - homeTemp.AddRoomListFilePath(fileName); - } - } - homeTemp.Save(false); - CanInitAllRoom = true; - InitAllRoom(); - } + /// <summary> + /// 浠庢湰鍦伴噸鏂板姞杞藉叏閮ㄧ殑鎴块棿 + /// </summary> + public static void RefreshAllRoomByLocation() + { + Lists.Clear(); + var homeTemp = Config.Instance.Home; + homeTemp.RoomFilePathList.Clear(); - #endregion + var listFile = Global.FileListByHomeId(); - #region 鈼� 娣诲姞鎴块棿_________________________ + //鎴戠殑鍠滅埍鐨勬埧闂村繀椤昏鍦ㄧ0浣嶆墠琛� + string fRoom = "Room_Favorite.json"; + if (listFile.Contains(fRoom) == true) + { + listFile.Remove(fRoom); + homeTemp.AddRoomListFilePath(fRoom); + } - /// <summary> - /// 澧炲姞鎴块棿 - /// </summary> - /// <returns><c>true</c>, if room was added, <c>false</c> otherwise.</returns> - /// <param name="room">Room.</param> - public bool AddRoom(Room room) - { - if (string.IsNullOrEmpty(room.FileName) || Global.IsExistsByHomeId(room.FileName)) - { - return false; - } - if (Config.Instance.Home.RoomFilePathList.Contains(room.FileName)) - { - return false; - } - Lists.Add(room); - var r = Config.Instance.Home.AddRoomListFilePath(room.FileName); - if (r == false) - { - return false; - } - Save(); - HdlAutoBackupLogic.AddOrEditorFile(room.FileName); - return true; - } + foreach (string fileName in listFile) + { + if (fileName.StartsWith("Room_")) + { + homeTemp.AddRoomListFilePath(fileName); + } + } + homeTemp.Save(false); + CanInitAllRoom = true; + InitAllRoom(); + } - #endregion + #endregion - #region 鈼� 鍒犻櫎鎴块棿_________________________ + #region 鈼� 娣诲姞鎴块棿_________________________ - /// <summary> - /// 鍒犻櫎鎴块棿 - /// </summary> - public bool Remove(string roomFilePath) - { - var room = GetRoomByFilePath(roomFilePath); - if (null == room) - { - return false; - } - //鍒犻櫎鏉ヨ嚜鎷嶇収鎴栬�呯郴缁熷浘搴撶殑鎴块棿鑳屾櫙鍥剧墖 - if (room.BackgroundImageType == 1 || room.BackgroundImageType == 2) - { - DeleteBackGroundIamageFilebyHomeId(room.BackgroundImage); - } - if (Global.IsExistsByHomeId(roomFilePath) == false) - { - return false; - } - Config.Instance.Home.RemoveRoomListFilePath(roomFilePath); - //鍒犻櫎鏂囦欢 - Global.DeleteFilebyHomeId(roomFilePath); - Lists.Remove(room); - HdlAutoBackupLogic.DeleteFile(roomFilePath); - return true; - } + /// <summary> + /// 澧炲姞鎴块棿 + /// </summary> + /// <returns><c>true</c>, if room was added, <c>false</c> otherwise.</returns> + /// <param name="room">Room.</param> + public bool AddRoom(Room room) + { + if (string.IsNullOrEmpty(room.FileName) || Global.IsExistsByHomeId(room.FileName)) + { + return false; + } + if (Config.Instance.Home.RoomFilePathList.Contains(room.FileName)) + { + return false; + } + Lists.Add(room); + var r = Config.Instance.Home.AddRoomListFilePath(room.FileName); + if (r == false) + { + return false; + } + Save(); + HdlAutoBackupLogic.AddOrEditorFile(room.FileName); + return true; + } - #endregion + #endregion - #region 鈼� 鑾峰彇鎴块棿________________________ + #region 鈼� 鍒犻櫎鎴块棿_________________________ - /// <summary> - /// 鑾峰彇鍠滅埍鎴块棿 - /// </summary> - /// <returns></returns> - public static Room GetLoveRoom() - { - return CurrentRoom.GetRoomById(LoveRoomId); - } + /// <summary> + /// 鍒犻櫎鎴块棿 + /// </summary> + public bool Remove(string roomFilePath) + { + var room = GetRoomByFilePath(roomFilePath); + if (null == room) + { + return false; + } + //鍒犻櫎鏉ヨ嚜鎷嶇収鎴栬�呯郴缁熷浘搴撶殑鎴块棿鑳屾櫙鍥剧墖 + if (room.BackgroundImageType == 1 || room.BackgroundImageType == 2) + { + DeleteBackGroundIamageFilebyHomeId(room.BackgroundImage); + } + if (Global.IsExistsByHomeId(roomFilePath) == false) + { + return false; + } + Config.Instance.Home.RemoveRoomListFilePath(roomFilePath); + //鍒犻櫎鏂囦欢 + Global.DeleteFilebyHomeId(roomFilePath); + Lists.Remove(room); + HdlAutoBackupLogic.DeleteFile(roomFilePath); + return true; + } - /// <summary> - /// 閫氳繃璺緞鑾峰彇鎴块棿 - /// </summary> - /// <returns>The room by file path.</returns> - /// <param name="roomFilePath">Room file path.</param> - public static Room GetRoomByFilePath(string roomFilePath) - { - try - { - var roomFile = Global.ReadFileByHomeId(roomFilePath); - var nowRoom = Newtonsoft.Json.JsonConvert.DeserializeObject<Room>(System.Text.Encoding.UTF8.GetString(roomFile)); + #endregion - if (null == nowRoom) - { - System.Console.WriteLine("鎴块棿鏂囦欢璺緞涓嶅锛屾枃浠惰矾寰勪负锛�" + roomFilePath); - return null; - } + #region 鈼� 鑾峰彇鎴块棿________________________ - var beforeRoom = Lists.Find((obj) => obj.Id == nowRoom.Id); - if (beforeRoom != null) - { - var tempDeviceUIList = new List<DeviceUI>(); - tempDeviceUIList.AddRange(beforeRoom.DeviceUIList); - var tempSceneUIList = new List<SceneUI>(); - tempSceneUIList.AddRange(beforeRoom.SceneUIList); - //璁惧锛坉eviceUI锛� - beforeRoom.DeviceUIList.Clear(); - foreach (var deviceFilePath in beforeRoom.DeviceUIFilePathList) - { - beforeRoom.DeviceUIList.Add(Common.LocalDevice.Current.GetDeviceUI(deviceFilePath)); - } - //鍦烘櫙(SceneUI) - beforeRoom.SceneUIList.Clear(); - foreach (var sceneFilePath in beforeRoom.SceneUIFilePathList) - { - var jsonInfo = Encoding.UTF8.GetString(Global.ReadFileByHomeId(sceneFilePath)); - var tempSceneUI = Newtonsoft.Json.JsonConvert.DeserializeObject<SceneUI>(jsonInfo); - if (tempSceneUI != null) - { - var scene = tempSceneUIList.Find((obj) => obj.FileName == tempSceneUI.FileName); - if (scene != null) - { - beforeRoom.SceneUIList.Add(scene); - } - else - { - beforeRoom.AddScene(scene); - } - } - } + /// <summary> + /// 鑾峰彇鍠滅埍鎴块棿 + /// </summary> + /// <returns></returns> + public static Room GetLoveRoom() + { + return CurrentRoom.GetRoomById(LoveRoomId); + } - return beforeRoom; - } + /// <summary> + /// 閫氳繃璺緞鑾峰彇鎴块棿 + /// </summary> + /// <returns>The room by file path.</returns> + /// <param name="roomFilePath">Room file path.</param> + public static Room GetRoomByFilePath(string roomFilePath) + { + try + { + var roomFile = Global.ReadFileByHomeId(roomFilePath); + var nowRoom = Newtonsoft.Json.JsonConvert.DeserializeObject<Room>(System.Text.Encoding.UTF8.GetString(roomFile)); - //璁惧锛坉eviceUI锛� - nowRoom.DeviceUIList.Clear(); - foreach (var deviceFilePath in nowRoom.DeviceUIFilePathList) - { - var tempCommon = LocalDevice.Current.GetDeviceUI(deviceFilePath); - if (tempCommon == null || tempCommon.CommonDevice == null) - { - continue; - } - nowRoom.DeviceUIList.Add(tempCommon); - } - //鍦烘櫙(SceneUI) - nowRoom.SceneUIList.Clear(); - foreach (var sceneUIFilePath in nowRoom.SceneUIFilePathList) - { - var jsonInfo = Encoding.UTF8.GetString(Global.ReadFileByHomeId(sceneUIFilePath)); - var tempScene = Newtonsoft.Json.JsonConvert.DeserializeObject<SceneUI>(jsonInfo); - if (tempScene == null) - { - continue; - } - nowRoom.SceneUIList.Add(tempScene); - } - return nowRoom; - } - catch(Exception ex) - { - return null; - } - } + if (null == nowRoom) + { + System.Console.WriteLine("鎴块棿鏂囦欢璺緞涓嶅锛屾枃浠惰矾寰勪负锛�" + roomFilePath); + return null; + } - /// <summary> - /// 鏍规嵁鎴块棿Id锛岃幏鍙栨埧闂村璞� - /// </summary> - /// <returns>The room by name.</returns> - /// <param name="roomId">鎴块棿ID</param> - public Room GetRoomById(string roomId) - { - return Lists.Find((obj) => obj.Id == roomId); - } + var beforeRoom = Lists.Find((obj) => obj.Id == nowRoom.Id); + if (beforeRoom != null) + { + var tempDeviceUIList = new List<DeviceUI>(); + tempDeviceUIList.AddRange(beforeRoom.DeviceUIList); + var tempSceneUIList = new List<SceneUI>(); + tempSceneUIList.AddRange(beforeRoom.SceneUIList); + //璁惧锛坉eviceUI锛� + beforeRoom.DeviceUIList.Clear(); + foreach (var deviceFilePath in beforeRoom.DeviceUIFilePathList) + { + beforeRoom.DeviceUIList.Add(Common.LocalDevice.Current.GetDeviceUI(deviceFilePath)); + } + //鍦烘櫙(SceneUI) + beforeRoom.SceneUIList.Clear(); + foreach (var sceneFilePath in beforeRoom.SceneUIFilePathList) + { + var jsonInfo = Encoding.UTF8.GetString(Global.ReadFileByHomeId(sceneFilePath)); + var tempSceneUI = Newtonsoft.Json.JsonConvert.DeserializeObject<SceneUI>(jsonInfo); + if (tempSceneUI != null) + { + var scene = tempSceneUIList.Find((obj) => obj.FileName == tempSceneUI.FileName); + if (scene != null) + { + beforeRoom.SceneUIList.Add(scene); + } + else + { + beforeRoom.AddScene(scene); + } + } + } - /// <summary> - /// 鏍规嵁璁惧鑾峰彇鎴块棿鍚嶅瓧(妤煎眰+鎴块棿鍚�) - /// </summary> - /// <returns>鎴块棿鍚�</returns> - /// <param name="device">璁惧瀵硅薄</param> - public string GetRoomNameByDevice(CommonDevice device) - { - var room = this.GetRoomByDevice(device); - if (room == null) - { - //鏈垎閰嶅尯鍩� - return Language.StringByID(R.MyInternationalizationString.uDeviceNotAssignedRoom); - } - if (Config.Instance.Home.FloorDics.ContainsKey(room.FloorId) == true) - { - //(妤煎眰+鎴块棿鍚�) - return Config.Instance.Home.FloorDics[room.FloorId] + " " + room.Name; - } - return room.Name; - } + return beforeRoom; + } - /// <summary> - /// 鑾峰彇璁惧鎵�鍦ㄧ殑鎴块棿 - /// </summary> - /// <returns>The room by device.</returns> - /// <param name="device">璁惧瀵硅薄</param> - public Room GetRoomByDevice(CommonDevice device) - { - var deviceUI = new DeviceUI { }; - deviceUI.DeviceAddr = device.DeviceAddr; - deviceUI.DeviceEpoint = device.DeviceEpoint; + //璁惧锛坉eviceUI锛� + nowRoom.DeviceUIList.Clear(); + foreach (var deviceFilePath in nowRoom.DeviceUIFilePathList) + { + var tempCommon = LocalDevice.Current.GetDeviceUI(deviceFilePath); + if (tempCommon == null || tempCommon.CommonDevice == null) + { + continue; + } + nowRoom.DeviceUIList.Add(tempCommon); + } + //鍦烘櫙(SceneUI) + nowRoom.SceneUIList.Clear(); + foreach (var sceneUIFilePath in nowRoom.SceneUIFilePathList) + { + var jsonInfo = Encoding.UTF8.GetString(Global.ReadFileByHomeId(sceneUIFilePath)); + var tempScene = Newtonsoft.Json.JsonConvert.DeserializeObject<SceneUI>(jsonInfo); + if (tempScene == null) + { + continue; + } + nowRoom.SceneUIList.Add(tempScene); + } + return nowRoom; + } + catch (Exception ex) + { + return null; + } + } - return Lists.Find((obj) => obj.DeviceUIFilePathList.Contains(deviceUI.FileName)); - } + /// <summary> + /// 鏍规嵁鎴块棿Id锛岃幏鍙栨埧闂村璞� + /// </summary> + /// <returns>The room by name.</returns> + /// <param name="roomId">鎴块棿ID</param> + public Room GetRoomById(string roomId) + { + return Lists.Find((obj) => obj.Id == roomId); + } - /// <summary> - /// 閫氳繃鍦烘櫙id鑾峰彇鎴块棿鍚� - /// </summary> - /// <returns>The room name by scene identifier.</returns> - /// <param name="sceneId">Scene identifier.</param> - public string GetRoomNameBySceneId(int sceneId) - { - var room = GetRoomBySceneId(sceneId); - if (room == null) - { - return null; - } - return room.Name; - } + /// <summary> + /// 鏍规嵁璁惧鑾峰彇鎴块棿鍚嶅瓧(妤煎眰+鎴块棿鍚�) + /// </summary> + /// <returns>鎴块棿鍚�</returns> + /// <param name="device">璁惧瀵硅薄</param> + public string GetRoomNameByDevice(CommonDevice device) + { + var room = this.GetRoomByDevice(device); + if (room == null) + { + //鏈垎閰嶅尯鍩� + return Language.StringByID(R.MyInternationalizationString.uDeviceNotAssignedRoom); + } + if (Config.Instance.Home.FloorDics.ContainsKey(room.FloorId) == true) + { + //(妤煎眰+鎴块棿鍚�) + return Config.Instance.Home.FloorDics[room.FloorId] + " " + room.Name; + } + return room.Name; + } - /// <summary> - /// 閫氳繃鍦烘櫙id鑾峰彇鎴块棿瀵硅薄 - /// </summary> - /// <returns>The room by scene identifier.</returns> - /// <param name="sceneId">Scene identifier.</param> - public Room GetRoomBySceneId(int sceneId) - { - foreach (var r in Lists) - { - foreach (var scene in r.SceneUIList) - { - if (scene.Id == sceneId) - { - return r; - } - } - } - return null; - } + /// <summary> + /// 鑾峰彇璁惧鎵�鍦ㄧ殑鎴块棿 + /// </summary> + /// <returns>The room by device.</returns> + /// <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)); + } - #endregion + /// <summary> + /// 閫氳繃鍦烘櫙id鑾峰彇鎴块棿鍚� + /// </summary> + /// <returns>The room name by scene identifier.</returns> + /// <param name="sceneId">Scene identifier.</param> + public string GetRoomNameBySceneId(int sceneId) + { + var room = GetRoomBySceneId(sceneId); + if (room == null) + { + return null; + } + return room.Name; + } - #region 鈼� 鎴块棿鏂规硶________________________ + /// <summary> + /// 閫氳繃鍦烘櫙id鑾峰彇鎴块棿瀵硅薄 + /// </summary> + /// <returns>The room by scene identifier.</returns> + /// <param name="sceneId">Scene identifier.</param> + public Room GetRoomBySceneId(int sceneId) + { + foreach (var r in Lists) + { + foreach (var scene in r.SceneUIList) + { + if (scene.Id == sceneId) + { + return r; + } + } + } + return null; + } - /// <summary> - /// 璁惧鐨勬埧闂村彉鏇� - /// </summary> - /// <param name="device">璁惧瀵硅薄</param> - /// <param name="roomId">鏂版埧闂碔d</param> - public void ChangedRoom(CommonDevice device, string roomId) - { - //鎴块棿鏄惁淇敼 - if (this.IsRoomChanged(device, roomId) == false) - { - return; - } - //浠庡師鏉ョ殑鎴块棿绉婚櫎璁惧 - this.DeleteDevice(device); - //娣诲姞鍒版柊鐨勬埧闂� - var room = this.GetRoomById(roomId); - if (room != null) - { - room.AddDevice(device); - } - } - - /// <summary> - /// 鎴块棿鍚嶅瓧鏄惁鏈変慨鏀� - /// </summary> - /// <param name="device">璁惧瀵硅薄</param> - /// <param name="roomId">鏂版埧闂碔d</param> - /// <returns></returns> - public bool IsRoomChanged(CommonDevice device, string roomId) - { - var room = this.GetRoomByDevice(device); - if (room == null || room.Id != roomId) - { - return true; - } - return false; - } + #endregion - #endregion + #region 鈼� 鎴块棿鏂规硶________________________ - #region 鈼� 鏇存柊鎴块棿_________________________ + /// <summary> + /// 璁惧鐨勬埧闂村彉鏇� + /// </summary> + /// <param name="device">璁惧瀵硅薄</param> + /// <param name="roomId">鏂版埧闂碔d</param> + public void ChangedRoom(CommonDevice device, string roomId) + { + //鎴块棿鏄惁淇敼 + if (this.IsRoomChanged(device, roomId) == false) + { + return; + } + //浠庡師鏉ョ殑鎴块棿绉婚櫎璁惧 + this.DeleteDevice(device); - /// <summary> - /// Updates the memorry. - /// </summary> - /// <param name="roomFilePath">Room file path.</param> - public static void UpdateMemorry(string roomFilePath) - { - GetRoomByFilePath(roomFilePath); - } + //娣诲姞鍒版柊鐨勬埧闂� + var room = this.GetRoomById(roomId); + if (room != null) + { + room.AddDevice(device); + } + } + + /// <summary> + /// 鎴块棿鍚嶅瓧鏄惁鏈変慨鏀� + /// </summary> + /// <param name="device">璁惧瀵硅薄</param> + /// <param name="roomId">鏂版埧闂碔d</param> + /// <returns></returns> + public bool IsRoomChanged(CommonDevice device, string roomId) + { + var room = this.GetRoomByDevice(device); + if (room == null || room.Id != roomId) + { + return true; + } + return false; + } + + #endregion + + #region 鈼� 鏇存柊鎴块棿_________________________ + + /// <summary> + /// Updates the memorry. + /// </summary> + /// <param name="roomFilePath">Room file path.</param> + public static void UpdateMemorry(string roomFilePath) + { + GetRoomByFilePath(roomFilePath); + } + + #endregion + + #region 鈼� 鎴块棿鑳屾櫙鍥剧殑鐩稿叧___________________ + /// <summary> + /// 鍒犻櫎鑳屾櫙鍥剧墖 + /// </summary> + /// <param name="fileName">fileName瀹為檯涓婂寘鍚簡浣忓畢璺姴 濡� 浣忓畢/鏂囦欢鍚�.</param> + public static void DeleteBackGroundIamageFilebyHomeId(string fileName) + { + if (fileName == null) + { + return; + } + var pathLists = fileName.Split('/'); + if (pathLists == null || pathLists.Count() < 9 || pathLists[8] == null) + { + return; + } + var path = System.IO.Path.Combine(Config.Instance.FullPath, fileName); + if (!Global.IsExistsByHomeId(pathLists[8])) + { + return; + } + //鍒犻櫎鏈湴鍥剧墖 + System.IO.File.Delete(path); + //鍒犻櫎澶囦唤 + Phone.UserCenter.HdlAutoBackupLogic.DeleteFile(pathLists[8]); + } + + /// <summary> + /// 绉诲姩鑳屾櫙鍥剧墖鍒颁綇瀹呯洰褰曚笅 + /// </summary> + /// <param name="oldFile">闇�瑕佺Щ鍔ㄧ殑鏂囦欢(鐩存帴鏂囦欢鍚�)</param> + /// <param name="newFile">瑕佺Щ鍔ㄥ埌鐨勪綅缃�-(鍖呭惈浣忓畢璺緞锛氫綇瀹�/鏂囦欢鍚�)</param> + public void MoveBackGroundIamageFileToDirectory(string oldFile, string newFile) + { + try + { + var newPath = System.IO.Path.Combine(Config.Instance.FullPath, newFile); + var path = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, oldFile); + Global.MoveFileToDirectory(path, newPath); + //澶囦唤 + Phone.UserCenter.HdlAutoBackupLogic.AddOrEditorFile(oldFile); + //Save(); + } + catch (Exception ex) + { + System.Console.WriteLine("绉诲姩鍥剧墖寮傚父 " + ex.Message); + } + } + + #endregion + + #region 鈼� 娣诲姞璁惧________________________ + + /// <summary> + /// 娣诲姞璁惧 + /// </summary> + /// <param name="deviceUIFilePath">Device UIF ile path.</param> + public void AddDevice(string deviceUIFilePath) + { + if (string.IsNullOrEmpty(deviceUIFilePath)) + { + return; + } + var jsonInfo = Encoding.UTF8.GetString(Global.ReadFileByHomeId(deviceUIFilePath)); + var deviceUI = Newtonsoft.Json.JsonConvert.DeserializeObject<DeviceUI>(jsonInfo); + if (null == deviceUI || null == deviceUI.CommonDevice) + { + //褰撳墠瀵硅薄鏁版嵁鏃犳晥 + return; + } + if (!DeviceUIFilePathList.Contains(deviceUIFilePath) && !DeviceUIList.Contains(deviceUI)) + { + DeviceUIFilePathList.Add(deviceUIFilePath); + DeviceUIList.Add(deviceUI); + } + //淇濆瓨鍒版湰鍦� + Save(); + } + + /// <summary> + /// 娣诲姞璁惧 + /// </summary> + /// <param name="device">瑕佹坊鍔犵殑璁惧瀵硅薄</param> + public void AddDevice(CommonDevice device) + { + if (device == null) + { + return; + } + //璁惧淇℃伅淇濆瓨鍒版湰鍦� + device.Save(); + + //娣诲姞鑷姩澶囦唤 + HdlAutoBackupLogic.AddOrEditorFile(device.FilePath); + + DeviceUI deviceUI = Common.LocalDevice.Current.GetDeviceUI(device); + if (DeviceUIFilePathList.Contains(deviceUI.FileName) == false) + { + DeviceUIFilePathList.Add(deviceUI.FileName); + DeviceUIList.Add(deviceUI); + //淇濆瓨鍒版湰鍦� + Save(); + + //娣诲姞鑷姩澶囦唤 + HdlAutoBackupLogic.AddOrEditorFile(FileName); + } + } + + #endregion + + #region 鈼� 鍒犻櫎璁惧_________________________ + + /// <summary> + /// 鍒犻櫎鍔熻兘-璁惧 + /// </summary> + /// <param name="deviceUIFilePath">Device UIF ile path.</param> + public void DeleteDevice(string deviceUIFilePath) + { + if (deviceUIFilePath == null) return; + if (DeviceUIFilePathList.Contains(deviceUIFilePath) && Global.IsExistsByHomeId(deviceUIFilePath)) + { + DeviceUIFilePathList.Remove(deviceUIFilePath); + DeviceUIList.RemoveAll((obj) => obj.FileName == deviceUIFilePath); + HdlAutoBackupLogic.DeleteFile(deviceUIFilePath); + Save(); + } + } + + /// <summary> + /// 鍒犻櫎璁惧 + /// </summary> + /// <param name="device">瑕佸垹闄ょ殑璁惧瀵硅薄</param> + public void DeleteDevice(CommonDevice device) + { + if (device == null) + { + return; + } + DeviceUI deviceUI = new DeviceUI(); + deviceUI.DeviceAddr = device.DeviceAddr; + deviceUI.DeviceEpoint = device.DeviceEpoint; + + //鏍规嵁璁惧锛岃幏鍙栨墍鍦ㄧ殑鎴块棿 + var room = this.GetRoomByDevice(device); + if (room == null) + { + return; + } + //绉婚櫎缂撳瓨 + if (room.DeviceUIFilePathList.Contains(deviceUI.FileName) == false) + { + return; + } + room.DeviceUIFilePathList.Remove(deviceUI.FileName); + + room.DeviceUIList.RemoveAll((obj) => obj.FileName == deviceUI.FileName); + room.Save(); + //鏇存敼鑷姩澶囦唤 + HdlAutoBackupLogic.AddOrEditorFile(room.FileName); + } + + #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); + } + } + } + } - #endregion + /// <summary> + /// 鏍规嵁璁惧鑾峰彇瀹冪殑UI瀵硅薄锛屽鏋滀笉瀛樺湪鍒欐柊寤� + /// </summary> + /// <returns>The device user interface.</returns> + /// <param name="device">璁惧瀵硅薄</param> + public DeviceUI GetDeviceUI(CommonDevice device) + { + return Common.LocalDevice.Current.GetDeviceUI(device); + } - #region 鈼� 鎴块棿鑳屾櫙鍥剧殑鐩稿叧___________________ - /// <summary> - /// 鍒犻櫎鑳屾櫙鍥剧墖 - /// </summary> - /// <param name="fileName">fileName瀹為檯涓婂寘鍚簡浣忓畢璺姴 濡� 浣忓畢/鏂囦欢鍚�.</param> - public static void DeleteBackGroundIamageFilebyHomeId(string fileName) - { - if (fileName == null) - { - return; - } - var pathLists = fileName.Split('/'); - if (pathLists == null || pathLists.Count() < 9 || pathLists[8] == null) - { - return; - } - var path = System.IO.Path.Combine(Config.Instance.FullPath, fileName); - if (!Global.IsExistsByHomeId(pathLists[8])) - { - return; - } - //鍒犻櫎鏈湴鍥剧墖 - System.IO.File.Delete(path); - //鍒犻櫎澶囦唤 - Phone.UserCenter.HdlAutoBackupLogic.DeleteFile(pathLists[8]); - } + /// <summary> + /// 閲嶆柊鑾峰彇-鎵�鏈夋埧闂寸殑鎵�鏈夎澶囩被鍨� + /// </summary> + public static void GetAllRoomDeviceTypeList() + { + AllRoomDeviceTypeList.Clear(); + foreach (var deviceUI in AllRoomDeviceUIList) + { + if (deviceUI == null || deviceUI.CommonDevice == null) + { + continue; + } + if (!AllRoomDeviceTypeList.Contains(deviceUI.CommonDevice.Type)) + { + AllRoomDeviceTypeList.Add(deviceUI.CommonDevice.Type); + } + } + } - /// <summary> - /// 绉诲姩鑳屾櫙鍥剧墖鍒颁綇瀹呯洰褰曚笅 - /// </summary> - /// <param name="oldFile">闇�瑕佺Щ鍔ㄧ殑鏂囦欢(鐩存帴鏂囦欢鍚�)</param> - /// <param name="newFile">瑕佺Щ鍔ㄥ埌鐨勪綅缃�-(鍖呭惈浣忓畢璺緞锛氫綇瀹�/鏂囦欢鍚�)</param> - public void MoveBackGroundIamageFileToDirectory(string oldFile, string newFile) - { - try - { - var newPath = System.IO.Path.Combine(Config.Instance.FullPath, newFile); - var path = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath,oldFile); - Global.MoveFileToDirectory(path, newPath); - //澶囦唤 - Phone.UserCenter.HdlAutoBackupLogic.AddOrEditorFile(oldFile); - //Save(); - } - catch (Exception ex) - { - System.Console.WriteLine("绉诲姩鍥剧墖寮傚父 " + ex.Message); - } - } + /// <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 + #endregion - #region 鈼� 娣诲姞璁惧________________________ + #region 鈼� 娣诲姞鍦烘櫙_________________________ - /// <summary> - /// 娣诲姞璁惧 - /// </summary> - /// <param name="deviceUIFilePath">Device UIF ile path.</param> - public void AddDevice(string deviceUIFilePath) - { - if (string.IsNullOrEmpty(deviceUIFilePath)) - { - return; - } - var jsonInfo = Encoding.UTF8.GetString(Global.ReadFileByHomeId(deviceUIFilePath)); - var deviceUI = Newtonsoft.Json.JsonConvert.DeserializeObject<DeviceUI>(jsonInfo); - if (null == deviceUI || null == deviceUI.CommonDevice) - { - //褰撳墠瀵硅薄鏁版嵁鏃犳晥 - return; - } - if (!DeviceUIFilePathList.Contains(deviceUIFilePath) && !DeviceUIList.Contains(deviceUI)) - { - DeviceUIFilePathList.Add(deviceUIFilePath); - DeviceUIList.Add(deviceUI); - } - //淇濆瓨鍒版湰鍦� - Save(); - } + /// <summary> + /// 娣诲姞鍦烘櫙 0澶辫触 1鎴愬姛 -1宸茬粡瀛樺湪 + /// </summary> + /// <returns>The scene.</returns> + /// <param name="sceneName">Scene name.</param> + /// <param name="sceneIconPath">鑳屾櫙鍥剧墖锛屼笉鍖呭惈浣忓畢璺緞 濡傛灉iconPathType=1鎴栬��2 闇�瑕佹嫾鎺ヤ綇瀹� 鍙樻垚 浣忓畢/sceneIconPath</param> + /// <param name="commons">Commons.</param> + /// <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) + { + 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; + } + } - /// <summary> - /// 娣诲姞璁惧 - /// </summary> - /// <param name="device">瑕佹坊鍔犵殑璁惧瀵硅薄</param> - public void AddDevice(CommonDevice device) - { - if (device == null) - { - return; - } - //璁惧淇℃伅淇濆瓨鍒版湰鍦� - device.Save(); + bool result = true; + foreach (var common in commons) + { + //娣诲姞鏂版垚鍛� + var addSceneMemberData = new ZigBee.Device.Scene.AddSceneMemberData + { + DeviceAddr = common.DeviceAddr, + Type = common.Type, + Epoint = common.Epoint, + ScenesId = getSceneIdData.NewScenesId, + TaskList = common.TaskList, + DelayTime = common.DelayTime, + ElseScenesId = common.ElseScenesId + }; + //common.ScenesId = getSceneIdData.NewScenesId; + //娣诲姞鏂版垚鍛� 杩斿洖缁撴灉 + var addSceneMemberResponseAllData = await ZigBee.Device.Scene.AddSceneMemberAsync(addSceneMemberData); + if (addSceneMemberResponseAllData == null || addSceneMemberResponseAllData.addSceneMemberResponseData == null) + { + continue; + } + var addSceneMemberResponseData = addSceneMemberResponseAllData.addSceneMemberResponseData; + if (addSceneMemberResponseData == null && addSceneMemberResponseData.Result != 1) + { + result = false; + } + } + //鍔犲叆鎴愬姛 + if (result) + { + //iconPathType=0 鐩存帴浼犲�硷紝 iconPathType=1鍜宨conPathType=2闇�瑕佹嫾鎺ヤ綇瀹呰矾寰� + var fullPath = sceneIconPath; + if (iconPathType == 1 || iconPathType == 2) + { + Common.Room.CurrentRoom.MoveBackGroundIamageFileToDirectory(sceneIconPath, $"{Config.Instance.FullPath}/{sceneIconPath}"); + fullPath = $"{Config.Instance.FullPath}/{sceneIconPath}"; + } + var sceneUI = new SceneUI + { + Name = sceneName, + Id = getSceneIdData.NewScenesId, + IconPath = fullPath, + IconPathType = iconPathType, + AddSceneMemberDataList = commons + }; + SceneUIList.Add(sceneUI); + SceneUIFilePathList.Add(sceneUI.FileName); + sceneUI.Save(); + Save(); + HdlAutoBackupLogic.AddOrEditorFile(sceneUI.FileName); + return 1; + } + return 0; + } - //娣诲姞鑷姩澶囦唤 - HdlAutoBackupLogic.AddOrEditorFile(device.FilePath); + /// <summary> + /// 娣诲姞鍦烘櫙 + /// </summary> + /// <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(); + Save(); + } - DeviceUI deviceUI = Common.LocalDevice.Current.GetDeviceUI(device); - if (DeviceUIFilePathList.Contains(deviceUI.FileName) == false) - { - DeviceUIFilePathList.Add(deviceUI.FileName); - DeviceUIList.Add(deviceUI); - //淇濆瓨鍒版湰鍦� - Save(); + #endregion - //娣诲姞鑷姩澶囦唤 - HdlAutoBackupLogic.AddOrEditorFile(FileName); - } - } + #region 鈼� 璁惧鏄惁鏀惰棌______________________ - #endregion + /// <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 鈼� 鍒犻櫎璁惧_________________________ + #region 鈼� 淇敼鍦烘櫙________________________ - /// <summary> - /// 鍒犻櫎鍔熻兘-璁惧 - /// </summary> - /// <param name="deviceUIFilePath">Device UIF ile path.</param> - public void DeleteDevice(string deviceUIFilePath) - { - if (deviceUIFilePath == null) return; - if (DeviceUIFilePathList.Contains(deviceUIFilePath) && Global.IsExistsByHomeId(deviceUIFilePath)) - { - DeviceUIFilePathList.Remove(deviceUIFilePath); - DeviceUIList.RemoveAll((obj) => obj.FileName == deviceUIFilePath); - HdlAutoBackupLogic.DeleteFile(deviceUIFilePath); - Save(); - } - } + /// <summary> + /// 淇敼鍦烘櫙璁惧 0澶辫触 1鎴愬姛 + /// </summary> + /// <returns>The scene.</returns> + /// <param name="sceneUI">Scene user interface.</param> + /// <param name="sceneRemoveMemberData">Scene remove member data.</param> + /// <param name="addCommons">Add commons.</param> + public async System.Threading.Tasks.Task<int> ModifyScene(SceneUI sceneUI, Scene.SceneRemoveMemberData sceneRemoveMemberData, List<Scene.AddSceneMemberData> addCommons) + { + if (AllRoomSceneUIList.Find(s => s.Name == sceneUI.Name) == null) + { + return 0; + } - /// <summary> - /// 鍒犻櫎璁惧 - /// </summary> - /// <param name="device">瑕佸垹闄ょ殑璁惧瀵硅薄</param> - public void DeleteDevice(CommonDevice device) - { - if (device == null) - { - return; - } - DeviceUI deviceUI = new DeviceUI(); - deviceUI.DeviceAddr = device.DeviceAddr; - deviceUI.DeviceEpoint = device.DeviceEpoint; + bool result = true; + //绉婚櫎鎴愬憳 杩斿洖缁撴灉 + var removeSceneMemberResponseAllData = await ZigBee.Device.Scene.RemoveSceneMemberAsync(sceneRemoveMemberData); + if (removeSceneMemberResponseAllData == null || removeSceneMemberResponseAllData.removeSceneMemberResponseData == null) + { + return 0; + } + var removeSceneMemberResponseData = removeSceneMemberResponseAllData.removeSceneMemberResponseData; + if (removeSceneMemberResponseData == null) + { + return 0; + } + if (removeSceneMemberResponseData.Result != 0) + { + result = false; + } + //娣诲姞 + foreach (var addCommon in addCommons) + { + //娣诲姞鏂版垚鍛� + var addSceneMemberData = new ZigBee.Device.Scene.AddSceneMemberData + { + DeviceAddr = addCommon.DeviceAddr, + Type = addCommon.Type, + Epoint = addCommon.Epoint, + ScenesId = sceneUI.Id, + TaskList = addCommon.TaskList, + DelayTime = addCommon.DelayTime, + ElseScenesId = addCommon.ElseScenesId + }; + //娣诲姞鏂版垚鍛� 杩斿洖缁撴灉 + var addSceneMemberResponseAllData = await ZigBee.Device.Scene.AddSceneMemberAsync(addSceneMemberData); + if (addSceneMemberResponseAllData == null || addSceneMemberResponseAllData.addSceneMemberResponseData == null) + { + result = false; + System.Console.WriteLine("娣诲姞鍦烘櫙澶辫触"); + continue; + } + var addSceneMemberResponseData = addSceneMemberResponseAllData.addSceneMemberResponseData; + if (addSceneMemberResponseData == null && addSceneMemberResponseData.Result != 1) + { + result = false; + } + } + //鍔犲叆鎴愬姛 + if (result) + { + sceneUI.AddSceneMemberDataList = addCommons; + sceneUI.Save(); + return 1; + } + return 0; + } - //鏍规嵁璁惧锛岃幏鍙栨墍鍦ㄧ殑鎴块棿 - var room = this.GetRoomByDevice(device); - if (room == null) - { - return; - } - //绉婚櫎缂撳瓨 - if (room.DeviceUIFilePathList.Contains(deviceUI.FileName) == false) - { - return; - } - room.DeviceUIFilePathList.Remove(deviceUI.FileName); - - room.DeviceUIList.RemoveAll((obj) => obj.FileName == deviceUI.FileName); - room.Save(); - //鏇存敼鑷姩澶囦唤 - HdlAutoBackupLogic.AddOrEditorFile(room.FileName); - } + #endregion - #endregion + #region 鈼� 鍒犻櫎鍦烘櫙________________________ - #region 鈼� 鑾峰彇璁惧_________________________ + /// <summary> + /// 绉婚櫎鍦烘櫙--璇ヤ粎杩涜浜嗗鏈湴鍦烘櫙鏁版嵁鐨勫垹闄� + /// </summary> + /// <param name="sceneUI">Scene user interface.</param> + public void RemoveScene(SceneUI sceneUI) + { + if (Global.IsExistsByHomeId(sceneUI.FileName) == false) + { + return; + } + SceneUIList.Remove(sceneUI); + SceneUIFilePathList.Remove(sceneUI.FileName); + Save(); + Global.DeleteFilebyHomeId(sceneUI.FileName); + HdlAutoBackupLogic.DeleteFile(sceneUI.FileName); + HdlAutoBackupLogic.AddOrEditorFile(FileName); + } - /// <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); - } - } - } - } + #endregion - /// <summary> - /// 鏍规嵁璁惧鑾峰彇瀹冪殑UI瀵硅薄锛屽鏋滀笉瀛樺湪鍒欐柊寤� - /// </summary> - /// <returns>The device user interface.</returns> - /// <param name="device">璁惧瀵硅薄</param> - public DeviceUI GetDeviceUI(CommonDevice device) - { - return Common.LocalDevice.Current.GetDeviceUI(device); - } + #region 鈼� 鑾峰彇鍦烘櫙________________________ - /// <summary> - /// 閲嶆柊鑾峰彇-鎵�鏈夋埧闂寸殑鎵�鏈夎澶囩被鍨� - /// </summary> - public static void GetAllRoomDeviceTypeList() - { - AllRoomDeviceTypeList.Clear(); - foreach (var deviceUI in AllRoomDeviceUIList) - { - if (deviceUI == null || deviceUI.CommonDevice == null) - { - continue; - } - if (!AllRoomDeviceTypeList.Contains(deviceUI.CommonDevice.Type)) - { - AllRoomDeviceTypeList.Add(deviceUI.CommonDevice.Type); - } - } - } + /// <summary> + /// 閫氳繃鍦烘櫙id鑾峰彇鍦烘櫙 + /// </summary> + /// <returns>The scene UIB y scene identifier.</returns> + /// <param name="sceneId">Scene identifier.</param> + public SceneUI GetSceneUIBySceneId(int sceneId) + { + foreach (var r in Lists) + { + foreach (var sceneUI in r.SceneUIList) + { + if (sceneUI.Id == sceneId) + { + return sceneUI; + } + } + } + return null; + } - /// <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 - #endregion + #region 鈼� 鍒锋柊鍦烘櫙_________________________ - #region 鈼� 娣诲姞鍦烘櫙_________________________ + /// <summary> + /// 鍒锋柊鎴块棿鐨勫満鏅垪琛� + /// </summary> + public async System.Threading.Tasks.Task<bool> RefreshSceneUIList() + { + return false; + //System.Console.WriteLine($"寮�濮嬭姹傜綉鍏冲満鏅�****{DateTime.Now.ToString("yyMMdd hhmmss fff")}*****"); + //bool result = true; + //var sceneList = await ZigBee.Device.Scene.GetSceneListAsync(); + //System.Console.WriteLine($"缁撴潫璇锋眰缃戝叧鍦烘櫙****{DateTime.Now.ToString("yyMMdd hhmmss fff")}*****"); + //if (sceneList == null) + //{ + // return false; + //} + //List<int> sceneIDList = new List<int> { }; + //System.Console.WriteLine($"寮�濮嬫湰鍦板満鏅�****{DateTime.Now.ToString("yyMMdd hhmmss fff")}*****"); + //foreach (var scene in sceneList) + //{ + // if (scene == null) + // { + // continue; + // } + // sceneIDList.Add(scene.ScenesId); + //} + //foreach(var r in Lists) + //{ + // if(r.SceneUIList==null || r.SceneUIList.Count==0) + // { + // continue; + // } + // foreach(var rScene in r.SceneUIList) + // { + // if(rScene==null) + // { + // continue; + // } + // //var scene = sceneList.Find((obj) => rScene.ScenesId == obj.ScenesId); + // if(sceneIDList.Contains(rScene.ScenesId)==false) + // { + // var removeResult = r.SceneUIList.Remove(rScene); + // r.Save(); + // if (removeResult == false) + // { + // result = false; + // } + // } + // } + //} + //System.Console.WriteLine($"缁撴潫鏈湴鍦烘櫙****{DateTime.Now.ToString("yyMMdd hhmmss fff")}*****"); + //return result; + } - /// <summary> - /// 娣诲姞鍦烘櫙 0澶辫触 1鎴愬姛 -1宸茬粡瀛樺湪 - /// </summary> - /// <returns>The scene.</returns> - /// <param name="sceneName">Scene name.</param> - /// <param name="sceneIconPath">鑳屾櫙鍥剧墖锛屼笉鍖呭惈浣忓畢璺緞 濡傛灉iconPathType=1鎴栬��2 闇�瑕佹嫾鎺ヤ綇瀹� 鍙樻垚 浣忓畢/sceneIconPath</param> - /// <param name="commons">Commons.</param> - /// <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) - { - 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; - } - } + #endregion - bool result = true; - foreach (var common in commons) - { - //娣诲姞鏂版垚鍛� - var addSceneMemberData = new ZigBee.Device.Scene.AddSceneMemberData - { - DeviceAddr = common.DeviceAddr, - Type = common.Type, - Epoint = common.Epoint, - ScenesId = getSceneIdData.NewScenesId, - TaskList = common.TaskList, - DelayTime = common.DelayTime, - ElseScenesId = common.ElseScenesId - }; - //common.ScenesId = getSceneIdData.NewScenesId; - //娣诲姞鏂版垚鍛� 杩斿洖缁撴灉 - var addSceneMemberResponseAllData = await ZigBee.Device.Scene.AddSceneMemberAsync(addSceneMemberData); - if (addSceneMemberResponseAllData == null || addSceneMemberResponseAllData.addSceneMemberResponseData == null) - { - continue; - } - var addSceneMemberResponseData = addSceneMemberResponseAllData.addSceneMemberResponseData; - if (addSceneMemberResponseData == null && addSceneMemberResponseData.Result != 1) - { - result = false; - } - } - //鍔犲叆鎴愬姛 - if (result) - { - //iconPathType=0 鐩存帴浼犲�硷紝 iconPathType=1鍜宨conPathType=2闇�瑕佹嫾鎺ヤ綇瀹呰矾寰� - var fullPath = sceneIconPath; - if (iconPathType == 1 || iconPathType == 2) - { - Common.Room.CurrentRoom.MoveBackGroundIamageFileToDirectory(sceneIconPath, $"{Config.Instance.FullPath}/{sceneIconPath}"); - fullPath = $"{Config.Instance.FullPath}/{sceneIconPath}"; - } - var sceneUI = new SceneUI - { - Name = sceneName, - Id = getSceneIdData.NewScenesId, - IconPath = fullPath, - IconPathType = iconPathType, - AddSceneMemberDataList= commons - }; - SceneUIList.Add(sceneUI); - SceneUIFilePathList.Add(sceneUI.FileName); - sceneUI.Save(); - Save(); - HdlAutoBackupLogic.AddOrEditorFile(sceneUI.FileName); - return 1; - } - return 0; - } + #region 鈼� 淇濆瓨____________________________ - /// <summary> - /// 娣诲姞鍦烘櫙 - /// </summary> - /// <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(); - Save(); - } + /// <summary> + /// 淇濆瓨 + /// </summary> + /// <param name="autoBackup">鏄惁鑷姩澶囦唤锛岄粯璁rue</param> + public void Save(bool autoBackup = true) + { + //淇濆瓨鎴块棿淇℃伅 + Global.WriteFileByBytesByHomeId(FileName, System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this))); + if (autoBackup == true) + { + HdlAutoBackupLogic.AddOrEditorFile(FileName); + } + } - #endregion + #endregion - #region 鈼� 璁惧鏄惁鏀惰棌______________________ + #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 + /// <summary> + /// 鏍规嵁妤煎眰鐨勪富閿幏鍙栨帓搴忓悗鐨勬埧闂村垪琛� + /// </summary> + /// <param name="i_floorKeys">妤煎眰鐨勪富閿�</param> + /// <param name="getShard">鍒嗕韩鐨勬埧闂存槸鍚︿篃鑾峰彇</param> + /// <returns></returns> + public List<Room> GetFloorSortRoom(string i_floorKeys, bool getShard = true) + { + Dictionary<string, List<string>> dicAllSort = new Dictionary<string, List<string>>(); + //璇诲彇鎴块棿椤哄簭 + string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.RoomSortFile); + var strData = UserCenterLogic.LoadFileContent(fullName); + if (strData != null) + { + dicAllSort = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, List<string>>>(strData); + } - #region 鈼� 淇敼鍦烘櫙________________________ + var listRoomSort = new List<string>(); + if (dicAllSort.ContainsKey(i_floorKeys) == true) + { + listRoomSort = dicAllSort[i_floorKeys]; + } + else + { + dicAllSort[i_floorKeys] = listRoomSort; + } - /// <summary> - /// 淇敼鍦烘櫙璁惧 0澶辫触 1鎴愬姛 - /// </summary> - /// <returns>The scene.</returns> - /// <param name="sceneUI">Scene user interface.</param> - /// <param name="sceneRemoveMemberData">Scene remove member data.</param> - /// <param name="addCommons">Add commons.</param> - public async System.Threading.Tasks.Task<int> ModifyScene(SceneUI sceneUI, Scene.SceneRemoveMemberData sceneRemoveMemberData, List<Scene.AddSceneMemberData> addCommons) - { - if (AllRoomSceneUIList.Find(s => s.Name == sceneUI.Name) == null) - { - return 0; - } + var dicRoom = new Dictionary<string, Common.Room>(); + foreach (var room in Common.Room.Lists) + { + if (room.FloorId != i_floorKeys || room.IsLove == true) + { + //涓嶆槸鍚屼竴涓ゼ灞� + continue; + } + if (listRoomSort.Contains(room.Id) == false) + { + //鏂版坊鍔犵殑鎴块棿 + listRoomSort.Add(room.Id); + } + if (getShard == false && room.IsSharedRoom == true) + { + //涓嶈鍒嗕韩鐨勬埧闂� + continue; + } + dicRoom[room.Id] = room; + } - bool result = true; - //绉婚櫎鎴愬憳 杩斿洖缁撴灉 - var removeSceneMemberResponseAllData = await ZigBee.Device.Scene.RemoveSceneMemberAsync(sceneRemoveMemberData); - if (removeSceneMemberResponseAllData == null || removeSceneMemberResponseAllData.removeSceneMemberResponseData == null) - { - return 0; - } - var removeSceneMemberResponseData = removeSceneMemberResponseAllData.removeSceneMemberResponseData; - if (removeSceneMemberResponseData == null) - { - return 0; - } - if (removeSceneMemberResponseData.Result != 0) - { - result = false; - } - //娣诲姞 - foreach (var addCommon in addCommons) - { - //娣诲姞鏂版垚鍛� - var addSceneMemberData = new ZigBee.Device.Scene.AddSceneMemberData - { - DeviceAddr = addCommon.DeviceAddr, - Type = addCommon.Type, - Epoint = addCommon.Epoint, - ScenesId = sceneUI.Id, - TaskList = addCommon.TaskList, - DelayTime = addCommon.DelayTime, - ElseScenesId = addCommon.ElseScenesId - }; - //娣诲姞鏂版垚鍛� 杩斿洖缁撴灉 - var addSceneMemberResponseAllData = await ZigBee.Device.Scene.AddSceneMemberAsync(addSceneMemberData); - if (addSceneMemberResponseAllData == null || addSceneMemberResponseAllData.addSceneMemberResponseData == null) - { - result = false; - System.Console.WriteLine("娣诲姞鍦烘櫙澶辫触"); - continue; - } - var addSceneMemberResponseData = addSceneMemberResponseAllData.addSceneMemberResponseData; - if (addSceneMemberResponseData == null && addSceneMemberResponseData.Result != 1) - { - result = false; - } - } - //鍔犲叆鎴愬姛 - if (result) - { - sceneUI.AddSceneMemberDataList = addCommons; - sceneUI.Save(); - return 1; - } - return 0; - } + var listSortRoom = new List<Room>(); + for (int i = 0; i < listRoomSort.Count; i++) + { + if (dicRoom.ContainsKey(listRoomSort[i]) == true) + { + listSortRoom.Add(dicRoom[listRoomSort[i]]); + } + } - #endregion + //淇濆瓨椤哄簭 + UserCenterLogic.SaveFileContent(fullName, dicAllSort); + return listSortRoom; + } - #region 鈼� 鍒犻櫎鍦烘櫙________________________ + /// <summary> + /// 淇濆瓨鎴块棿鐨勯『搴� + /// </summary> + /// <param name="i_floorKeys">妤煎眰涓婚敭</param> + /// <param name="listSort">鎴块棿椤哄簭(鎴块棿鐨勪富閿�)</param> + public void SaveRoomSort(string i_floorKeys, List<string> listSort) + { + Dictionary<string, List<string>> dicAllSort = new Dictionary<string, List<string>>(); + //璇诲彇鎴块棿椤哄簭 + string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.RoomSortFile); + var strData = UserCenterLogic.LoadFileContent(fullName); + if (strData != null) + { + dicAllSort = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, List<string>>>(strData); + } - /// <summary> - /// 绉婚櫎鍦烘櫙--璇ヤ粎杩涜浜嗗鏈湴鍦烘櫙鏁版嵁鐨勫垹闄� - /// </summary> - /// <param name="sceneUI">Scene user interface.</param> - public void RemoveScene(SceneUI sceneUI) - { - if(Global.IsExistsByHomeId(sceneUI.FileName)==false) - { - return; - } - SceneUIList.Remove(sceneUI); - SceneUIFilePathList.Remove(sceneUI.FileName); - Save(); - Global.DeleteFilebyHomeId(sceneUI.FileName); - HdlAutoBackupLogic.DeleteFile(sceneUI.FileName); - HdlAutoBackupLogic.AddOrEditorFile(FileName); - } + //淇濆瓨椤哄簭 + dicAllSort[i_floorKeys] = listSort; + UserCenterLogic.SaveFileContent(fullName, dicAllSort); + dicAllSort.Clear(); + } - #endregion + /// <summary> + /// 鑾峰彇鎺掑簭鍚庣殑妤煎眰 + /// </summary> + /// <returns></returns> + public Dictionary<string, string> GetFloorSortList() + { + //璇诲彇妤煎眰椤哄簭 + var listFloorSort = new List<string>(); + string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.FloorSortFile); + var strData = UserCenterLogic.LoadFileContent(fullName); + if (strData != null) + { + listFloorSort = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>>(strData); + } + foreach (string keys in Common.Config.Instance.Home.FloorDics.Keys) + { + if (listFloorSort.Contains(keys) == false) + { + //鏂版坊鍔犵殑妤煎眰 + listFloorSort.Add(keys); + } + } - #region 鈼� 鑾峰彇鍦烘櫙________________________ + var dic = new Dictionary<string, string>(); + for (int i = 0; i < listFloorSort.Count; i++) + { + if (Config.Instance.Home.FloorDics.ContainsKey(listFloorSort[i]) == true) + { + dic[listFloorSort[i]] = Config.Instance.Home.FloorDics[listFloorSort[i]]; + } + } - /// <summary> - /// 閫氳繃鍦烘櫙id鑾峰彇鍦烘櫙 - /// </summary> - /// <returns>The scene UIB y scene identifier.</returns> - /// <param name="sceneId">Scene identifier.</param> - public SceneUI GetSceneUIBySceneId(int sceneId) - { - foreach (var r in Lists) - { - foreach (var sceneUI in r.SceneUIList) - { - if (sceneUI.Id == sceneId) - { - return sceneUI; - } - } - } - return null; - } + //淇濆瓨椤哄簭 + UserCenterLogic.SaveFileContent(fullName, listFloorSort); + return dic; + } - #endregion + /// <summary> + /// 淇濆瓨妤煎眰鐨勯『搴� + /// </summary> + /// <param name="listSort">妤煎眰鐨勪富閿�</param> + public void SaveFloorSort(List<string> listSort) + { + string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.FloorSortFile); + //淇濆瓨椤哄簭 + UserCenterLogic.SaveFileContent(fullName, listSort); + } - #region 鈼� 鍒锋柊鍦烘櫙_________________________ + #endregion - /// <summary> - /// 鍒锋柊鎴块棿鐨勫満鏅垪琛� - /// </summary> - public async System.Threading.Tasks.Task<bool> RefreshSceneUIList() - { - return false; - //System.Console.WriteLine($"寮�濮嬭姹傜綉鍏冲満鏅�****{DateTime.Now.ToString("yyMMdd hhmmss fff")}*****"); - //bool result = true; - //var sceneList = await ZigBee.Device.Scene.GetSceneListAsync(); - //System.Console.WriteLine($"缁撴潫璇锋眰缃戝叧鍦烘櫙****{DateTime.Now.ToString("yyMMdd hhmmss fff")}*****"); - //if (sceneList == null) - //{ - // return false; - //} - //List<int> sceneIDList = new List<int> { }; - //System.Console.WriteLine($"寮�濮嬫湰鍦板満鏅�****{DateTime.Now.ToString("yyMMdd hhmmss fff")}*****"); - //foreach (var scene in sceneList) - //{ - // if (scene == null) - // { - // continue; - // } - // sceneIDList.Add(scene.ScenesId); - //} - //foreach(var r in Lists) - //{ - // if(r.SceneUIList==null || r.SceneUIList.Count==0) - // { - // continue; - // } - // foreach(var rScene in r.SceneUIList) - // { - // if(rScene==null) - // { - // continue; - // } - // //var scene = sceneList.Find((obj) => rScene.ScenesId == obj.ScenesId); - // if(sceneIDList.Contains(rScene.ScenesId)==false) - // { - // var removeResult = r.SceneUIList.Remove(rScene); - // r.Save(); - // if (removeResult == false) - // { - // result = false; - // } - // } - // } - //} - //System.Console.WriteLine($"缁撴潫鏈湴鍦烘櫙****{DateTime.Now.ToString("yyMMdd hhmmss fff")}*****"); - //return result; - } + #region 鈼� 鍏嬮殕鎴块棿瀵硅薄_____________________ - #endregion + /// <summary> + /// 鍏嬮殕鎴块棿瀵硅薄 + /// </summary> + /// <returns></returns> + public Room CloneRoomClass() + { + var newRoom = new Room(); + //鍏嬮殕灞炴�� + 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; - #region 鈼� 淇濆瓨____________________________ + return newRoom; + } - /// <summary> - /// 淇濆瓨 - /// </summary> - /// <param name="autoBackup">鏄惁鑷姩澶囦唤锛岄粯璁rue</param> - public void Save(bool autoBackup = true) - { - //淇濆瓨鎴块棿淇℃伅 - Global.WriteFileByBytesByHomeId(FileName, System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this))); - if (autoBackup == true) - { - HdlAutoBackupLogic.AddOrEditorFile(FileName); - } - } - - #endregion - - #region 鈼� 妤煎眰鍜屾埧闂撮『搴忕浉鍏砡______________ - - /// <summary> - /// 鏍规嵁妤煎眰鐨勪富閿幏鍙栨帓搴忓悗鐨勬埧闂村垪琛� - /// </summary> - /// <param name="i_floorKeys">妤煎眰鐨勪富閿�</param> - /// <param name="getShard">鍒嗕韩鐨勬埧闂存槸鍚︿篃鑾峰彇</param> - /// <returns></returns> - public List<Room> GetFloorSortRoom(string i_floorKeys, bool getShard = true) - { - Dictionary<string, List<string>> dicAllSort = new Dictionary<string, List<string>>(); - //璇诲彇鎴块棿椤哄簭 - string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.RoomSortFile); - var strData = UserCenterLogic.LoadFileContent(fullName); - if (strData != null) - { - dicAllSort = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, List<string>>>(strData); - } - - var listRoomSort = new List<string>(); - if (dicAllSort.ContainsKey(i_floorKeys) == true) - { - listRoomSort = dicAllSort[i_floorKeys]; - } - else - { - dicAllSort[i_floorKeys] = listRoomSort; - } - - var dicRoom = new Dictionary<string, Common.Room>(); - foreach (var room in Common.Room.Lists) - { - if (room.FloorId != i_floorKeys || room.IsLove == true) - { - //涓嶆槸鍚屼竴涓ゼ灞� - continue; - } - if (listRoomSort.Contains(room.Id) == false) - { - //鏂版坊鍔犵殑鎴块棿 - listRoomSort.Add(room.Id); - } - if (getShard == false && room.IsSharedRoom == true) - { - //涓嶈鍒嗕韩鐨勬埧闂� - continue; - } - dicRoom[room.Id] = room; - } - - var listSortRoom = new List<Room>(); - for (int i = 0; i < listRoomSort.Count; i++) - { - if (dicRoom.ContainsKey(listRoomSort[i]) == true) - { - listSortRoom.Add(dicRoom[listRoomSort[i]]); - } - } - - //淇濆瓨椤哄簭 - UserCenterLogic.SaveFileContent(fullName, dicAllSort); - return listSortRoom; - } - - /// <summary> - /// 淇濆瓨鎴块棿鐨勯『搴� - /// </summary> - /// <param name="i_floorKeys">妤煎眰涓婚敭</param> - /// <param name="listSort">鎴块棿椤哄簭(鎴块棿鐨勪富閿�)</param> - public void SaveRoomSort(string i_floorKeys, List<string> listSort) - { - Dictionary<string, List<string>> dicAllSort = new Dictionary<string, List<string>>(); - //璇诲彇鎴块棿椤哄簭 - string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.RoomSortFile); - var strData = UserCenterLogic.LoadFileContent(fullName); - if (strData != null) - { - dicAllSort = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, List<string>>>(strData); - } - - //淇濆瓨椤哄簭 - dicAllSort[i_floorKeys] = listSort; - UserCenterLogic.SaveFileContent(fullName, dicAllSort); - dicAllSort.Clear(); - } - - /// <summary> - /// 鑾峰彇鎺掑簭鍚庣殑妤煎眰 - /// </summary> - /// <returns></returns> - public Dictionary<string, string> GetFloorSortList() - { - //璇诲彇妤煎眰椤哄簭 - var listFloorSort = new List<string>(); - string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.FloorSortFile); - var strData = UserCenterLogic.LoadFileContent(fullName); - if (strData != null) - { - listFloorSort = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>>(strData); - } - foreach (string keys in Common.Config.Instance.Home.FloorDics.Keys) - { - if (listFloorSort.Contains(keys) == false) - { - //鏂版坊鍔犵殑妤煎眰 - listFloorSort.Add(keys); - } - } - - var dic = new Dictionary<string, string>(); - for (int i = 0; i < listFloorSort.Count; i++) - { - if (Config.Instance.Home.FloorDics.ContainsKey(listFloorSort[i]) == true) - { - dic[listFloorSort[i]] = Config.Instance.Home.FloorDics[listFloorSort[i]]; - } - } - - //淇濆瓨椤哄簭 - UserCenterLogic.SaveFileContent(fullName, listFloorSort); - return dic; - } - - /// <summary> - /// 淇濆瓨妤煎眰鐨勯『搴� - /// </summary> - /// <param name="listSort">妤煎眰鐨勪富閿�</param> - public void SaveFloorSort(List<string> listSort) - { - string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.FloorSortFile); - //淇濆瓨椤哄簭 - UserCenterLogic.SaveFileContent(fullName, listSort); - } - - #endregion - - #region 鈼� 鍏嬮殕鎴块棿瀵硅薄_____________________ - - /// <summary> - /// 鍏嬮殕鎴块棿瀵硅薄 - /// </summary> - /// <returns></returns> - public Room CloneRoomClass() - { - var newRoom = new Room(); - //鍏嬮殕灞炴�� - 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; - - return newRoom; - } - - #endregion + #endregion - #region 鈼� 妤煎眰___________________________ + #region 鈼� 妤煎眰___________________________ - /// <summary> - /// 鑾峰彇妤煎眰鍚嶇О - /// </summary> - /// <param name="floorId"></param> - /// <returns></returns> - public string GetFloorNameById(string floorId) - { - if (Config.Instance.Home.FloorDics.Count == 0) - { - return null; - } + /// <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; - } + foreach (var floor in Config.Instance.Home.FloorDics) + { + if (floorId == floor.Key) + { + return floor.Value; + } + } + return null; + } - #endregion + #endregion - - } + } } diff --git a/ZigbeeApp/Shared/Phone/Device/Category/Category.cs b/ZigbeeApp/Shared/Phone/Device/Category/Category.cs index e634aee..edec647 100644 --- a/ZigbeeApp/Shared/Phone/Device/Category/Category.cs +++ b/ZigbeeApp/Shared/Phone/Device/Category/Category.cs @@ -22,7 +22,7 @@ /// <summary> /// low_High /// </summary> - private const int low_High= 127; + private const int low_High = 127; /// <summary> /// 鍔熻兘 /// </summary> @@ -547,7 +547,7 @@ { foreach (var floor in Config.Instance.Home.FloorDics) { - Config.Instance.Home.CurrentFloorId=floor.Key; + Config.Instance.Home.CurrentFloorId = floor.Key; break; } } @@ -561,7 +561,7 @@ /// <param name="selectedBtn">閫変腑閭d釜鐣岄潰 0--鍔熻兘 1--鍦烘櫙 2--鑷姩鍖� </param> public void Show(int selectedBtn = 1) { - + ZbGateway.StatusList.Add(this); RemoveAll(); @@ -664,16 +664,16 @@ var roomFL = new HorizontalScrolViewLayout() { - X= Application.GetRealWidth(CommonFormResouce.X_Left), + X = Application.GetRealWidth(CommonFormResouce.X_Left), Y = functionSceneAutoBG.Bottom, Height = Application.GetRealHeight(167), - Width=Application.GetRealWidth(CommonPage.AppRealWidth-CommonFormResouce.X_Left), + Width = Application.GetRealWidth(CommonPage.AppRealWidth - CommonFormResouce.X_Left), BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor }; midFL.AddChidren(roomFL); Button curBtn = new Button(); - for(int i=0;i<Config.Instance.Home.RoomFilePathList.Count;i++) + for (int i = 0; i < Config.Instance.Home.RoomFilePathList.Count; i++) { var roomFilePath = Config.Instance.Home.RoomFilePathList[i]; var room = Shared.Common.Room.GetRoomByFilePath(roomFilePath); @@ -683,9 +683,9 @@ } var row = new RowLayout() { - Width = Application.GetRealWidth(187+50), + Width = Application.GetRealWidth(187 + 50), Height = Application.GetRealHeight(167), - LineColor= ZigbeeColor.Current.GXCGrayBackgroundColor + LineColor = ZigbeeColor.Current.GXCGrayBackgroundColor }; roomFL.AddChidren(row); @@ -693,21 +693,22 @@ { Width = Application.GetRealWidth(187), Height = Application.GetRealHeight(78), - Radius=(uint)Application.GetRealHeight(78/2), + Radius = (uint)Application.GetRealHeight(78 / 2), Gravity = Gravity.Center, - Text=room.Name, - TextColor=ZigbeeColor.Current.GXCTextGrayColor, - SelectedTextColor=ZigbeeColor.Current.GXCTextWhiteColor, - BackgroundColor=ZigbeeColor.Current.GXCButtonUnSelectedColor3, - SelectedBackgroundColor=ZigbeeColor.Current.GXCButtonSelectedColor, - BorderColor=ZigbeeColor.Current.GXCBorderUnSelectedColor, - BorderWidth=1 + Text = room.Name, + TextColor = ZigbeeColor.Current.GXCTextGrayColor, + SelectedTextColor = ZigbeeColor.Current.GXCTextWhiteColor, + BackgroundColor = ZigbeeColor.Current.GXCButtonUnSelectedColor3, + SelectedBackgroundColor = ZigbeeColor.Current.GXCButtonSelectedColor, + BorderColor = ZigbeeColor.Current.GXCBorderUnSelectedColor, + BorderWidth = 1 }; row.AddChidren(roomBtn); - if (Shared.Common.Room.CurrentRoom==null) { + if (Shared.Common.Room.CurrentRoom == null) + { continue; } - if(Shared.Common.Room.CurrentRoom.FileName==roomFilePath) + if (Shared.Common.Room.CurrentRoom.FileName == roomFilePath) { roomBtn.IsSelected = true; curBtn = roomBtn; @@ -725,7 +726,7 @@ Shared.Common.Room.CurrentRoom = room; }; } - + //鍔熻兘鍜屽満鏅痓odyView functionSceneBodyView = new FrameLayout() @@ -776,7 +777,7 @@ addBtn.MouseUpEventHandler += AddBtn_MouseUpEventHandler; selectFloorBtn.MouseUpEventHandler += SelectedFloor_MouseUpEventHandler; - floorBtn.MouseUpEventHandler+= SelectedFloor_MouseUpEventHandler; + floorBtn.MouseUpEventHandler += SelectedFloor_MouseUpEventHandler; } @@ -787,9 +788,9 @@ /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param> private void SelectedFloor_MouseUpEventHandler(object sender, MouseEventArgs mouseEventArgs) { - var floors = new SelectFloor (); + var floors = new SelectFloor(); AddChidren(floors); - floors.Init(599,357); + floors.Init(599, 357); floors.FloorAction += (floorName) => { floorBtn.Text = floorName; @@ -941,10 +942,10 @@ { functionTypeScrowView = new HorizontalScrolViewLayout { - X=Application.GetRealWidth(CommonFormResouce.X_Left), + X = Application.GetRealWidth(CommonFormResouce.X_Left), Height = Application.GetRealHeight(279), Width = Application.GetRealWidth(1028), - BackgroundColor=ZigbeeColor.Current.GXCBackgroundColor + BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor }; functionSceneBodyView.AddChidren(functionTypeScrowView); @@ -953,13 +954,13 @@ X = Application.GetRealWidth(CommonFormResouce.X_Left), Y = functionTypeScrowView.Bottom + Application.GetRealHeight(50), Width = Application.GetRealWidth(1028), - Height = functionSceneBodyView.Height - Application.GetRealHeight(279+50) - 1, + Height = functionSceneBodyView.Height - Application.GetRealHeight(279 + 50) - 1, BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor }; functionSceneBodyView.AddChidren(deviceListScrolView); tempFunctionTypeBtn = new FunctionButton(); - + foreach (var deviceType in Common.Room.AllRoomDeviceTypeList) { typeRowLayout = new RowLayout() @@ -1003,7 +1004,7 @@ tempFunctionTypeBtn.IsSelected = false; tempFunctionTypeBtn = (typeSender as Button).Parent as FunctionButton; ((typeSender as Button).Parent as FunctionButton).IsSelected = true; - + deviceListScrolView.RemoveAll(); var sameTypeList = new List<DeviceUI> { }; @@ -1081,7 +1082,7 @@ var deviceTypeRowLayout = new RowLayout() { - Height = Application.GetRealHeight(127+35), + Height = Application.GetRealHeight(127 + 35), LineColor = ZigbeeColor.Current.GXCBackgroundColor, Tag = deviceUI }; @@ -1315,7 +1316,7 @@ }; deviceTypeRowLayout.AddRightView(delBtn); delBtn.MouseUpEventHandler += delEvent; - + } else if (deviceUI.CommonDevice.Type == ZigBee.Device.DeviceType.Thermostat) { @@ -1470,7 +1471,7 @@ deviceTypeRowLayout.AddRightView(delBtn); delBtn.MouseUpEventHandler += delEvent; - + deviceRow.SwitchBtn.MouseUpEventHandler += (sender, e) => { zbGateway = deviceUI.CommonDevice.Gateway; @@ -1505,7 +1506,7 @@ } else { - + } } } @@ -1517,10 +1518,10 @@ { var noFunction = new Button() { - Y=Application.GetRealHeight(320), - Width=Application.GetMinRealAverage(757), + Y = Application.GetRealHeight(320), + Width = Application.GetMinRealAverage(757), Height = Application.GetMinRealAverage(435), - UnSelectedImagePath="Item/NoFunction.png", + UnSelectedImagePath = "Item/NoFunction.png", Gravity = Gravity.CenterHorizontal }; functionSceneBodyView.AddChidren(noFunction); @@ -1535,7 +1536,7 @@ //Text = "娌℃湁鍔熻兘 \n 璇峰湪涓汉涓績涓�--璁惧绠$悊澶勬坊鍔�", TextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor, TextAlignment = TextAlignment.Center, - IsMoreLines=true + IsMoreLines = true }; functionSceneBodyView.AddChidren(noFunctionTip); } @@ -1565,7 +1566,7 @@ { var sceneScrolView = new VerticalScrolViewLayout { - Y=Application.GetRealHeight(58) + Y = Application.GetRealHeight(58) }; functionSceneBodyView.AddChidren(sceneScrolView); foreach (var sceneRoomUI in sceneList) @@ -1590,9 +1591,9 @@ var sceneImg = new Button() { - X=Application.GetRealWidth(179), - Width=Application.GetMinReal(844), - Height=Application.GetMinReal(400), + X = Application.GetRealWidth(179), + Width = Application.GetMinReal(844), + Height = Application.GetMinReal(400), Gravity = Gravity.CenterVertical, UnSelectedImagePath = sceneRoomUI.sceneUI.IconPath, Radius = (uint)Application.GetRealHeight(CommonFormResouce.BigFormRadius) @@ -1601,22 +1602,22 @@ var leftFL = new FrameLayout { - X=Application.GetRealWidth(CommonFormResouce.X_Left), + X = Application.GetRealWidth(CommonFormResouce.X_Left), Width = Application.GetRealWidth(251), Height = Application.GetRealHeight(282), - Gravity=Gravity.CenterVertical, + Gravity = Gravity.CenterVertical, BackgroundColor = ZigbeeColor.Current.GXCBlackBackgroundColor2 }; sceneRowLayout.AddChidren(leftFL); var collectionBtn = new Button { - X=Application.GetRealWidth(23), - Y=Application.GetRealHeight(23), - Width=Application.GetMinRealAverage(65), - Height=Application.GetMinRealAverage(65), - UnSelectedImagePath="Item/Collection.png", - SelectedImagePath="Item/CollectionSelected.png" + X = Application.GetRealWidth(23), + Y = Application.GetRealHeight(23), + Width = Application.GetMinRealAverage(65), + Height = Application.GetMinRealAverage(65), + UnSelectedImagePath = "Item/Collection.png", + SelectedImagePath = "Item/CollectionSelected.png" }; leftFL.AddChidren(collectionBtn); @@ -1627,7 +1628,7 @@ TextColor = ZigbeeColor.Current.GXCTextWhiteColor, Text = sceneRoomUI.sceneUI.Name, Gravity = Gravity.Center, - IsMoreLines=true + IsMoreLines = true }; leftFL.AddChidren(sceneNameBtn); @@ -1642,7 +1643,7 @@ //缂栬緫 var settingBtn = new Device.CommonForm.RowLayoutEditButton() { - TextID=R.MyInternationalizationString.Setting, + TextID = R.MyInternationalizationString.Setting, Tag = sceneRoomUI.sceneUI.SceneDelayTime }; //鍒犻櫎 @@ -1696,7 +1697,7 @@ var tip = new CustomAlert { }; AddChidren(tip); tip.Show(Language.StringByID(R.MyInternationalizationString.ConfirmDelete)); - + //var alert = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.ConfirmDelete), Language.StringByID(R.MyInternationalizationString.Cancel), Language.StringByID(R.MyInternationalizationString.Confrim)); //alert.Show(); tip.ResultEventHandler += async (e1) => diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/DeviceStateCondition.cs b/ZigbeeApp/Shared/Phone/Device/Logic/DeviceStateCondition.cs index 585af4d..59e67bb 100644 --- a/ZigbeeApp/Shared/Phone/Device/Logic/DeviceStateCondition.cs +++ b/ZigbeeApp/Shared/Phone/Device/Logic/DeviceStateCondition.cs @@ -1416,29 +1416,87 @@ case DeviceType.TemperatureSensor: { - + devicefra.Y = Application.GetRealHeight(1920 - 140 - 160 * 2 - 20 - 50); + devicefra.Height = Application.GetRealHeight(140 + 160 * 2 + 20 + 50); var temperatureSensor = common as TemperatureSensor; + var Btntemperaturevalue = new Button + { + TextColor = ZigbeeColor.Current.LogicBtnCancelColor, + Height = Application.GetRealHeight(60), + Width = Application.GetRealWidth(400), + TextAlignment = TextAlignment.CenterLeft, + X = Application.GetRealWidth(80), + Y = timetype.Bottom + Application.GetRealHeight(70), + }; + devicefra.AddChidren(Btntemperaturevalue); + + var horizontalSeekBarVol = new HorizontalSeekBar + { + Width = Application.GetRealWidth(920), + Height = Application.GetRealHeight(80), + Radius = (uint)Application.GetRealHeight(25), + Y = timetype.Bottom + Application.GetRealHeight(70 + 60 + 70), + X = Application.GetRealWidth(80), + ProgressColor = ZigbeeColor.Current.LogicProgressColorSelected, + Max = 100, + SleepTime = 1000, + ThumbRadius = 9, + }; + devicefra.AddChidren(horizontalSeekBarVol); + horizontalSeekBarVol.MouseUpEventHandler += (sender, e) => + { + SelectedDeviceStatuscondition = "TemperatureSensor"; + if (temperatureSensor.SensorDiv == 1) + { + dictionary(deviceConditionsInfo, "AttriButeData1", horizontalSeekBarVol.Progress.ToString()); + + Btntemperaturevalue.Text = "褰撳墠>" + horizontalSeekBarVol.Progress.ToString() + "鈩�"; + + } + else + { + Btntemperaturevalue.Text = "褰撳墠<" + horizontalSeekBarVol.Progress.ToString() + "%"; + dictionary(deviceConditionsInfo, "AttriButeData1", horizontalSeekBarVol.Progress.ToString());//娓╁害鍊� + } + }; + + + if (temperatureSensor.SensorDiv == 1) { dictionary(deviceConditionsInfo, "Cluster_ID", "1026"); dictionary(deviceConditionsInfo, "AttriButeId", "0"); - dictionary(deviceConditionsInfo, "Range", "0"); + dictionary(deviceConditionsInfo, "Range", "0");//0澶т簬AttriButeData1鏃惰Е鍙戝姩浣� dictionary(deviceConditionsInfo, "AttriButeData1", "0"); dictionary(deviceConditionsInfo, "AttriButeData2", "0"); - - + Btntemperaturevalue.Text = "褰撳墠>0鈩�"; } else { - + Btntemperaturevalue.Text = "褰撳墠<0%"; dictionary(deviceConditionsInfo, "Cluster_ID", "1029"); dictionary(deviceConditionsInfo, "AttriButeId", "0"); - dictionary(deviceConditionsInfo, "Range", "0");//琛ㄧず澶т簬鍊� + dictionary(deviceConditionsInfo, "Range", "2");//2灏忎簬AttriButeData1鏃惰Е鍙戝姩浣� dictionary(deviceConditionsInfo, "AttriButeData1", "0");//娓╁害鍊� dictionary(deviceConditionsInfo, "AttriButeData2", "0"); } + if (edit && devices != null) + { + horizontalSeekBarVol.Progress = int.Parse(devices["AttriButeData1"]); + if (temperatureSensor.SensorDiv == 1) + { + + Btntemperaturevalue.Text = "褰撳墠>" + devices["AttriButeData1"] + "鈩�"; + + } + else + { + Btntemperaturevalue.Text = "褰撳墠<" + devices["AttriButeData1"] + "%"; + } + } + } break; } diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/LogicCommunalPage.cs b/ZigbeeApp/Shared/Phone/Device/Logic/LogicCommunalPage.cs index f0a810c..d6f3727 100644 --- a/ZigbeeApp/Shared/Phone/Device/Logic/LogicCommunalPage.cs +++ b/ZigbeeApp/Shared/Phone/Device/Logic/LogicCommunalPage.cs @@ -529,7 +529,6 @@ deviceedit.MouseUpEventHandler += (sender, e) => { - if (deviceinof.Type != DeviceType.DoorLock) { var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor }; @@ -734,6 +733,25 @@ } } break; + case DeviceType.TemperatureSensor: + // conditionIcon.UnSelectedImagePath = "ZigeeLogic/temperature.png"; + var dev = deviceinof as TemperatureSensor; + if (conditions["Cluster_ID"]=="1026") { + dev.SensorDiv = 1; + } else { + dev.SensorDiv = 2; + } + if (conditions["Cluster_ID"] == "1026") + { + conditionIcon.UnSelectedImagePath = "ZigeeLogic/temperature.png"; + devicestatus.Text = ">" + conditions["AttriButeData1"] + "鈩�"; + } + else + { + conditionIcon.UnSelectedImagePath = "ZigeeLogic/humidity.png"; + devicestatus.Text = "<" + conditions["AttriButeData1"] + "%"; + } + break; } diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/LogicIfon.cs b/ZigbeeApp/Shared/Phone/Device/Logic/LogicIfon.cs index 99a78c5..5174ff6 100644 --- a/ZigbeeApp/Shared/Phone/Device/Logic/LogicIfon.cs +++ b/ZigbeeApp/Shared/Phone/Device/Logic/LogicIfon.cs @@ -1,6 +1,8 @@ 锘縰sing System; using System.Collections.Generic; using Shared; +using ZigBee.Device; + namespace Shared.Phone.Device.Logic { public class LogicIfon @@ -11,7 +13,7 @@ /// </summary> /// <param name="common">Common.</param> /// <param name="objecttype">Objecttype.</param> - public static void AddDeviceconditions(ZigBee.Device.CommonDevice common, Dictionary<string, string> objecttype) + public static void AddDeviceconditions(CommonDevice common, Dictionary<string, string> objecttype) { for (int i = 0; i < Common.Logic.CurrentLogic.Conditions.Count; i++) { @@ -19,9 +21,32 @@ { if ((Common.Logic.CurrentLogic.Conditions[i]["MacAddr"] == common.DeviceAddr) && (Common.Logic.CurrentLogic.Conditions[i]["Epoint"] == common.DeviceEpoint.ToString())) { - Common.Logic.CurrentLogic.Conditions.RemoveAt(i); - Common.Logic.CurrentLogic.Conditions.Insert(i, objecttype); - return; + if (common.Type == DeviceType.TemperatureSensor)//璁惧娓╁害浼犳劅鍣ㄦ湁鐐圭壒鍒� + { + var dev = common as TemperatureSensor; + string str = ""; + if (dev.SensorDiv == 1) + { + str = "1026"; + } + else + { + str = "1029"; + } + if (Common.Logic.CurrentLogic.Conditions[i]["Cluster_ID"] == str) + { + Common.Logic.CurrentLogic.Conditions.RemoveAt(i); + Common.Logic.CurrentLogic.Conditions.Insert(i, objecttype); + return; + } + + } + else + { + Common.Logic.CurrentLogic.Conditions.RemoveAt(i); + Common.Logic.CurrentLogic.Conditions.Insert(i, objecttype); + return; + } } } diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs old mode 100755 new mode 100644 index 6d2082c..7e67cc1 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs @@ -19,7 +19,7 @@ /// <summary> /// 鍒楄〃鎺т欢 /// </summary> - private VerticalListControl listView = null; + private VerticalScrolViewLayout listView = null; /// <summary> /// 琛屾帶浠剁殑淇℃伅(Keys锛歁ac鍦板潃) /// </summary> @@ -127,7 +127,7 @@ txtSearchControl.BindEvent(this.SetRowDataBySearchKeys); //鍒楄〃鎺т欢 - listView = new VerticalListControl(29); + listView = new VerticalScrolViewLayout(); listView.Y = txtSearchControl.Bottom + Application.GetRealHeight(29); listView.Height = frame.Height - txtSearchControl.Bottom - Application.GetRealHeight(29); frame.AddChidren(listView); @@ -208,7 +208,7 @@ rowInfo.frameTable = frameTable; //鎺т欢 - var rowMenu = new DeviceObjectControl(deviceMac, listView.rowSpace / 2); + var rowMenu = new DeviceObjectControl(deviceMac, 0); frameTable.AddChidren(rowMenu); rowMenu.InitControl(); rowInfo.MenuRow = rowMenu; -- Gitblit v1.8.0