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/LogicCommunalPage.cs | 239 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 239 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..008ae98 --- /dev/null +++ b/ZigbeeApp/Shared/Phone/Device/Logic/LogicCommunalPage.cs @@ -0,0 +1,239 @@ +锘縰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"; + } + + 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); + + EditText 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) => + { + Common.Logic.CurrentLogic.LogicName = logicTextBox.Text.Trim(); + if (Common.Logic.CurrentLogic.Conditions.Count == 1) + { + new LogicDveiceStatus { }.ConditionView(false, this); + } + 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) => + { + Common.Logic.CurrentLogic.LogicName = logicTextBox.Text.Trim(); + new LogicDveiceStatus { }.ConditionView(true, this); + }; + row.MouseUpEventHandler += editclick; + relationship.MouseUpEventHandler += editclick; + + } + new LogicDveiceStatus { }.Conditions(this, middle, ListConditions, logicTextBox.Text.Trim()); + + #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>()); + new LogicDveiceStatus { }.Actions(this, middle, ListActions, logicTextBox.Text.Trim()); + + #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); + }; + } + } +} -- Gitblit v1.8.0