From 6fa9d69da922c8049f5acfcbb9ce9fd26811024c Mon Sep 17 00:00:00 2001 From: xm <1271024303@qq.com> Date: 星期四, 16 四月 2020 17:10:57 +0800 Subject: [PATCH] 请合并代码 --- ZigbeeApp/Shared/Phone/Device/Logic/LogicCommunalPage.cs | 1332 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 1,332 insertions(+), 0 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/LogicCommunalPage.cs b/ZigbeeApp/Shared/Phone/Device/Logic/LogicCommunalPage.cs new file mode 100755 index 0000000..837877f --- /dev/null +++ b/ZigbeeApp/Shared/Phone/Device/Logic/LogicCommunalPage.cs @@ -0,0 +1,1332 @@ +锘縰sing System; +using System.Collections.Generic; +using Newtonsoft.Json.Linq; +using Shared; +using Shared.Common; +using Shared.Phone; +using Shared.Phone.Device.Logic.LogicView; +using Shared.R; +using ZigBee.Device; + +namespace Shared.Phone.Device.Logic +{ + public class LogicCommunalPage : FrameLayout + { + + public LogicCommunalPage() + { + UserView.HomePage.Instance.RemoveViewByTag("Logic"); + Tag = "Logic"; + } + EditText logicTextBox; + public async void Show(Action action) + { + + #region View甯冨眬浠g爜 + UserView.HomePage.Instance.ScrollEnabled = false;//閿佷綇宸︽粦 + TopView view = new TopView(); + this.AddChidren(view.TopRowView()); + if (Common.Logic.CurrentLogic.LogicId != 0) + { + view.toptitleNameBtn.Text = Language.StringByID(MyInternationalizationString.editautomation); + } + else + { + view.toptitleNameBtn.Text = Language.StringByID(MyInternationalizationString.newautomation); + } + view.clickBtn.MouseDownEventHandler += (sender, e) => + { + // UserView.HomePage.Instance.ScrollEnabled = true;//鎭㈠宸︽粦 + action(); + RemoveFromParent(); + }; + var middle = new VerticalScrolViewLayout + { + Y = view.topRowLayout.Bottom, + Height = Application.GetRealHeight(Method.H - 184-180), + BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, + }; + this.AddChidren(middle); + var saveBtn = new SaveView(); + saveBtn.frameLayout.Y = middle.Bottom; + saveBtn.frameLayout.Height = Application.GetRealHeight(180); + this.AddChidren(saveBtn.Show()); + #endregion + + #region -----鑷姩鍖栧悕绉� 璁剧疆鍚嶇О----- + var logicnamefl = new FrameLayout + { + Height = Application.GetRealHeight(130), + BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor, + }; + middle.AddChidren(logicnamefl); + + var text = new Button + { + Width = Application.GetRealWidth(300), + Height = Application.GetRealHeight(60), + X = Application.GetRealWidth(58), + TextAlignment = TextAlignment.CenterLeft, + //Text = "鑷姩鍖栧悕绉�", + TextID = MyInternationalizationString.automationname, + TextColor = ZigbeeColor.Current.LogicTextBlackColor, + Y = Application.GetRealHeight(35), + TextSize = 15, + }; + logicnamefl.AddChidren(text); + + logicTextBox = new EditText + { + Y = Application.GetRealHeight(35), + Width = Application.GetRealWidth(1080-58-300), + Height = Application.GetRealHeight(60), + X = text.Right, + TextAlignment = TextAlignment.CenterLeft, + TextColor = ZigbeeColor.Current.LogicBtnCancelColor, + TextSize = 14, + Text = Common.Logic.CurrentLogic.LogicName, + //TextID=MyInternationalizationString.automation1, + }; + logicnamefl.AddChidren(logicTextBox); + + var fraline = new FrameLayout + { + Height = Application.GetRealHeight(30), + }; + middle.AddChidren(fraline); + #endregion + + #region -----鏄剧ず閫昏緫鏉′欢----- + Addview addconditionview = new Addview(); + addconditionview.iconBtn.Visible = true; + addconditionview.titleBtn.TextID = MyInternationalizationString.ifcondition; + middle.AddChidren(addconditionview.AddDeviceView()); + + ///娣诲姞鏉′欢鐨勭偣鍑讳簨浠� + addconditionview.clickBtn.MouseUpEventHandler+= (sender, e) => + { + if (Common.Logic.CurrentLogic.Conditions.Count == 1) + { + ConditionView(false); + } + else + { + var addLogicPage = new AddLogicPage(); + UserView.HomePage.Instance.AddChidren(addLogicPage); + UserView.HomePage.Instance.PageIndex += 1; + addLogicPage.Show(); + } + }; + List<Dictionary<string, string>> ListConditions = new List<Dictionary<string, string>>(); + ListConditions.Clear(); + ListConditions.AddRange(Common.Logic.CurrentLogic.Conditions); + ListConditions.Add(new Dictionary<string, string>()); + if (Common.Logic.CurrentLogic.Conditions.Count > 1) + { + var row = new FrameLayout + { + Height = Application.GetRealHeight(60), + BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor, + }; + middle.AddChidren(row); + var relationship = new Button + { + Width = Application.GetRealWidth(600), + Height = Application.GetRealHeight(60), + TextAlignment = TextAlignment.CenterLeft, + X = Application.GetRealWidth(58), + TextColor = ZigbeeColor.Current.LogicBtnCompleteColor, + }; + row.AddChidren(relationship); + if (Common.Logic.CurrentLogic.Relationship == 0) + { + relationship.Text = Language.StringByID(MyInternationalizationString.followingconditions) + Language.StringByID(MyInternationalizationString.Allconditions); + } + else + { + relationship.Text = Language.StringByID(MyInternationalizationString.followingconditions) + Language.StringByID(MyInternationalizationString.anycondition); + } + EventHandler<MouseEventArgs> editclick = (sender, e) => + { + + ConditionView(true); + }; + row.MouseUpEventHandler += editclick; + relationship.MouseUpEventHandler += editclick; + + } + for (int i = 0; i < ListConditions.Count; i++) + { + if (i == (ListConditions.Count - 1)) + { + LogicView.AddDeviceView addflview = new LogicView.AddDeviceView(); + addflview.titleBtn.TextID = MyInternationalizationString.addconditions; + middle.AddChidren(addflview.AddFl()); + addflview.clickBtn.MouseUpEventHandler += (sender, e) => + { + if (Common.Logic.CurrentLogic.Conditions.Count == 1) + { + ConditionView(false); + } + else + { + var addLogicPage = new AddLogicPage(); + UserView.HomePage.Instance.AddChidren(addLogicPage); + UserView.HomePage.Instance.PageIndex += 1; + addLogicPage.Show(); + } + }; + } + else + { + SelectedDeviceView selecteddevice = new SelectedDeviceView(); + selecteddevice.Show(middle); + selecteddevice.stateRow.AddRightView(selecteddevice.edit); + selecteddevice.stateRow.AddRightView(selecteddevice.del); + + var Type = int.Parse(ListConditions[i]["Type"]); + var conditions = ListConditions[i]; + string name = ""; + string icon = ""; + string state = ""; + switch (Type) + { + /// (0:鏃堕棿鐐规潯浠�;1:璁惧鐘舵�佸彉鍖栨潯浠�;2:鍏朵粬閫昏緫鏉′欢;3:璁℃暟鍣ㄦ潯浠�;4:鍊掕鏃�;5:鏃堕棿娈垫潯浠�;6:瀹夐槻鏉′欢;7:鍦扮悊浣嶇疆) + case 0: + { + + //"0姝e父鏃堕棿鐐�","1鏃ュ嚭鏃堕棿","2鏃ヨ惤鏃堕棿","3姝e崍鏃堕棿" + switch (int.Parse(conditions["DateType"])) + { + case 0: + { + name = Language.StringByID(MyInternationalizationString.immediateexecution); + icon = "ZigeeLogic/timepoint.png"; + string s = ""; + s = conditions["StartMin"].Length < 2 ? "0" + conditions["StartMin"] : conditions["StartMin"]; + state = conditions["StartHour"] + ":" + s; + + } + break; + case 1: + { + name = Language.StringByID(MyInternationalizationString.sunrise); + icon = "ZigeeLogic/sunrise.png"; + if (int.Parse(conditions["AdjustTime"]) > 0) + { + state = Language.StringByID(MyInternationalizationString.delayed) + conditions["AdjustTime"] + Language.StringByID(MyInternationalizationString.logicminute); + } + else if (int.Parse(conditions["AdjustTime"]) < 0) + { + state = Language.StringByID(MyInternationalizationString.advance) + Math.Abs(int.Parse(conditions["AdjustTime"])).ToString() + Language.StringByID(MyInternationalizationString.logicminute); + } + else + { + //timeTxet.Text = Language.StringByID(MyInternationalizationString.sunrise); + } + } + break; + case 2: + { + name = Language.StringByID(MyInternationalizationString.sunset); + icon = "ZigeeLogic/sunset.png"; + if (int.Parse(conditions["AdjustTime"]) > 0) + { + state = Language.StringByID(MyInternationalizationString.delayed) + conditions["AdjustTime"] + Language.StringByID(MyInternationalizationString.logicminute); + } + else if (int.Parse(conditions["AdjustTime"]) < 0) + { + state = Language.StringByID(MyInternationalizationString.advance) + Math.Abs(int.Parse(conditions["AdjustTime"])).ToString() + Language.StringByID(MyInternationalizationString.logicminute); + } + else + { + // timevalue.Text = Language.StringByID(MyInternationalizationString.sunset); + } + } + break; + case 3: + { + name = Language.StringByID(MyInternationalizationString.noon); + icon = "ZigeeLogic/noon.png"; + if (int.Parse(conditions["AdjustTime"]) > 0) + { + state = Language.StringByID(MyInternationalizationString.delayed) + conditions["AdjustTime"] + Language.StringByID(MyInternationalizationString.logicminute); + } + else if (int.Parse(conditions["AdjustTime"]) < 0) + { + state = Language.StringByID(MyInternationalizationString.advance) + Math.Abs(int.Parse(conditions["AdjustTime"])).ToString() + Language.StringByID(MyInternationalizationString.logicminute); + } + else + { + // timeTxet.Text = Language.StringByID(MyInternationalizationString.noon); + } + } + break; + } + + } + break; + case 5: + { + icon = "ZigeeLogic/timeparagraph.png"; + string s1 = "", s2 = ""; + s1 = conditions["StartMin"].Length < 2 ? "0" + conditions["StartMin"] : conditions["StartMin"]; + s2 = conditions["StopMin"].Length < 2 ? "0" + conditions["StopMin"] : conditions["StopMin"]; + ///鏄剧ず鏃堕棿 + name = conditions["StartHour"] + ":" + s1 + "-" + conditions["StopHour"] + ":" + s2; + state =Language.StringByID(MyInternationalizationString.timeframe); + } + break; + case 1: + { + var deviceinof = Method.GetCommonDevice(conditions["MacAddr"], conditions["Epoint"]); + name = LocalDevice.Current.GetDeviceEpointName(deviceinof); + selecteddevice.regionNameBtn.Visible = true; + Method.RoomNmae(selecteddevice.regionNameBtn, deviceinof); + + switch (deviceinof.Type) + { + case DeviceType.OnOffOutput: + { + icon = "ZigeeLogic/light.png"; + if (conditions["AttriButeId"] == "0") + { + if (conditions["AttriButeData1"] == "1") + { + state = Language.StringByID(MyInternationalizationString.open); + } + else + { + state = Language.StringByID(MyInternationalizationString.close); + } + + } + } + break; + case DeviceType.IASZone: + { + var iASZonedevice = deviceinof as IASZone; + var intvalue = conditions["AttriButeData1"]; + icon = $"ZigeeLogic/sensor{iASZonedevice.IasDeviceType}.png"; + switch (iASZonedevice.IasDeviceType) + { + case 13: + { + if (intvalue == "1") + { + state=Language.StringByID( MyInternationalizationString.someone); + } + else + { + int minute = int.Parse(conditions["IgnoreTime"]) / 60; + int second = int.Parse(conditions["IgnoreTime"]) % 60; + if (minute != 0 && second != 0) + { + state = minute.ToString() + Language.StringByID(MyInternationalizationString.minute) + second.ToString() + Language.StringByID(MyInternationalizationString.second) + Language.StringByID(MyInternationalizationString.unattendedtime1); + + } + else + { + if (minute == 0 && second != 0) + { + state = second.ToString() + Language.StringByID(MyInternationalizationString.second) + Language.StringByID(MyInternationalizationString.unattendedtime1); + + } + if (minute != 0 && second == 0) + { + state = minute.ToString() + Language.StringByID(MyInternationalizationString.Minute) + Language.StringByID(MyInternationalizationString.unattendedtime1); + + } + + } + } + } + break; + case 21: + case 22: + { + if (intvalue == "1") + { + state =Language.StringByID( MyInternationalizationString.logicopen); + } + else + { + if (conditions.ContainsKey("IgnoreTime")) + { + + int minute = int.Parse(conditions["IgnoreTime"]) / 60; + int second = int.Parse(conditions["IgnoreTime"]) % 60; + if (minute != 0 && second != 0) + { + state = minute.ToString() + Language.StringByID(MyInternationalizationString.minute) + second.ToString() + Language.StringByID(MyInternationalizationString.second) + Language.StringByID(MyInternationalizationString.closetime); + + } + else + { + if (minute == 0 && second != 0) + { + state = second.ToString() + Language.StringByID(MyInternationalizationString.second) + Language.StringByID(MyInternationalizationString.closetime); + + } + if (minute != 0 && second == 0) + { + state = minute.ToString() + Language.StringByID(MyInternationalizationString.Minute) + Language.StringByID(MyInternationalizationString.closetime); + + } + + } + + } + else + { + state =Language.StringByID(MyInternationalizationString.logicclose); + } + } + } + break; + case 40: + { + if (intvalue == "1") + { + state =Language.StringByID(MyInternationalizationString.smokescreen); + } + + } + break; + case 42: + { + if (intvalue == "1") + { + state =Language.StringByID( MyInternationalizationString.waterleakage); + } + else + { + state =Language.StringByID( MyInternationalizationString.noleakage); + } + } + break; + case 43: + { + if (intvalue == "1") + { + state =Language.StringByID( MyInternationalizationString.gas); + } + + } + break; + case 277: + { + if (intvalue == "1") + { + state =Language.StringByID( MyInternationalizationString.callthepolice); + } + + } + break; + default: + { + if (intvalue == "1") + { + state =Language.StringByID(MyInternationalizationString.callthepolice); + } + } + break; + + } + } + break; + case DeviceType.OnOffSwitch: + { + icon = "ZigeeLogic/panel.png"; + state = Language.StringByID(MyInternationalizationString.OnOffSwitch) + conditions["Epoint"]; + } + break; + case DeviceType.DoorLock: + { + icon = "ZigeeLogic/doorlock.png"; + for (int a = 0; a < Common.Logic.CurrentLogic.Accounts.Count; a++) + { + if (Common.Logic.CurrentLogic.Accounts[a]["Type"] == "1") + { + if (Common.Logic.CurrentLogic.Accounts[a]["UserId"] == conditions["AttriButeData2"]) + { + state = Common.Logic.CurrentLogic.Accounts[a]["AccountName"]; + break; + + } + } + + } + } + 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; + } + string s = ""; + switch (conditions["Range"]) + { + case "0": + { + s = ">"; + } + break; + case "1": + { + s = "="; + } + break; + case "2": + { + s = "<"; + } + break; + case "6": + { + s = "鈮�"; + } + break; + case "7": + { + s = "鈮�"; + } + break; + } + if (conditions["Cluster_ID"] == "1026") + { + icon = "ZigeeLogic/temperature.png"; + state = s + conditions["AttriButeData1"] + "鈩�"; + } + else + { + icon = "ZigeeLogic/humidity.png"; + state = s + conditions["AttriButeData1"] + "%"; + } + break; + + } + + } + } + break; + case 6: + { + switch (conditions["EnOrWithdrawMode"]) + { + case "0": + { + if (conditions["ModeId"] == "1") + { + icon = "ZigeeLogic/athome.png"; + name = Language.StringByID(MyInternationalizationString.logicathomegarrison); + + } + else + { + icon = "ZigeeLogic/leavehome.png"; + name = Language.StringByID(MyInternationalizationString.logicremovehomegarrison); + } + } + break; + case "1": + { + icon = "ZigeeLogic/withdrawal.png"; + name = Language.StringByID(MyInternationalizationString.withdrawal); + } + break; + case "2": + { + icon = "ZigeeLogic/withdrawal.png"; + name = Language.StringByID(MyInternationalizationString.urgentwithdrawal); + } + break; + } + } + break; + case 7: + { + icon = "ZigeeLogic/position.png"; + name = Language.StringByID(MyInternationalizationString.geographicalposition); + foreach (var radius in Common.Logic.CurrentLogic.Accounts) + { + if (radius["Type"] == "7") + { + if (conditions["AtHome"] == "1") + { + state = Language.StringByID(MyInternationalizationString.athome) + radius["Radius"] + "绫�"; + } + else + { + state = Language.StringByID(MyInternationalizationString.leavehome) + radius["Radius"] + "绫�"; + } + } + } + } + break; + } + if (Type != 1) + { + selecteddevice.ordinaryBtn.Visible = true; + selecteddevice.iconBtn.UnSelectedImagePath = icon; + selecteddevice.ordinaryBtn.Text = name; + selecteddevice.selecetddevicestateBtn.Text = state; + } + else + { + //璁惧鐘舵�� + selecteddevice.deviceNameBtn.Visible = true; + selecteddevice.iconBtn.UnSelectedImagePath = icon; + selecteddevice.deviceNameBtn.Text = name; + selecteddevice.selecetddevicestateBtn.Text = state; + } + ///缂栬緫 + selecteddevice.edit.MouseUpEventHandler += (sender, e) => + { + switch (Type) + { + + /// (0:鏃堕棿鐐规潯浠�;1:璁惧鐘舵�佸彉鍖栨潯浠�;2:鍏朵粬閫昏緫鏉′欢;3:璁℃暟鍣ㄦ潯浠�;4:鍊掕鏃�;5:鏃堕棿娈垫潯浠�;6:瀹夐槻鏉′欢;7:鍦扮悊浣嶇疆) + case 0: + { + var timePoint = new TimePoint(); + UserView.HomePage.Instance.AddChidren(timePoint); + UserView.HomePage.Instance.PageIndex += 1; + timePoint.IsEditor = true; + timePoint.Show(conditions); + } + break; + case 5: + { + var timePage = new TimePage(); + UserView.HomePage.Instance.AddChidren(timePage); + UserView.HomePage.Instance.PageIndex += 1; + timePage.str1 = conditions["StartHour"] + ":" + conditions["StartMin"] + "-" + conditions["StopHour"] + ":" + conditions["StopMin"]; + timePage.IsEditor = true; + timePage.Show(); + } + break; + case 1: + { + var deviceinof = Method.GetCommonDevice(conditions["MacAddr"], conditions["Epoint"]); + if (deviceinof.Type != DeviceType.DoorLock) + { + var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor }; + this.AddChidren(flMain); + CurrentDeviceState.CurrentDeviceView(flMain, deviceinof, true, "condition_logic"); + } + else + { + var memberList = new MemberList(); + UserView.HomePage.Instance.AddChidren(memberList); + UserView.HomePage.Instance.PageIndex += 1; + MemberList.edit = true; + memberList.Show(deviceinof, conditions); + } + } + break; + case 6: + { + var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor }; + this.AddChidren(flMain); + AddLogicPage.SecurityView(flMain, true); + } + break; + case 7: + { + var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor }; + this.AddChidren(flMain); + AddLogicPage.LocationView(flMain, true); + } + break; + } + }; + ///鍒犻櫎鎺т欢 + selecteddevice.del.MouseUpEventHandler += (sender, e) => + { + + var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Confirm, + Language.StringByID(MyInternationalizationString.doyouwanttodelete), + Language.StringByID(MyInternationalizationString.confrim)); + alert.Show(); + + alert.ConfirmClickEvent += () => + { + Common.Logic.CurrentLogic.Conditions.Remove(conditions); + selecteddevice.selecetdFrameLayout.RemoveFromParent(); + //var logicCommunalPage = new LogicCommunalPage(); + //UserView.HomePage.Instance.AddChidren(logicCommunalPage); + //UserView.HomePage.Instance.PageIndex += 1; + //logicCommunalPage.Show(() => { }); + }; + + }; + + } + } + + + #endregion + + #region ----鏄剧ず鎵ц鐩爣---- + + Addview addactionview = new Addview(); + addactionview.iconBtn.Visible = true; + addactionview.titleBtn.TextID = MyInternationalizationString.execute; + middle.AddChidren(addactionview.AddDeviceView()); + + addactionview.clickBtn.MouseUpEventHandler+= (sender, e) => + { + Common.Logic.CurrentLogic.LogicName = logicTextBox.Text.Trim(); + Method.View(IfString.Action_Logic,IfString.Action_LogicScene); + }; + + List<Dictionary<string, object>> ListActions = new List<Dictionary<string, object>>(); + ListActions.Clear(); + ListActions.AddRange(Common.Logic.CurrentLogic.Actions); + ListActions.Add(new Dictionary<string, object>()); + + for (int i = 0; i < ListActions.Count; i++) + { + if (i == (ListActions.Count - 1)) + { + + LogicView.AddDeviceView addflview = new LogicView.AddDeviceView(); + addflview.titleBtn.TextID = MyInternationalizationString.addfunction; + middle.AddChidren(addflview.AddFl()); + addflview.clickBtn.MouseUpEventHandler += (sender, e) => + { + Common.Logic.CurrentLogic.LogicName = logicTextBox.Text.Trim(); + Method.View(IfString.Action_Logic, IfString.Action_LogicScene); + }; + } + else + { + + SelectedDeviceView actiondevice = new SelectedDeviceView(); + actiondevice.Show(middle); + var linkType = int.Parse(ListActions[i]["LinkType"].ToString()); + var actions = ListActions[i]; + string name = ""; + string icon = ""; + string state = ""; + + switch (linkType) + { + case 0: + case 8: + { + + var deviceinof = Method.GetCommonDevice(actions["DeviceAddr"].ToString(), actions["Epoint"].ToString()); + name = LocalDevice.Current.GetDeviceEpointName(deviceinof); + actiondevice.regionNameBtn.Visible = true; + Method.RoomNmae(actiondevice.regionNameBtn, deviceinof); + switch (deviceinof.Type) + { + case DeviceType.OnOffOutput: + { + icon = "ZigeeLogic/light.png"; + + var TaskList = actions["TaskList"] as List<Dictionary<string, string>>; + if (TaskList == null) + { + continue; + } + foreach (var status in TaskList) + { + if (status["TaskType"].ToString() == "1") + { + if (status["Data1"].ToString() == "0") + { + state = Language.StringByID(MyInternationalizationString.close); + + } + else if (status["Data1"].ToString() == "1") + { + state = Language.StringByID(MyInternationalizationString.open); + + } + else if (status["Data1"].ToString() == "2") + { + + state = Language.StringByID(MyInternationalizationString.onoff); + } + } + + } + + } + break; + case DeviceType.DimmableLight: + { + icon = "ZigeeLogic/dimmableLight.png"; + var TaskList = actions["TaskList"] as List<Dictionary<string, string>>; + if (TaskList == null) + { + continue; + } + foreach (var status in TaskList) + { + if (status["TaskType"].ToString() == "3") + { + var intvalue = int.Parse(status["Data1"]); + var lightbrightnessvalue = (intvalue * 100) / 254; + state = lightbrightnessvalue.ToString() + "%"; + } + else if (status["TaskType"].ToString() == "1") + { + + if (status["Data1"].ToString() == "0") + { + state = Language.StringByID(MyInternationalizationString.close); + } + else if (status["Data1"].ToString() == "2") + { + state = Language.StringByID(MyInternationalizationString.onoff); + } + } + + + } + + } + break; + case DeviceType.WindowCoveringDevice: + { + icon = "ZigeeLogic/curtain.png"; + var TaskList = actions["TaskList"] as List<Dictionary<string, string>>; + if (TaskList == null) + { + continue; + } + foreach (var status in TaskList) + { + if (status["TaskType"] == "6") + { + if (status["Data1"] == "0") + { + state = Language.StringByID(MyInternationalizationString.open); + } + else if (status["Data1"] == "1") + { + state = Language.StringByID(MyInternationalizationString.close); + } + else if (status["Data1"] == "5") + { + state = status["Data2"] + "%"; + } + } + + } + } + break; + case DeviceType.AirSwitch: + { + icon = "ZigeeLogic/airswitch.png"; + + var TaskList = actions["TaskList"] as List<Dictionary<string, string>>; + if (TaskList == null) + { + continue; + } + foreach (var status in TaskList) + { + if (status["TaskType"].ToString() == "1") + { + if (status["Data1"].ToString() == "0") + { + state = Language.StringByID(MyInternationalizationString.close); + + } + else if (status["Data1"].ToString() == "1") + { + state = Language.StringByID(MyInternationalizationString.open); + + } + else if (status["Data1"].ToString() == "2") + { + + state = Language.StringByID(MyInternationalizationString.onoff); + } + } + + } + + } + break; + case DeviceType.Thermostat: + { + icon = "ZigeeLogic/ac.png"; + + var TaskList = actions["TaskList"] as List<Dictionary<string, string>>; + if (TaskList == null) + { + continue; + } + string modetext = "", temperaturetext = "", speedtext = ""; + bool ifclose = false; + foreach (var status in TaskList) + { + + if (TaskList.Count == 1) + { + //鏁扮粍鍙湁涓�涓厓绱犺鏄庡綋鍓嶇┖璋冪姸鎬佷负鍏筹紱 + ifclose = false; + //濡傛灉绌鸿皟鐘舵�佹槸鍏筹紱鐩存帴璺冲嚭for寰潖锛� + break; + } + else + { + ifclose = true; + } + if (status["TaskType"].ToString() == "5") + { + if (status["Data1"] == "3") + {//3---璁剧疆宸ヤ綔妯″紡(1:鑷姩;3:鍒跺喎;4:鍒剁儹;7:閫侀;8:闄ゆ箍) + switch (status["Data2"]) + { + case "3": + { + modetext = Language.StringByID(MyInternationalizationString.logiccool); + } + break; + case "4": + { + modetext = Language.StringByID(MyInternationalizationString.logicheat); + } + break; + case "1": + { + modetext = Language.StringByID(MyInternationalizationString.logicauto); + } + break; + case "8": + { + modetext = Language.StringByID(MyInternationalizationString.logicdry); + } + break; + case "7": + { + modetext = Language.StringByID(MyInternationalizationString.logicfanonly); + } + break; + } + } + else if (status["Data1"] == "6") + {//6---璁剧疆椋庢墖妯″紡(1:浣庨;2:涓;3:楂橀;) + switch (status["Data2"]) + { + case "1": + { + speedtext = Language.StringByID(MyInternationalizationString.logiclow); + } + break; + + case "2": + { + speedtext = Language.StringByID(MyInternationalizationString.logicmedium); + } + break; + case "3": + { + speedtext = Language.StringByID(MyInternationalizationString.logichigh); + } + break; + + } + } + //4---璁剧疆鍔犵儹搴︽暟;5---璁剧疆鍒跺喎銆侀櫎婀垮害鏁�;7---璁剧疆鑷姩搴︽暟 + else if (status["Data1"] == "4" || status["Data1"] == "5" || status["Data1"] == "7") + { + var s = int.Parse(status["Data2"]) / 100; + temperaturetext = s.ToString(); + } + else if (status["Data1"] == "20") + { + temperaturetext = "鏃�"; + } + + + } + + } + if (ifclose) + { + state = modetext + ";" + temperaturetext + "鈩�;" + speedtext; + } + else + { + state = Language.StringByID(MyInternationalizationString.close); + + } + } + break; + case DeviceType.DoorLock: + { + //闂ㄩ攣鐗规畩 + icon = "ZigeeLogic/doorlock.png"; + if (actions["PassData"].ToString() == "055704010112") + { + state = Language.StringByID(MyInternationalizationString.logicopen); + } + else + { + state = Language.StringByID(MyInternationalizationString.logicclose); + } + } + break; + } + + } + break; + case 2: + { + //鍦ㄦ湰鍦版煡鎵捐鍦烘櫙; + var sceneinof = UserCenter.HdlSceneLogic.Current.GetSceneUIBySceneId(Convert.ToInt32(actions["DeviceAddr"].ToString())); + //鏈湴娌℃湁瀛樺湪; + if (sceneinof == null) + { + //瀹炵幇鐩殑:鏄剧ず鍑烘潵璁╁彲浠ヨ嚜宸辨槸鍚﹀垹闄� + sceneinof = new SceneUI(); + #region -------- + ////鍦ㄧ綉鍏虫煡鎵捐鍦烘櫙; + ////鏍囪闂:缃戠粶璇锋眰锛屽瓨鍦ㄨ鍥惧姞杞藉揩鎱㈢殑闂锛� + //sceneinof = await Send.GetScene(int.Parse(actions["DeviceAddr"].ToString())); + ////缃戝叧娌℃湁瀛樺湪; + //if (sceneinof == null) + //{ + // //娉ㄨВ:鏈湴鍜岀綉鍏抽兘涓嶅瓨鍦ㄨ鍦烘櫙,鐣岄潰灏嗕笉浼氭樉绀鸿鍦烘櫙; + // //sceneinof = new SceneUI(); + // //绉婚櫎璇ュ満鏅暟鎹�; + // Common.Logic.CurrentLogic.Actions.Remove(actions); + // //绉婚櫎璇ュ満鏅鍥�; + // devicesFrameLayout.RemoveFromParent(); + // continue; + //} + #endregion + } + + icon = "ZigeeLogic/scene.png"; + name = sceneinof.Name; + actiondevice.regionNameBtn.Visible = true; + /////閫氳繃璁惧鎵惧埌鍖哄煙(鎴块棿)鍚嶇О + Common.Room room = new Common.Room(); + actiondevice.regionNameBtn.Text = UserCenter.HdlRoomLogic.Current.GetRoomNameBySceneId(sceneinof.Id); + + } + break; + case 6: + { + + + + if (actions["SecuritySetting"].ToString() == "0") + { + if (actions["Password"].ToString() == "888888") + { + icon = "ZigeeLogic/withdrawal.png"; + state = Language.StringByID(MyInternationalizationString.urgentwithdrawal); + } + else + { + icon = "ZigeeLogic/withdrawal.png"; + state = Language.StringByID(MyInternationalizationString.withdrawal); + + } + } + else if (actions["SecuritySetting"].ToString() == "1") + { + if (actions["SecurityModeId"].ToString() == "1") + { + icon = "ZigeeLogic/athome.png"; + state = Language.StringByID(MyInternationalizationString.logicathomegarrison); + } + else if (actions["SecurityModeId"].ToString() == "2") + { + icon = "ZigeeLogic/leavehome.png"; + state = Language.StringByID(MyInternationalizationString.logicremovehomegarrison); + } + } + + } + break; + case 7: + { + var delaytimevalue = int.Parse(actions["DelayTime"].ToString()); + var Minutes = delaytimevalue / 60; + var seconds = delaytimevalue % 60; + + icon = "ZigeeLogic/delay.png"; + + if (Minutes != 0) + { + if (seconds == 0) + { + state = Minutes.ToString() + Language.StringByID(MyInternationalizationString.minute); + } + else + { + state = Minutes.ToString() + Language.StringByID(MyInternationalizationString.minute) + seconds.ToString() + Language.StringByID(MyInternationalizationString.second); + } + } + else + { + state = seconds.ToString() + Language.StringByID(MyInternationalizationString.second); + } + //璁板綍寤舵椂锛� + actiondevice.edit.Tag = i; + }; + break; + } + + if (linkType != 2) + { + actiondevice.stateRow.AddRightView(actiondevice.edit); + } + actiondevice.stateRow.AddRightView(actiondevice.del); + + if (linkType == 6 || linkType == 7) + { + actiondevice.ordinaryBtn.Visible = true; + actiondevice.iconBtn.UnSelectedImagePath = icon; + actiondevice.ordinaryBtn.Text = name; + actiondevice.selecetddevicestateBtn.Text = state; + } + else + { + //璁惧鐘舵�� + actiondevice.deviceNameBtn.Visible = true; + actiondevice.iconBtn.UnSelectedImagePath = icon; + actiondevice.deviceNameBtn.Text = name; + actiondevice.selecetddevicestateBtn.Text = state; + } + ///缂栬緫 + actiondevice.edit.MouseUpEventHandler += (sender, e) => + { + switch (linkType) + { + case 8: + case 0: + { + var deviceinof = Method.GetCommonDevice(actions["DeviceAddr"].ToString(), actions["Epoint"].ToString()); + var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor }; + this.AddChidren(flMain); + CurrentDeviceState.CurrentDeviceView(flMain, deviceinof, true, "action_logic"); + } + break; + case 6: + { + var securityMode = new SecurityMode(); + UserView.HomePage.Instance.AddChidren(securityMode); + UserView.HomePage.Instance.PageIndex += 1; + securityMode.IsDeviceEditor = true; + securityMode.Show(); + } + break; + case 7: + { + var delayTime = new DelayTime(); + UserView.HomePage.Instance.AddChidren(delayTime); + UserView.HomePage.Instance.PageIndex += 1; + delayTime.Show(int.Parse(actiondevice.edit.Tag.ToString()), true); + } + break; + + } + }; + ///鍒犻櫎鎺т欢 + actiondevice.del.MouseUpEventHandler += (sender, e) => + { + + var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Confirm, + Language.StringByID(MyInternationalizationString.doyouwanttodelete), + Language.StringByID(MyInternationalizationString.confrim)); + alert.Show(); + alert.ConfirmClickEvent += () => + { + Common.Logic.CurrentLogic.Actions.Remove(actions); + actiondevice.selecetdFrameLayout.RemoveFromParent(); + // devicesFrameLayout.RemoveFromParent(); + //var logicCommunalPage = new LogicCommunalPage(); + //UserView.HomePage.Instance.AddChidren(logicCommunalPage); + //UserView.HomePage.Instance.PageIndex += 1; + //logicCommunalPage.Show(() => { }); + }; + + }; + } + } + + #endregion + + #region -----姣忓ぉ 璁剧疆鍛ㄦ湡----- + + var fraline1 = new FrameLayout + { + Height = Application.GetRealHeight(30), + }; + middle.AddChidren(fraline1); + + Addview weekview = new Addview(); + weekview.iconBtn.Visible = true; + weekview.iconBtn.UnSelectedImagePath = "ZigeeLogic/next.png"; + weekview.titleBtn.TextID = MyInternationalizationString.setupcycle; + middle.AddChidren(weekview.AddDeviceView()); + var weekBtn = new Button + { + Width = Application.GetRealWidth(595), + Height = Application.GetRealHeight(60), + TextAlignment = TextAlignment.CenterRight, + //Text = "姣忓ぉ", + TextColor = ZigbeeColor.Current.LogicBtnCancelColor, + TextID = MyInternationalizationString.everyday, + Y = Application.GetRealHeight(35+30), + X = weekview.titleBtn.Right, + TextSize = 14, + }; + weekview.frameLayout.AddChidren(weekBtn); + Method.UpdateWeek(weekBtn,Common.Logic.CurrentLogic); + EventHandler<MouseEventArgs> cycleclick = (sender, e) => + { + /*------淇濈暀姣忔湀,姣忓勾绫诲瀷*/ + var cycle = new Cycle(() => { Method.UpdateWeek(weekBtn, Common.Logic.CurrentLogic);}); + UserView.HomePage.Instance.AddChidren(cycle); + UserView.HomePage.Instance.PageIndex += 1; + cycle.Show(); + + //var cyclicCycle = new CyclicCycle(() => { UpdateWeek(btnweektext); }); + //UserView.HomePage.Instance.AddChidren(cyclicCycle); + //UserView.HomePage.Instance.PageIndex += 1; + //cyclicCycle.Show(); + }; + weekBtn.MouseUpEventHandler += cycleclick; + weekview.clickBtn.MouseUpEventHandler += cycleclick; + #endregion + + #region ----鎺ㄩ�佽缃�---- + Method.Push(middle); + + #endregion + + saveBtn.clickviewBtn.MouseUpEventHandler +=(sender, e) => + { + var name = logicTextBox.Text.Trim(); + Method.SaveLogic(IfString._Logic,name, IfString.Tag, Common.Logic.CurrentLogic); + }; + } + + void ConditionView(bool edit) + { + Common.Logic.CurrentLogic.LogicName = logicTextBox.Text.Trim(); + #region ------缁勫悎鏉′欢鐣岄潰甯冨眬閮ㄥ垎 + var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicTranslucentColor }; + this.AddChidren(flMain); + CompleteView completeView = new CompleteView(); + flMain.AddChidren(completeView.Show(2)); + completeView.Btntitle.TextID = MyInternationalizationString.condition; + EventHandler<MouseEventArgs> clickcancel = (sender, e) => + { + UserView.HomePage.Instance.ScrollEnabled = true; + flMain.RemoveFromParent(); + }; + flMain.MouseUpEventHandler += clickcancel; + completeView.Btncancel.MouseUpEventHandler += clickcancel; + + //婊¤冻鎵�鏈夋潯浠� + mFunView allFunView = new mFunView(); + allFunView.frameLayout.Y = Application.GetRealHeight(140 + 20); + completeView.Show(2).AddChidren(allFunView.Show()); + allFunView.titleBtn.TextID = MyInternationalizationString.Allconditions; + //婊¤冻鍏朵腑涓�涓潯浠� + mFunView ormFunview = new mFunView(); + ormFunview.frameLayout.Y = allFunView.frameLayout.Bottom; + completeView.Show(2).AddChidren(ormFunview.Show()); + ormFunview.titleBtn.TextID = MyInternationalizationString.anycondition; + ormFunview.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor; + #endregion + + ///婊¤冻鎵�鏈夋潯浠剁偣鍑讳簨浠� + allFunView.clickviewBtn.MouseUpEventHandler += (sedner, e) => + { + allFunView.selectedIconBtn.Visible = true; + ormFunview.selectedIconBtn.Visible = false; + allFunView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor; + ormFunview.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor; + }; + ///婊¤冻鍏朵腑涓�涓潯浠剁偣鍑讳簨浠� + ormFunview.clickviewBtn.MouseUpEventHandler += (sedner, e) => + { + allFunView.selectedIconBtn.Visible = false; + ormFunview.selectedIconBtn.Visible = true; + allFunView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor; + ormFunview.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor; + }; + + if (edit) + { + if (Common.Logic.CurrentLogic.Relationship == 0) + { + allFunView.selectedIconBtn.Visible = true; + ormFunview.selectedIconBtn.Visible = false; + allFunView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor; + ormFunview.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor; + } + else + { + allFunView.selectedIconBtn.Visible = false; + ormFunview.selectedIconBtn.Visible = true; + allFunView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor; + ormFunview.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor; + } + } + completeView.Btncomplete.MouseUpEventHandler += (sender, e) => + { + if (!allFunView.selectedIconBtn.Visible && !ormFunview.selectedIconBtn.Visible) + { + ///鍙互鎻愮ず鏈�変腑鐘舵�侊紱 + return; + } + flMain.RemoveFromParent(); + + if (allFunView.selectedIconBtn.Visible) + { + Common.Logic.CurrentLogic.Relationship = 0; + + } + if (ormFunview.selectedIconBtn.Visible) + { + Common.Logic.CurrentLogic.Relationship = 1; + + } + if (edit) + { + if (Common.Logic.CurrentLogic.LogicId != 0) + { + Send.LogicControlSwitch(Common.Logic.CurrentLogic); + } + var logicCommunalPage = new LogicCommunalPage(); + UserView.HomePage.Instance.AddChidren(logicCommunalPage); + UserView.HomePage.Instance.PageIndex += 1; + logicCommunalPage.Show(() => { }); + } + else + { + var addLogicPage = new AddLogicPage(); + UserView.HomePage.Instance.AddChidren(addLogicPage); + UserView.HomePage.Instance.PageIndex += 1; + addLogicPage.Show(); + } + }; + + } + + + } +} -- Gitblit v1.8.0