New file |
| | |
| | | using 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布局代码 |
| | | 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); |
| | | }; |
| | | } |
| | | } |
| | | } |