From 94e4e5b9fd3da964c44b7b14227d6fe2bbb426d7 Mon Sep 17 00:00:00 2001 From: WJC <wjc@hdlchina.com.cn> Date: 星期四, 02 四月 2020 13:56:39 +0800 Subject: [PATCH] 2020-04-02-2 --- ZigbeeApp/Shared/Phone/Device/Logic/Method.cs | 148 ++++++++++++++++++++++++++++++++++++------------- 1 files changed, 108 insertions(+), 40 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/Method.cs b/ZigbeeApp/Shared/Phone/Device/Logic/Method.cs index 7aecfbb..ee8afb3 100644 --- a/ZigbeeApp/Shared/Phone/Device/Logic/Method.cs +++ b/ZigbeeApp/Shared/Phone/Device/Logic/Method.cs @@ -21,8 +21,7 @@ /// <param name="device">Device.</param> public static void RoomNmae(Button button, CommonDevice device) { - var room = new Common.Room(); - button.Text = room.GetRoomNameByDevice(device); + button.Text = UserCenter.HdlRoomLogic.Current.GetRoomNameByDevice(device); } /// <summary> /// 杩斿洖妤煎眰鎵�鏈夌殑鎴块棿鐨勫垪琛� @@ -33,11 +32,12 @@ public static List<Common.Room> GetRoomList(string type, string floorId = null) { var list = new List<Common.Room>(); - for (int i = 0; i < Common.Room.Lists.Count; i++) + var listAllRoom = UserCenter.HdlRoomLogic.Current.GetAllListRooms(); + for (int i = 0; i < listAllRoom.Count; i++) { if (type == "action_logicscene" || type == "action_lockscene") { - if (Common.Room.Lists[i].SceneUIList.Count == 0) + if (listAllRoom[i].ListSceneId.Count == 0) { ///杩囨护鎺夋病鏈夊満鏅殑鎴块棿 continue; } @@ -46,14 +46,14 @@ { ///鍖哄垎鍑鸿緭鍏ユ潯浠跺拰杈撳嚭鐩爣璁惧 var listdevicetype = GetDevice(type); - var listdevice = GetDeviceUIList(Common.Room.Lists[i], listdevicetype); + var listdevice = GetDeviceUIList(listAllRoom[i], listdevicetype); if (listdevice.Count == 0) { ///杩囨护鎺夋病鏈夎澶囩殑鎴块棿 continue; } } - list.Add(Common.Room.Lists[i]); + list.Add(listAllRoom[i]); } if (string.IsNullOrEmpty(floorId)) { @@ -69,16 +69,17 @@ /// <param name="room">褰撳墠鎴块棿</param> /// <param name="deviceTypelist">璁惧绫诲瀷</param> /// <returns></returns> - public static List<DeviceUI> GetDeviceUIList(Common.Room room, List<DeviceType> deviceTypelist) + public static List<CommonDevice> GetDeviceUIList(Common.Room room, List<DeviceType> deviceTypelist) { - var deviceUIlist = new List<DeviceUI>(); - foreach (var device in room.DeviceUIList) + var deviceUIlist = new List<CommonDevice>(); + foreach (var deviceKey in room.ListDevice) { - if (device.CommonDevice == null) + var device = LocalDevice.Current.GetDevice(deviceKey); + if (device == null) { continue; } - if (!deviceTypelist.Contains(device.CommonDevice.Type)) + if (!deviceTypelist.Contains(device.Type)) { //杩囨护鎺変笉鏀寔鐨勮澶� continue; @@ -90,47 +91,53 @@ /// <summary> /// 鎺掑垪鎵�鏈夎澶囩被鍨嬬殑鍒楄〃 /// </summary> - /// <param name="type">鍒ゆ柇瀛楃涓�</param> /// <param name="devicelist">璁惧鍒楄〃</param> /// <returns></returns> - public static List<string> GetDeviceTypeList(string type, List<DeviceUI> devicelist) + public static List<string> GetDeviceTypeList(List<CommonDevice> devicelist) { List<string> devicetypelist = new List<string>(); devicetypelist.Clear(); - var lightjosn = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.ColorDimmableLight || device.CommonDevice.Type == DeviceType.OnOffOutput); + + var lightjosn = devicelist.Find((device) => device.Type == DeviceType.DimmableLight || device.Type == DeviceType.OnOffOutput); if (lightjosn != null) { devicetypelist.Add(Language.StringByID(MyInternationalizationString.Lights)); } - var iASZonejosn = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.IASZone || device.CommonDevice.Type == DeviceType.TemperatureSensor); - if (iASZonejosn != null) - { - devicetypelist.Add(Language.StringByID(MyInternationalizationString.sensor)); - } - var onOffSwitchjson = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.OnOffSwitch); - if (onOffSwitchjson != null) - { - devicetypelist.Add(Language.StringByID(MyInternationalizationString.OnOffSwitch)); - } - var doorLock = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.DoorLock); - if (doorLock != null) - { - devicetypelist.Add(Language.StringByID(MyInternationalizationString.doorLock)); - } - var curtainjosn = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.WindowCoveringDevice); + + var curtainjosn = devicelist.Find((device) => device.Type == DeviceType.WindowCoveringDevice); if (curtainjosn != null) { devicetypelist.Add(Language.StringByID(MyInternationalizationString.Curtains)); } - var ac = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.Thermostat); + + var ac = devicelist.Find((device) => device.Type == DeviceType.Thermostat); if (ac != null) { devicetypelist.Add(Language.StringByID(MyInternationalizationString.AC)); } - var airSwitch = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.AirSwitch); + + var onOffSwitchjson = devicelist.Find((device) => device.Type == DeviceType.OnOffSwitch); + if (onOffSwitchjson != null) + { + devicetypelist.Add(Language.StringByID(MyInternationalizationString.OnOffSwitch)); + } + + var doorLock = devicelist.Find((device) => device.Type == DeviceType.DoorLock); + if (doorLock != null) + { + devicetypelist.Add(Language.StringByID(MyInternationalizationString.doorLock)); + } + + var airSwitch = devicelist.Find((device) => device.Type == DeviceType.AirSwitch); if (airSwitch != null) { devicetypelist.Add(Language.StringByID(MyInternationalizationString.Airswitch)); + } + + var iASZonejosn = devicelist.Find((device) => device.Type == DeviceType.IASZone || device.Type == DeviceType.TemperatureSensor); + if (iASZonejosn != null) + { + devicetypelist.Add(Language.StringByID(MyInternationalizationString.sensor)); } return devicetypelist; @@ -224,11 +231,11 @@ /// </summary> /// <param name="device">璁惧瀵硅薄</param> /// <param name="button">鏄剧ず鍥炬爣鐨勬帶浠�</param> - public static void GetDeviceIcon(DeviceUI device, Button button) + public static void GetDeviceIcon(CommonDevice device, Button button) { string patm = ""; string selectedpatm = ""; - switch (device.CommonDevice.Type) + switch (device.Type) { case DeviceType.OnOffOutput: { @@ -238,7 +245,7 @@ break; case DeviceType.IASZone: { - var iASZonedevice = device.CommonDevice as IASZone; + var iASZonedevice = device as IASZone; if (iASZonedevice.DeviceID != 1026) { break; @@ -249,7 +256,7 @@ break; case DeviceType.TemperatureSensor: { - var temperatureSensor = device.CommonDevice as TemperatureSensor; + var temperatureSensor = device as TemperatureSensor; if (temperatureSensor.SensorDiv == 1) { patm = $"ZigeeLogic/temperature.png"; @@ -325,12 +332,16 @@ } break; case "action_logic": - { //鑷姩鍖栨敮鎸佺殑鐩爣璁惧 + { + + //鑷姩鍖栨敮鎸佺殑鐩爣璁惧 deviceTypeList.Add(DeviceType.OnOffOutput); deviceTypeList.Add(DeviceType.DimmableLight); deviceTypeList.Add(DeviceType.WindowCoveringDevice); deviceTypeList.Add(DeviceType.Thermostat); deviceTypeList.Add(DeviceType.AirSwitch); + ///闂ㄩ攣鐗规畩 + // deviceTypeList.Add(DeviceType.DoorLock); } break; case "condition_mould": @@ -351,6 +362,8 @@ deviceTypeList.Add(DeviceType.WindowCoveringDevice); deviceTypeList.Add(DeviceType.Thermostat); deviceTypeList.Add(DeviceType.AirSwitch); + ///闂ㄩ攣鐗规畩 + // deviceTypeList.Add(DeviceType.DoorLock); } break; @@ -648,6 +661,7 @@ custompushview.iconBtn.Visible = true; custompushview.iconBtn.UnSelectedImagePath = "ZigeeLogic/next.png"; custompushview.titleBtn.TextID = MyInternationalizationString.custompush; + custompushview.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor; middle.AddChidren(custompushview.AddDeviceView()); EventHandler<MouseEventArgs> customclick = (sender, e) => @@ -668,6 +682,7 @@ LogicView.IfString.Tag = true; custompushview.frameLayout.Height = Application.GetRealHeight(160); Common.Logic.CurrentLogic.LogicIsCustomPushText = 1; + pushview.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicRowLayoutLineColor; } else @@ -675,6 +690,7 @@ LogicView.IfString.Tag = false; custompushview.frameLayout.Height = Application.GetRealHeight(0); Common.Logic.CurrentLogic.LogicIsCustomPushText = 0; + pushview.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor; } Send.Zj(LogicView.IfString.Tag, Common.Logic.CurrentLogic); }; @@ -684,12 +700,14 @@ LogicView.IfString.Tag = false; pushview.switchBtn.IsSelected = false; custompushview.frameLayout.Height = Application.GetRealHeight(0); + pushview.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor; } else { LogicView.IfString.Tag = true; pushview.switchBtn.IsSelected = true; custompushview.frameLayout.Height = Application.GetRealHeight(160); + pushview.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicRowLayoutLineColor; } } /// <summary> @@ -701,6 +719,16 @@ /// <param name="CurrentLogic">褰撳墠閫昏緫</param> public async static void SaveLogic(string if_logic, string name, bool tag, Common.Logic CurrentLogic) { + + if (CurrentLogic.Conditions.Count == 0 || CurrentLogic.Actions.Count == 0) + { + var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Normal, + Language.StringByID(MyInternationalizationString.addnull), + Language.StringByID(MyInternationalizationString.confrim)); + alert.Show(); + return; + } + if (string.IsNullOrEmpty(name)) { var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Normal, @@ -729,7 +757,17 @@ { succeed = true; CurrentLogic.LogicId = logicifon.LogicId; - Common.Logic.LogicList.Add(CurrentLogic); + if (LogicView.IfString._LockLogic == if_logic) + { + //闂ㄩ攣鑱斿姩浜嬩欢閫昏緫鍒楄〃 + Common.Logic.LockLogicList.Add(CurrentLogic); + } + else + { + //鑷姩鍖栭�昏緫鍒楄〃 + Common.Logic.LogicList.Add(CurrentLogic); + + } if (tag) { Send.Zj(tag, CurrentLogic); @@ -754,13 +792,29 @@ //TipView("娣诲姞鑷姩鍖栧け璐�"); //return; } - UserView.HomePage.Instance.RemoveViewByTag("Logic"); + + if (LogicView.IfString._Logic == if_logic) { - Category.Category.instance?.RefreshBodyView(); + UserView.HomePage.Instance.RemoveViewByTag("Logic"); + if (CurrentLogic.LogicType == 0) + { + //鍙埛鏂板垎绫讳笂涓嬫粦鍔╲iew锛� + Phone.Category.CategoryMainForm.instance?.RefreshBodyView(); + // Category.Category.instance?.RefreshBodyView(); + } + else if (CurrentLogic.LogicType == 2) + { + //鍒锋柊鏁翠釜鍒嗙被锛� + //闂ㄩ攣甯稿紑妯″紡鐗规畩; + UserView.UserPage.Instance.ShowCategoryAutoListForm(); + + } } else if (LogicView.IfString._LockLogic == if_logic) { + UserView.HomePage.Instance.RemoveViewByTag("Logic");//绉婚櫎鎵�鏈夋爣璁癓ogic鐣岄潰 + UserView.HomePage.Instance.RemoveViewByTag("LockListView");//绉婚櫎鎵�鏈夋爣璁癓ockListView鐣岄潰 var doorLockLogicList = new DoorLockLogic.LockLogicList(); UserView.HomePage.Instance.AddChidren(doorLockLogicList); UserView.HomePage.Instance.PageIndex += 1; @@ -768,6 +822,20 @@ } } + /// <summary> + /// 璺冲叆杈撳嚭鐩爣鍔熻兘鐣岄潰鐨勬柟娉� + /// </summary> + /// <param name="str1">璁惧鐣岄潰璇嗗埆瀛楃涓�</param> + /// <param name="str2">鍦烘櫙鐣岄潰璇嗗埆瀛楃涓�</param> + public static void View(string str1, string str2) + { + var deviceTarget = new DeviceTarget(); + UserView.HomePage.Instance.AddChidren(deviceTarget); + UserView.HomePage.Instance.PageIndex += 1; + deviceTarget.Show(str1, str2); + } + + } } -- Gitblit v1.8.0