From d6fb0646531172f23648441c224cdcccd721b894 Mon Sep 17 00:00:00 2001 From: xm <1271024303@qq.com> Date: 星期一, 14 十二月 2020 09:59:01 +0800 Subject: [PATCH] 请合并代码,完成晾衣架最终功能。 --- ZigbeeApp/Shared/Phone/Device/Logic/OneLogic.cs | 444 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 444 insertions(+), 0 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/OneLogic.cs b/ZigbeeApp/Shared/Phone/Device/Logic/OneLogic.cs new file mode 100755 index 0000000..437e22b --- /dev/null +++ b/ZigbeeApp/Shared/Phone/Device/Logic/OneLogic.cs @@ -0,0 +1,444 @@ +锘縰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 OneLogic : FrameLayout + { + + public OneLogic() + { + UserView.HomePage.Instance.RemoveViewByTag("Logic"); + Tag = "Logic"; + } + /// <summary> + /// S-one闂ㄩ攣鐗规畩鐣岄潰 + /// </summary> + /// <param name="Yes"></param> + public void Show(bool Yes) + { + #region View甯冨眬浠g爜 + UserView.HomePage.Instance.ScrollEnabled = false; + TopView view = new TopView(); + this.AddChidren(view.TopRowView()); + + if (Yes) + { + view.toptitleNameBtn.Text = Language.StringByID(MyInternationalizationString.look); + } + else + { + 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;//鎭㈠宸︽粦 + 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); + + var 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); + if (Yes) + { + //S-one闂ㄩ攣鐗规畩,涓嶈兘鍐嶆缂栬緫; + logicTextBox.Enable = false; + } + var fraline = new FrameLayout + { + Height = Application.GetRealHeight(30), + }; + middle.AddChidren(fraline); + #endregion + + #region -----鏄剧ず閫昏緫鏉′欢----- + Addview addconditionview = new Addview(); + addconditionview.iconBtn.Visible = false; + addconditionview.titleBtn.TextID = MyInternationalizationString.ifcondition; + middle.AddChidren(addconditionview.AddDeviceView()); + + ///娣诲姞鏉′欢鐨勭偣鍑讳簨浠� + for (int i = 0; i < Common.Logic.CurrentLogic.Conditions.Count; i++) + { + SelectedDeviceView selecteddevice = new SelectedDeviceView(); + selecteddevice.Show(middle); + if (!Yes) + { + //S-one闂ㄩ攣鐗规畩,涓嶈兘鍐嶆缂栬緫; + selecteddevice.stateRow.AddRightView(selecteddevice.edit); + } + var Type = int.Parse(Common.Logic.CurrentLogic.Conditions[i]["Type"]); + var conditions = Common.Logic.CurrentLogic.Conditions[i]; + switch (Type) + { + case 0: + { + + //"0姝e父鏃堕棿鐐�","1鏃ュ嚭鏃堕棿","2鏃ヨ惤鏃堕棿","3姝e崍鏃堕棿" + switch (int.Parse(conditions["DateType"])) + { + case 0: + { + selecteddevice.ordinaryBtn.Text = Language.StringByID(MyInternationalizationString.immediateexecution); + selecteddevice.iconBtn.UnSelectedImagePath = "ZigeeLogic/timepoint.png"; + string s = ""; + s = conditions["StartMin"].Length < 2 ? "0" + conditions["StartMin"] : conditions["StartMin"]; + selecteddevice.selecetddevicestateBtn.Text= conditions["StartHour"] + ":" + s; + } + break; + } + + } + break; + } + if (Yes) + { + //鏀瑰彉瀛椾綋棰滆壊; + selecteddevice.ordinaryBtn.TextColor = ZigbeeColor.Current.LogicBtnCancelColor; + selecteddevice.selecetddevicestateBtn.TextColor = ZigbeeColor.Current.LogicBtnCancelColor; + } + ///缂栬緫 + selecteddevice.edit.MouseUpEventHandler += (sender, e) => + { + if (Type == 0) + { + var oneTimePoint = new OneTimePoint(); + UserView.HomePage.Instance.AddChidren(oneTimePoint); + UserView.HomePage.Instance.PageIndex += 1; + oneTimePoint.Show((timeString) => + { + if (!string.IsNullOrEmpty(timeString)) + { + //缂栬緫瀹屽洖鏉ュ厛鏇存柊鏃堕棿 + selecteddevice.selecetddevicestateBtn.Text = timeString; + } + }); + } + }; + + } + #endregion + + #region ----鏄剧ず鎵ц鐩爣---- + Addview addactionview = new Addview(); + addactionview.iconBtn.Visible = false; + addactionview.titleBtn.TextID = MyInternationalizationString.execute; + middle.AddChidren(addactionview.AddDeviceView()); + + for (int i = 0; i < Common.Logic.CurrentLogic.Actions.Count; i++) + { + SelectedDeviceView actiondevice = new SelectedDeviceView(); + actiondevice.Show(middle); + if (!Yes) + { + //S-one闂ㄩ攣鐗规畩,涓嶈兘鍐嶆缂栬緫; + actiondevice.stateRow.AddRightView(actiondevice.edit); + } + var linkType = int.Parse(Common.Logic.CurrentLogic.Actions[i]["LinkType"].ToString()); + var actions = Common.Logic.CurrentLogic.Actions[i]; + switch (linkType) + { + case 8: + { + //S-one闂ㄩ攣鐗规畩锛圡ac鏄敮涓�鐨勮瘑鍒級 + ///濡傛灉涓嶈繖鏍锋煡鎵撅紝鍒嗙被-鑷姩鍖栬繘鏉ユ煡鐪嬩細瀛樺湪闂 + var deviceinof = Common.Logic.LogicDviceList.Find((obj) => { return obj.DeviceAddr == actions["DeviceAddr"].ToString(); }); + if (deviceinof == null) + { + deviceinof = new CommonDevice(); + } + actiondevice.deviceNameBtn.Text = LocalDevice.Current.GetDeviceEpointName(deviceinof); + actiondevice.deviceNameBtn.Visible = true; + actiondevice.regionNameBtn.Visible = true; + Method.RoomNmae(actiondevice.regionNameBtn, deviceinof); + + if (Yes) { + //鏀瑰彉瀛椾綋棰滆壊; + actiondevice.deviceNameBtn.TextColor = ZigbeeColor.Current.LogicBtnCancelColor; + actiondevice.regionNameBtn.TextColor = ZigbeeColor.Current.LogicBtnCancelColor; + actiondevice.selecetddevicestateBtn.TextColor = ZigbeeColor.Current.LogicBtnCancelColor; + } + switch (deviceinof.Type) + { + case DeviceType.DoorLock: + { + //闂ㄩ攣鐗规畩 + actiondevice.iconBtn.UnSelectedImagePath = "ZigeeLogic/doorlock.png"; + if (actions["PassData"].ToString() == "055704010112") + { + actiondevice.selecetddevicestateBtn.Text = Language.StringByID(MyInternationalizationString.logicopen); + } + else + { + actiondevice.selecetddevicestateBtn.Text = Language.StringByID(MyInternationalizationString.logicclose); + } + } + break; + } + + } + break; + + } + ///缂栬緫 + actiondevice.edit.MouseUpEventHandler += (sender, e) => + { + switch (linkType) + { + case 8: + { + //S-one闂ㄩ攣鐗规畩锛圡ac鏄敮涓�鐨勮瘑鍒級 + ///濡傛灉涓嶈繖鏍锋煡鎵撅紝鍒嗙被-鑷姩鍖栬繘鏉ユ煡鐪嬩細瀛樺湪闂 + var deviceinof = Common.Logic.LogicDviceList.Find((obj) => { return obj.DeviceAddr == actions["DeviceAddr"].ToString(); }); + if (deviceinof == null) + { + deviceinof = new CommonDevice(); + } + DevcieView(deviceinof, actiondevice.selecetddevicestateBtn); + }; + break; + + + } + }; + + } + #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) => + { + if (Yes) { + //S-one闂ㄩ攣鐗规畩,涓嶈兘鍐嶆缂栬緫; + return; + } + var cycle = new Cycle(() => { Method.UpdateWeek(weekBtn, Common.Logic.CurrentLogic); }); + UserView.HomePage.Instance.AddChidren(cycle); + UserView.HomePage.Instance.PageIndex += 1; + cycle.Show(); + }; + weekBtn.MouseUpEventHandler += cycleclick; + weekview.clickBtn.MouseUpEventHandler += cycleclick; + if (Yes) + { + //鏀瑰彉瀛椾綋棰滆壊; + weekBtn.TextColor = ZigbeeColor.Current.LogicBtnCancelColor; + logicTextBox.TextColor = ZigbeeColor.Current.LogicBtnCancelColor; + } + #endregion + + #region ----鎺ㄩ�佽缃�---- + Method.Push(middle); + #endregion + + saveBtn.clickviewBtn.MouseUpEventHandler += (sender, e) => + { + if (Yes) + { + //S-one闂ㄩ攣鐗规畩,涓嶈兘鍐嶆缂栬緫; + RemoveFromParent(); + return; + } + var name = logicTextBox.Text.Trim(); + Method.SaveLogic(IfString._SoneLogic, name, IfString.Tag, Common.Logic.CurrentLogic); + }; + + } + /// <summary> + /// 閫変腑璇ヤ綔涓烘潯浠舵垨鑰呯洰鏍囩殑瑙嗗浘鏂规硶 + /// </summary> + /// <param name="common">Common.</param> + void DevcieView( CommonDevice common,Button button) + { + #region -------鐣岄潰甯冨眬閮ㄥ垎 + //涓嶈褰撳墠鐣岄潰婊戝姩 + UserView.HomePage.Instance.ScrollEnabled = false; + var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor }; + this.AddChidren(flMain); + CompleteView completeView = new CompleteView(); + flMain.AddChidren(completeView.Show(1)); + // completeView.Btntitle.Text =LocalDevice.Current.GetDeviceEpointName(common); + completeView.Btntitle.TextID = MyInternationalizationString.openmode; + EventHandler<MouseEventArgs> clickcancel = (sender, e) => + { + flMain.RemoveFromParent(); + }; + flMain.MouseUpEventHandler += clickcancel; + completeView.Btncancel.MouseUpEventHandler += clickcancel; + + mFunView openView = new mFunView(); + openView.frameLayout.Y = Application.GetRealHeight(140 + 20); + completeView.Show(2).AddChidren(openView.Show()); + openView.titleBtn.TextID = MyInternationalizationString.logicopen; + + mFunView closeView = new mFunView(); + closeView.frameLayout.Y = Application.GetRealHeight(140 + 20 + 160); + closeView.frameLayout.Y = openView.frameLayout.Bottom; + completeView.Show(2).AddChidren(closeView.Show()); + closeView.titleBtn.TextID = MyInternationalizationString.logicclose; + closeView.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor; + #endregion + + + Dictionary<string, object> actionsInfo = new Dictionary<string, object>(); + actionsInfo.Add("LinkType", 8); + actionsInfo.Add("DeviceAddr", common.DeviceAddr); + actionsInfo.Add("Epoint","200"); + string SelectedDeviceStatus = ""; + switch (common.Type) + { + case DeviceType.DoorLock: + { + openView.clickviewBtn.MouseUpEventHandler += (sender, e) => + { + openView.selectedIconBtn.Visible = true; + closeView.selectedIconBtn.Visible = false; + openView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor; + closeView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor; + SelectedDeviceStatus = Language.StringByID(MyInternationalizationString.logicopen); + if (actionsInfo.ContainsKey("PassData")) + { + actionsInfo.Remove("PassData"); + } + actionsInfo.Add("PassData", "055704010112");//闂ㄩ攣甯稿紑 + }; + ///鐐瑰嚮鍙栨秷浜嬩欢 + closeView.clickviewBtn.MouseUpEventHandler += (sender, e) => + { + openView.selectedIconBtn.Visible = false; + closeView.selectedIconBtn.Visible = true; + openView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor; + closeView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor; + SelectedDeviceStatus = Language.StringByID(MyInternationalizationString.logicclose); + if (actionsInfo.ContainsKey("PassData")) + { + actionsInfo.Remove("PassData"); + } + actionsInfo.Add("PassData", "055704010113");//闂ㄩ攣甯稿叧 + + }; + + if (button.Text == Language.StringByID(MyInternationalizationString.logicopen)) + { + //寮�鍚� + SelectedDeviceStatus = Language.StringByID(MyInternationalizationString.logicopen); + openView.selectedIconBtn.Visible = true; + closeView.selectedIconBtn.Visible = false; + openView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor; + closeView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor; + + } + else { + //鍏抽棴 + SelectedDeviceStatus = Language.StringByID(MyInternationalizationString.logicclose); + openView.selectedIconBtn.Visible = false; + closeView.selectedIconBtn.Visible = true; + openView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor; + closeView.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor; + } + + } + break; + + } + + + completeView.Btncomplete.MouseUpEventHandler += (sender, e) => + { + if (!string.IsNullOrEmpty(SelectedDeviceStatus)) + { + LogicIfon.AddDoorLockActions(common, actionsInfo); + button.Text = SelectedDeviceStatus; + } + + flMain.RemoveFromParent(); + + }; + } + } +} -- Gitblit v1.8.0