old mode 100644
new mode 100755
| | |
| | | using Shared; |
| | | using Shared.Common; |
| | | using Shared.Phone; |
| | | using Shared.Phone.Device.Logic.LogicView; |
| | | using Shared.R; |
| | | using ZigBee.Device; |
| | | |
| | |
| | | UserView.HomePage.Instance.RemoveViewByTag("Logic"); |
| | | Tag = "Logic"; |
| | | } |
| | | EditText logicTextBox; |
| | | public void Show(Action action) |
| | | |
| | | public async void Show(Action action) |
| | | { |
| | | |
| | | this.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor; |
| | | |
| | | var topFrameLayout1 = new FrameLayout |
| | | #region View布局代码 |
| | | UserView.HomePage.Instance.ScrollEnabled = false;//锁住左滑 |
| | | TopView view = new TopView(); |
| | | this.AddChidren(view.TopRowView()); |
| | | if (Common.Logic.CurrentLogic.LogicId != 0) |
| | | { |
| | | Height = Application.GetRealHeight(80), |
| | | BackgroundColor = ZigbeeColor.Current.LogicTopViewBackgroundColor, |
| | | }; |
| | | AddChidren(topFrameLayout1); |
| | | |
| | | var topFrameLayout = new FrameLayout |
| | | { |
| | | Height = Application.GetRealHeight(140), |
| | | Y = Application.GetRealHeight(80), |
| | | BackgroundColor = ZigbeeColor.Current.LogicTopViewBackgroundColor, |
| | | }; |
| | | AddChidren(topFrameLayout); |
| | | |
| | | var titleName = new Button |
| | | { |
| | | |
| | | TextSize = 17, |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | X = Application.GetRealWidth(150), |
| | | }; |
| | | topFrameLayout.AddChidren(titleName); |
| | | if (Common.Logic.CurrentLogic.LogicId == 1) |
| | | { |
| | | titleName.Text = Language.StringByID(MyInternationalizationString.editautomation); |
| | | view.toptitleNameBtn.Text = Language.StringByID(MyInternationalizationString.editautomation); |
| | | } |
| | | else |
| | | { |
| | | titleName.Text = Language.StringByID(MyInternationalizationString.newautomation); |
| | | view.toptitleNameBtn.Text = Language.StringByID(MyInternationalizationString.newautomation); |
| | | } |
| | | |
| | | var back = new Button |
| | | view.clickBtn.MouseDownEventHandler += (sender, e) => |
| | | { |
| | | Width = Application.GetRealWidth(110), |
| | | Height = Application.GetRealHeight(110), |
| | | X = Application.GetRealWidth(20), |
| | | Gravity = Gravity.CenterVertical, |
| | | UnSelectedImagePath = "ZigeeLogic/Back.png", |
| | | }; |
| | | topFrameLayout.AddChidren(back); |
| | | back.MouseDownEventHandler += (sender, e) => |
| | | { |
| | | //if (Common.Logic.CurrentLogic.LogicId != 0) |
| | | //{ |
| | | // Common.Logic.CurrentLogic.LogicName = logicTextBox.Text.Trim(); |
| | | // action(); |
| | | // Send.AddModifyLogic(Common.Logic.CurrentLogic); |
| | | //} |
| | | // UserView.HomePage.Instance.ScrollEnabled = true;//恢复左滑 |
| | | action(); |
| | | RemoveFromParent(); |
| | | }; |
| | | |
| | | |
| | | var middle = new VerticalScrolViewLayout(); |
| | | middle.Y = topFrameLayout.Bottom; |
| | | middle.Height = Application.GetRealHeight(1920 - 220 - 194); |
| | | middle.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor; |
| | | var middle = new VerticalScrolViewLayout |
| | | { |
| | | Y = view.topRowLayout.Bottom, |
| | | Height = Application.GetRealHeight(Method.H - 184 - 180), |
| | | BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, |
| | | }; |
| | | this.AddChidren(middle); |
| | | |
| | | var fl = new FrameLayout |
| | | { |
| | | Height = Application.GetRealHeight(280), |
| | | BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor, |
| | | }; |
| | | middle.AddChidren(fl); |
| | | |
| | | #region -----每天 设置周期----- |
| | | var weekfl = new FrameLayout |
| | | { |
| | | Height = Application.GetRealHeight(140), |
| | | Y = Application.GetRealHeight(20), |
| | | }; |
| | | fl.AddChidren(weekfl); |
| | | |
| | | var btnweektext = new Button |
| | | { |
| | | Width = Application.GetRealWidth(900 - 300), |
| | | Height = Application.GetRealHeight(70), |
| | | X = Application.GetRealWidth(140 + 300), |
| | | TextAlignment = TextAlignment.CenterRight, |
| | | //Text = "每天", |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | TextID = MyInternationalizationString.everyday, |
| | | }; |
| | | weekfl.AddChidren(btnweektext); |
| | | var settxet = new Button |
| | | { |
| | | Width = Application.GetRealWidth(900 - 500), |
| | | Height = Application.GetRealHeight(70), |
| | | X = Application.GetRealWidth(140 + 500), |
| | | TextAlignment = TextAlignment.CenterRight, |
| | | Y = btnweektext.Bottom, |
| | | //Text = "设置周期", |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | TextID = MyInternationalizationString.setupcycle, |
| | | }; |
| | | weekfl.AddChidren(settxet); |
| | | |
| | | UpdateWeek(btnweektext); |
| | | |
| | | EventHandler<MouseEventArgs> cycleclick = (sender, e) => |
| | | { |
| | | /*------保留每月,每年类型*/ |
| | | //var cycle = new Cycle(() => { UpdateWeek(btnweektext); }); |
| | | //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(); |
| | | }; |
| | | btnweektext.MouseUpEventHandler += cycleclick; |
| | | settxet.MouseUpEventHandler += cycleclick; |
| | | 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(140), |
| | | Y = weekfl.Bottom, |
| | | //BackgroundColor=0xff453736, |
| | | Height = Application.GetRealHeight(130), |
| | | BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor, |
| | | }; |
| | | fl.AddChidren(logicnamefl); |
| | | middle.AddChidren(logicnamefl); |
| | | |
| | | var text = new Button |
| | | { |
| | | Width = Application.GetRealWidth(600), |
| | | Width = Application.GetRealWidth(300), |
| | | Height = Application.GetRealHeight(60), |
| | | X = Application.GetRealWidth(50), |
| | | X = Application.GetRealWidth(58), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | //Text = "自动化名称", |
| | | TextID = MyInternationalizationString.automationname, |
| | | TextColor = ZigbeeColor.Current.LogicViewBackgroundColor, |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | Y = Application.GetRealHeight(35), |
| | | TextSize = 15, |
| | | }; |
| | | logicnamefl.AddChidren(text); |
| | | |
| | | logicTextBox = new EditText |
| | | EditText logicTextBox = new EditText |
| | | { |
| | | Width = Application.GetRealWidth(900), |
| | | Y = Application.GetRealHeight(35), |
| | | Width = Application.GetRealWidth(1080 - 58 - 300), |
| | | Height = Application.GetRealHeight(60), |
| | | X = Application.GetRealWidth(40 + 20), |
| | | Y = text.Bottom + Application.GetRealHeight(10), |
| | | X = text.Right, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | TextSize=13, |
| | | Text =Common.Logic.CurrentLogic.LogicName, |
| | | TextColor = ZigbeeColor.Current.LogicBtnCancelColor, |
| | | TextSize = 14, |
| | | Text = Common.Logic.CurrentLogic.LogicName, |
| | | //TextID=MyInternationalizationString.automation1, |
| | | }; |
| | | logicnamefl.AddChidren(logicTextBox); |
| | | |
| | | var btnline = new Button |
| | | |
| | | var fraline = new FrameLayout |
| | | { |
| | | Height = Application.GetRealHeight(4), |
| | | Y = Application.GetRealHeight(140 - 4), |
| | | BackgroundColor = ZigbeeColor.Current.LogicLineColor, |
| | | Height = Application.GetRealHeight(30), |
| | | }; |
| | | logicnamefl.AddChidren(btnline); |
| | | middle.AddChidren(fraline); |
| | | #endregion |
| | | |
| | | #region -----显示逻辑条件----- |
| | | var conditionRowLayout = new RowLayout |
| | | { |
| | | Height = Application.GetRealHeight(150), |
| | | //BackgroundColor = 0xff323232, |
| | | }; |
| | | middle.AddChidren(conditionRowLayout); |
| | | |
| | | conditionRowLayout.AddChidren(new Button |
| | | { |
| | | Width = Application.GetRealWidth(300), |
| | | Height = Application.GetRealHeight(60), |
| | | //Text = "如果", |
| | | TextID = MyInternationalizationString.ifcondition, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | X = Application.GetRealWidth(40), |
| | | // Gravity = Gravity.CenterVertical, |
| | | TextColor = ZigbeeColor.Current.LogicViewBackgroundColor, |
| | | Y = Application.GetRealHeight(90), |
| | | TextSize = 16, |
| | | }); |
| | | Addview addconditionview = new Addview(); |
| | | addconditionview.iconBtn.Visible = true; |
| | | addconditionview.titleBtn.TextID = MyInternationalizationString.ifcondition; |
| | | middle.AddChidren(addconditionview.AddDeviceView()); |
| | | |
| | | var conditionadd = new Button |
| | | { |
| | | Width = Application.GetRealWidth(110), |
| | | Height = Application.GetRealHeight(100), |
| | | UnSelectedImagePath = "ZigeeLogic/add.png", |
| | | X = Application.GetRealWidth(1080 - 140), |
| | | Gravity = Gravity.CenterVertical, |
| | | }; |
| | | conditionRowLayout.AddChidren(conditionadd); |
| | | ///添加条件的点击事件 |
| | | conditionadd.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | ConditionView(); |
| | | }; |
| | | |
| | | |
| | | 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) |
| | | { |
| | | //inputVerticalScrolViewLayout.Height = Application.GetRealHeight(160 * ListConditions.Count) + Application.GetRealHeight(60); |
| | | var row = new FrameLayout |
| | | { |
| | | Height = Application.GetRealHeight(60), |
| | | BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor, |
| | | }; |
| | | //inputVerticalScrolViewLayout.AddChidren(row); |
| | | middle.AddChidren(row); |
| | | var relationship = new Button |
| | | { |
| | | Width = Application.GetRealWidth(600), |
| | | Height = Application.GetRealHeight(60), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | X = Application.GetRealWidth(40), |
| | | TextColor = ZigbeeColor.Current.LogicViewBackgroundColor, |
| | | 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.anycondition); |
| | | } |
| | | } |
| | | for (int i = 0; i < ListConditions.Count; i++) |
| | | { |
| | | if (i == (ListConditions.Count - 1)) |
| | | EventHandler<MouseEventArgs> editclick = (sender, e) => |
| | | { |
| | | Common.Logic.CurrentLogic.LogicName = logicTextBox.Text.Trim(); |
| | | new LogicDveiceStatus { }.ConditionView(true, this); |
| | | }; |
| | | row.MouseUpEventHandler += editclick; |
| | | relationship.MouseUpEventHandler += editclick; |
| | | |
| | | var addfl = new FrameLayout |
| | | { |
| | | Height = Application.GetRealHeight(160), |
| | | }; |
| | | middle.AddChidren(addfl); |
| | | var addbtn = new Button |
| | | { |
| | | Height = Application.GetRealHeight(120), |
| | | Width = Application.GetRealWidth(1000), |
| | | X = Application.GetRealWidth(40), |
| | | Y = Application.GetRealHeight(40), |
| | | Radius = (uint)Application.GetRealHeight(30), |
| | | //Text = "添加条件", |
| | | BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor, |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | TextID = MyInternationalizationString.addconditions, |
| | | }; |
| | | addfl.AddChidren(addbtn); |
| | | addbtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | ConditionView(); |
| | | }; |
| | | } |
| | | else |
| | | { |
| | | var conditionsowLayout = new RowLayout |
| | | { |
| | | Height = Application.GetRealHeight(160), |
| | | }; |
| | | middle.AddChidren(conditionsowLayout); |
| | | var Type = int.Parse(ListConditions[i]["Type"]); |
| | | var conditions = ListConditions[i]; |
| | | switch (Type) |
| | | { |
| | | |
| | | /// (0:时间点条件;1:设备状态变化条件;2:其他逻辑条件;3:计数器条件;4:倒计时;5:时间段条件;6:安防条件;7:地理位置) |
| | | case 0: |
| | | { |
| | | ///显示时间 |
| | | var timevalue = new Button |
| | | { |
| | | X = Application.GetRealWidth(40), |
| | | Width = Application.GetRealWidth(800), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | Gravity = Gravity.CenterVertical, |
| | | //Text = starttime, |
| | | //TextColor = 0xff121212, |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | }; |
| | | conditionsowLayout.AddChidren(timevalue); |
| | | |
| | | |
| | | var timeedit = new Button |
| | | { |
| | | BackgroundColor = ZigbeeColor.Current.LogicEditBlackColor, |
| | | Text = Language.StringByID(MyInternationalizationString.edit), |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | }; |
| | | conditionsowLayout.AddRightView(timeedit); |
| | | |
| | | timeedit.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | var timePoint = new TimePoint(); |
| | | UserView.HomePage.Instance.AddChidren(timePoint); |
| | | UserView.HomePage.Instance.PageIndex += 1; |
| | | timePoint.IsDeviceEditor = true; |
| | | timePoint.Show(conditions); |
| | | }; |
| | | |
| | | //"0正常时间点","1日出时间","2日落时间","3正午时间" |
| | | switch (int.Parse(conditions["DateType"])) |
| | | { |
| | | case 0: |
| | | { |
| | | string s = ""; |
| | | s = conditions["StartMin"].Length < 2 ? "0" + conditions["StartMin"] : conditions["StartMin"]; |
| | | timevalue.Text = Language.StringByID(MyInternationalizationString.time) + conditions["StartHour"] + ":" + s; |
| | | } |
| | | break; |
| | | case 1: |
| | | if (int.Parse(conditions["AdjustTime"]) > 0) |
| | | { |
| | | timevalue.Text = Language.StringByID(MyInternationalizationString.sunriseafter) + conditions["AdjustTime"] + Language.StringByID(MyInternationalizationString.logicminute); |
| | | } |
| | | else if (int.Parse(conditions["AdjustTime"]) < 0) |
| | | { |
| | | timevalue.Text = Language.StringByID(MyInternationalizationString.sunrisebefore) + Math.Abs(int.Parse(conditions["AdjustTime"])).ToString() + Language.StringByID(MyInternationalizationString.logicminute); |
| | | } |
| | | else |
| | | { |
| | | timevalue.Text = Language.StringByID(MyInternationalizationString.sunrise); |
| | | } |
| | | break; |
| | | case 2: |
| | | if (int.Parse(conditions["AdjustTime"]) > 0) |
| | | { |
| | | timevalue.Text = Language.StringByID(MyInternationalizationString.sunsetafter) + conditions["AdjustTime"] + Language.StringByID(MyInternationalizationString.logicminute); |
| | | } |
| | | else if (int.Parse(conditions["AdjustTime"]) < 0) |
| | | { |
| | | timevalue.Text = Language.StringByID(MyInternationalizationString.sunsetbefore) + Math.Abs(int.Parse(conditions["AdjustTime"])).ToString() + Language.StringByID(MyInternationalizationString.logicminute); |
| | | } |
| | | else |
| | | { |
| | | timevalue.Text =Language.StringByID(MyInternationalizationString.sunset); |
| | | } |
| | | break; |
| | | case 3: |
| | | if (int.Parse(conditions["AdjustTime"]) > 0) |
| | | { |
| | | timevalue.Text = Language.StringByID(MyInternationalizationString.noonafter) + conditions["AdjustTime"] + Language.StringByID(MyInternationalizationString.logicminute); |
| | | } |
| | | else if (int.Parse(conditions["AdjustTime"]) < 0) |
| | | { |
| | | timevalue.Text = Language.StringByID(MyInternationalizationString.noonbefore) + Math.Abs(int.Parse(conditions["AdjustTime"])).ToString() + Language.StringByID(MyInternationalizationString.logicminute); |
| | | } |
| | | else |
| | | { |
| | | timevalue.Text =Language.StringByID(MyInternationalizationString.noon); |
| | | } |
| | | break; |
| | | } |
| | | |
| | | } |
| | | break; |
| | | case 5: |
| | | { |
| | | string s1="", s2=""; |
| | | s1 = conditions["StartMin"].Length < 2 ? "0" + conditions["StartMin"] : conditions["StartMin"]; |
| | | s2 = conditions["StopMin"].Length <2 ? "0" + conditions["StopMin"] : conditions["StopMin"]; |
| | | ///显示时间 |
| | | var timevalue = new Button |
| | | { |
| | | X = Application.GetRealWidth(40), |
| | | Width = Application.GetRealWidth(500), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | Gravity = Gravity.CenterVertical, |
| | | Text = conditions["StartHour"] + ":" + s1 + "-" + conditions["StopHour"] + ":" + s2, |
| | | //TextColor = 0xff121212, |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | }; |
| | | conditionsowLayout.AddChidren(timevalue); |
| | | |
| | | |
| | | var timeedit = new Button |
| | | { |
| | | BackgroundColor =ZigbeeColor.Current.LogicEditBlackColor, |
| | | Text = Language.StringByID(MyInternationalizationString.edit), |
| | | //TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | }; |
| | | conditionsowLayout.AddRightView(timeedit); |
| | | timeedit.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | 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.IsDeviceEditor1 = true; |
| | | timePage.Show(); |
| | | }; |
| | | } |
| | | break; |
| | | case 1: |
| | | { |
| | | var deviceinof = Common.Logic.LogicDviceList.Find((obj) => { return obj.DeviceAddr == conditions["MacAddr"] && obj.DeviceEpoint.ToString() == conditions["Epoint"]; }); |
| | | if (deviceinof == null) |
| | | { |
| | | continue; |
| | | } |
| | | ///显示设备名称 |
| | | var btndevice = new Button |
| | | { |
| | | X = Application.GetRealWidth(40), |
| | | Width = Application.GetRealWidth(500), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | Gravity = Gravity.CenterVertical, |
| | | Text = deviceinof.DeviceEpointName, |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | //TextColor = 0xff121212, |
| | | }; |
| | | conditionsowLayout.AddChidren(btndevice); |
| | | |
| | | |
| | | var deviceedit = new Button |
| | | { |
| | | BackgroundColor =ZigbeeColor.Current.LogicEditBlackColor, |
| | | Text = Language.StringByID(MyInternationalizationString.edit), |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | }; |
| | | conditionsowLayout.AddRightView(deviceedit); |
| | | deviceedit.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | //var selectedDeviceState = new SelectedDeviceState(); |
| | | //UserView.HomePage.Instance.AddChidren(selectedDeviceState); |
| | | //UserView.HomePage.Instance.PageIndex += 1; |
| | | //selectedDeviceState.IsDeviceEditor = true; |
| | | //selectedDeviceState.Show(deviceinof); |
| | | var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor }; |
| | | this.AddChidren(flMain); |
| | | DeviceStateCondition.CurrentDeviceView(flMain, deviceinof, true); |
| | | }; |
| | | |
| | | ///显示设备条件状态控件 |
| | | var devicestatus = new Button |
| | | { |
| | | Width = Application.GetRealWidth(300), |
| | | Height = Application.GetRealHeight(160), |
| | | Gravity = Gravity.CenterVertical, |
| | | TextAlignment = TextAlignment.CenterRight, |
| | | X = Application.GetRealWidth(1080 - 330), |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | }; |
| | | conditionsowLayout.AddChidren(devicestatus); |
| | | |
| | | switch (deviceinof.Type) |
| | | { |
| | | case DeviceType.OnOffOutput: |
| | | { |
| | | if (conditions["AttriButeId"] == "0") |
| | | { |
| | | if (conditions["AttriButeData1"] == "1") |
| | | { |
| | | devicestatus.Text = Language.StringByID(MyInternationalizationString.open); |
| | | } |
| | | else |
| | | { |
| | | devicestatus.Text = Language.StringByID(MyInternationalizationString.close); |
| | | } |
| | | |
| | | } |
| | | } |
| | | break; |
| | | case DeviceType.WindowCoveringDevice: |
| | | { |
| | | if (conditions["AttriButeId"] == "8")//有歧义,没有开关属性id; |
| | | { |
| | | if (int.Parse(conditions["AttriButeData1"]) > 5) |
| | | { |
| | | devicestatus.Text = Language.StringByID(MyInternationalizationString.open); |
| | | } |
| | | else |
| | | { |
| | | devicestatus.Text = Language.StringByID(MyInternationalizationString.close); |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | case DeviceType.IASZone: |
| | | { |
| | | var iASZonedevice = deviceinof as IASZone; |
| | | var intvalue = conditions["AttriButeData1"]; |
| | | switch (iASZonedevice.IasDeviceType) |
| | | { |
| | | case 13: |
| | | { |
| | | if (intvalue == "1") |
| | | { |
| | | devicestatus.TextID = MyInternationalizationString.someone; |
| | | } |
| | | else |
| | | { |
| | | devicestatus.TextID = MyInternationalizationString.unmanned; |
| | | } |
| | | } |
| | | break; |
| | | case 21: |
| | | { |
| | | if (intvalue == "1") |
| | | { |
| | | devicestatus.TextID = MyInternationalizationString.logicopen; |
| | | } |
| | | else |
| | | { |
| | | devicestatus.TextID = MyInternationalizationString.logicclose; |
| | | } |
| | | } |
| | | break; |
| | | case 22: |
| | | { |
| | | if (intvalue == "1") |
| | | { |
| | | devicestatus.TextID = MyInternationalizationString.logicopen; |
| | | } |
| | | else |
| | | { |
| | | devicestatus.TextID = MyInternationalizationString.logicclose; |
| | | } |
| | | } |
| | | break; |
| | | case 40: |
| | | { |
| | | if (intvalue == "1") |
| | | { |
| | | devicestatus.TextID = MyInternationalizationString.smokescreen; |
| | | } |
| | | |
| | | } |
| | | break; |
| | | case 42: |
| | | { |
| | | if (intvalue == "1") |
| | | { |
| | | devicestatus.TextID = MyInternationalizationString.waterleakage; |
| | | } |
| | | else |
| | | { |
| | | devicestatus.TextID = MyInternationalizationString.noleakage; |
| | | } |
| | | } |
| | | break; |
| | | case 43: |
| | | { |
| | | if (intvalue == "1") |
| | | { |
| | | devicestatus.TextID = MyInternationalizationString.gas; |
| | | } |
| | | |
| | | } |
| | | break; |
| | | case 277: |
| | | { |
| | | if (intvalue == "1") |
| | | { |
| | | devicestatus.TextID = MyInternationalizationString.callthepolice; |
| | | } |
| | | |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | break; |
| | | case DeviceType.OnOffSwitch: |
| | | { |
| | | devicestatus.Text = Language.StringByID(MyInternationalizationString.OnOffSwitch) + conditions["Epoint"]; |
| | | //if (conditions["Epoint"] == "1") |
| | | //{ |
| | | // devicestatus.TextID = MyInternationalizationString.button1; |
| | | //} |
| | | //else if (conditions["Epoint"] == "2") |
| | | //{ |
| | | // devicestatus.TextID = MyInternationalizationString.button2; |
| | | //} |
| | | //else if (conditions["Epoint"] == "3") |
| | | //{ |
| | | // devicestatus.TextID = MyInternationalizationString.button3; |
| | | //} |
| | | //else if (conditions["Epoint"] == "4") |
| | | //{ |
| | | // devicestatus.TextID = MyInternationalizationString.button4; |
| | | //} |
| | | } |
| | | break; |
| | | |
| | | } |
| | | |
| | | } |
| | | break; |
| | | case 2: |
| | | { |
| | | var logicinof = Common.Logic.LogicList.Find((obj) => { return obj.LogicId.ToString() == conditions["Condition_LogicId"]; }); |
| | | if (logicinof == null) |
| | | { |
| | | continue; |
| | | } |
| | | ///显示逻辑名称 |
| | | var btnlogic = new Button |
| | | { |
| | | X = Application.GetRealWidth(40), |
| | | Width = Application.GetRealWidth(700), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | Gravity = Gravity.CenterVertical, |
| | | Text = logicinof.LogicName, |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | //TextColor = 0xff121212, |
| | | }; |
| | | conditionsowLayout.AddChidren(btnlogic); |
| | | |
| | | |
| | | var logicedit = new Button |
| | | { |
| | | BackgroundColor =ZigbeeColor.Current.LogicEditBlackColor, |
| | | Text = Language.StringByID(MyInternationalizationString.edit), |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | }; |
| | | conditionsowLayout.AddRightView(logicedit); |
| | | logicedit.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | var selectedLogicStatus = new SelectedLogicStatus(); |
| | | UserView.HomePage.Instance.AddChidren(selectedLogicStatus); |
| | | UserView.HomePage.Instance.PageIndex += 1; |
| | | selectedLogicStatus.IsDeviceEditor = true; |
| | | selectedLogicStatus.Show(logicinof); |
| | | }; |
| | | |
| | | ///显示Logic条件状态控件 |
| | | var logicstatus = new Button |
| | | { |
| | | Width = Application.GetRealWidth(300), |
| | | Height = Application.GetRealHeight(160), |
| | | Gravity = Gravity.CenterVertical, |
| | | //TextColor = 0xff121212, |
| | | X = Application.GetRealWidth(1080 - 330), |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | TextAlignment = TextAlignment.CenterRight, |
| | | }; |
| | | conditionsowLayout.AddChidren(logicstatus); |
| | | |
| | | if (conditions["IsValid"] == "1") |
| | | { |
| | | logicstatus.Text = Language.StringByID(MyInternationalizationString.open1); |
| | | } |
| | | else |
| | | { |
| | | logicstatus.Text = Language.StringByID(MyInternationalizationString.disable); |
| | | } |
| | | } |
| | | break; |
| | | case 6: |
| | | { |
| | | var btnsecurity = new Button |
| | | { |
| | | X = Application.GetRealWidth(40), |
| | | Width = Application.GetRealWidth(700), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | Gravity = Gravity.CenterVertical, |
| | | //Text = "安防", |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | //TextColor = 0xff121212, |
| | | TextID = MyInternationalizationString.security, |
| | | }; |
| | | conditionsowLayout.AddChidren(btnsecurity); |
| | | |
| | | |
| | | var btnsecurityedit = new Button |
| | | { |
| | | BackgroundColor =ZigbeeColor.Current.LogicEditBlackColor, |
| | | Text = Language.StringByID(MyInternationalizationString.edit), |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | }; |
| | | conditionsowLayout.AddRightView(btnsecurityedit); |
| | | btnsecurityedit.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | //var securityPage = new SecurityPage(); |
| | | //UserView.HomePage.Instance.AddChidren(securityPage); |
| | | //UserView.HomePage.Instance.PageIndex += 1; |
| | | //securityPage.IsDeviceEditor = true; |
| | | //securityPage.Show(); |
| | | |
| | | var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor }; |
| | | this.AddChidren(flMain); |
| | | AddLogicPage.SecurityView(flMain, true); |
| | | }; |
| | | |
| | | ///显示安防条件状态控件 |
| | | var securitystatus = new Button |
| | | { |
| | | Width = Application.GetRealWidth(300), |
| | | Height = Application.GetRealHeight(160), |
| | | Gravity = Gravity.CenterVertical, |
| | | TextAlignment = TextAlignment.CenterRight, |
| | | X = Application.GetRealWidth(1080 - 330), |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | }; |
| | | conditionsowLayout.AddChidren(securitystatus); |
| | | |
| | | if (conditions["EnOrWithdrawMode"] == "1") |
| | | { |
| | | securitystatus.Text = Language.StringByID(MyInternationalizationString.withdrawal); |
| | | } |
| | | else |
| | | { |
| | | securitystatus.Text = Language.StringByID(MyInternationalizationString.defence); |
| | | } |
| | | } |
| | | break; |
| | | case 7: |
| | | { |
| | | var btnlocation= new Button |
| | | { |
| | | X = Application.GetRealWidth(40), |
| | | Width = Application.GetRealWidth(700), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | Gravity = Gravity.CenterVertical, |
| | | //Text = "地理位置", |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | //TextColor = 0xff121212, |
| | | TextID = MyInternationalizationString.geographicalposition, |
| | | }; |
| | | conditionsowLayout.AddChidren(btnlocation); |
| | | |
| | | |
| | | var btnlocationedit = new Button |
| | | { |
| | | BackgroundColor =ZigbeeColor.Current.LogicEditBlackColor, |
| | | Text = Language.StringByID(MyInternationalizationString.edit), |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | }; |
| | | conditionsowLayout.AddRightView(btnlocationedit); |
| | | btnlocationedit.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | |
| | | var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor }; |
| | | this.AddChidren(flMain); |
| | | AddLogicPage.LocationView(flMain, true); |
| | | }; |
| | | |
| | | var locationstatus = new Button |
| | | { |
| | | Width = Application.GetRealWidth(300), |
| | | Height = Application.GetRealHeight(160), |
| | | Gravity = Gravity.CenterVertical, |
| | | TextAlignment = TextAlignment.CenterRight, |
| | | X = Application.GetRealWidth(1080 - 330), |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | }; |
| | | conditionsowLayout.AddChidren(locationstatus); |
| | | |
| | | if (conditions["AtHome"] == "1") |
| | | { |
| | | locationstatus.Text =Language.StringByID(MyInternationalizationString.athome); |
| | | } |
| | | else |
| | | { |
| | | locationstatus.Text =Language.StringByID(MyInternationalizationString.leavehome); |
| | | } |
| | | } |
| | | break; |
| | | |
| | | } |
| | | ///删除控件 |
| | | var del = new Button |
| | | { |
| | | BackgroundColor = ZigbeeColor.Current.LogicDelBackgroundColor, |
| | | Text = Language.StringByID(MyInternationalizationString.del), |
| | | }; |
| | | conditionsowLayout.AddRightView(del); |
| | | |
| | | del.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | |
| | | var alert = new Alert(Language.StringByID(MyInternationalizationString.tip), Language.StringByID(MyInternationalizationString.doyouwanttodelete), |
| | | Language.StringByID(MyInternationalizationString.cancel), Language.StringByID(MyInternationalizationString.confrim)); |
| | | alert.ResultEventHandler += (sender1, e1) => |
| | | { |
| | | if (e1) |
| | | { |
| | | Common.Logic.CurrentLogic.Conditions.Remove(conditions); |
| | | var logicCommunalPage = new LogicCommunalPage(); |
| | | UserView.HomePage.Instance.AddChidren(logicCommunalPage); |
| | | UserView.HomePage.Instance.PageIndex += 1; |
| | | logicCommunalPage.Show(() => { }); |
| | | } |
| | | }; |
| | | alert.Show(); |
| | | |
| | | }; |
| | | |
| | | } |
| | | } |
| | | |
| | | new LogicDveiceStatus { }.Conditions(this, middle, ListConditions, logicTextBox.Text.Trim()); |
| | | |
| | | #endregion |
| | | |
| | | #region ----显示执行目标---- |
| | | var targetRowLayout = new RowLayout |
| | | { |
| | | Height = Application.GetRealHeight(150), |
| | | // BackgroundColor = 0xff323232, |
| | | }; |
| | | middle.AddChidren(targetRowLayout); |
| | | |
| | | |
| | | var btntargettitle = new Button |
| | | { |
| | | //Text = "就执行", |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | X = Application.GetRealWidth(40), |
| | | TextColor = ZigbeeColor.Current.LogicViewBackgroundColor, |
| | | Y = Application.GetRealHeight(90), |
| | | Width = Application.GetRealWidth(300), |
| | | Height = Application.GetRealHeight(60), |
| | | TextSize = 16, |
| | | TextID = MyInternationalizationString.execute, |
| | | }; |
| | | targetRowLayout.AddChidren(btntargettitle); |
| | | |
| | | var btntargetadd = new Button |
| | | { |
| | | Width = Application.GetRealWidth(100), |
| | | Height = Application.GetRealHeight(100), |
| | | UnSelectedImagePath = "ZigeeLogic/add.png", |
| | | X = Application.GetRealWidth(1080 - 140), |
| | | Gravity = Gravity.CenterVertical, |
| | | }; |
| | | targetRowLayout.AddChidren(btntargetadd); |
| | | btntargetadd.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | Common.Logic.CurrentLogic.LogicName = logicTextBox.Text.Trim(); |
| | | var deviceTarget = new DeviceTarget(); |
| | | UserView.HomePage.Instance.AddChidren(deviceTarget); |
| | | UserView.HomePage.Instance.PageIndex += 1; |
| | | deviceTarget.Show(); |
| | | }; |
| | | |
| | | 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>()); |
| | | ListActions.Add(new Dictionary<string, object>() { ["LinkType"] = "11" }); |
| | | bool tag = false; |
| | | for (int i = 0; i < ListActions.Count; i++) |
| | | ListActions.Add(new Dictionary<string, object>()); |
| | | new LogicDveiceStatus { }.Actions(this, middle, ListActions, logicTextBox.Text.Trim()); |
| | | |
| | | #endregion |
| | | |
| | | #region -----每天 设置周期----- |
| | | |
| | | var fraline1 = new FrameLayout |
| | | { |
| | | var linkType = ListActions[i]["LinkType"].ToString(); |
| | | if (linkType == "10") |
| | | { |
| | | if (ListActions[i + 1]["LinkType"].ToString() == "0") |
| | | { |
| | | var delaytime = ListActions[i]["DelayTime"].ToString(); |
| | | if (ListActions[i + 1].ContainsKey("Time")) |
| | | { |
| | | ListActions[i + 1].Remove("Time"); |
| | | } |
| | | ListActions[i + 1].Add("Time", delaytime); |
| | | } |
| | | tag = true; |
| | | //break; |
| | | } |
| | | Height = Application.GetRealHeight(30), |
| | | }; |
| | | middle.AddChidren(fraline1); |
| | | |
| | | } |
| | | |
| | | if (!tag) |
| | | 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 |
| | | { |
| | | for (int i = 0; i < ListActions.Count; i++) |
| | | { |
| | | var linkType = ListActions[i]["LinkType"].ToString(); |
| | | if (linkType == "0") |
| | | { |
| | | var second = ListActions[i]["Time"].ToString(); |
| | | if (second != "0") |
| | | { |
| | | Dictionary<string, object> actionsInfo = new Dictionary<string, object>(); |
| | | actionsInfo.Add("LinkType", 10); |
| | | actionsInfo.Add("DelayTime", second); |
| | | ListActions.Insert(i, actionsInfo); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | for (int i = 0; i < ListActions.Count; i++) |
| | | 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 (i == (ListActions.Count - 1)) |
| | | { |
| | | /*------保留每月,每年类型*/ |
| | | var cycle = new Cycle(() => { Method.UpdateWeek(weekBtn, Common.Logic.CurrentLogic); }); |
| | | UserView.HomePage.Instance.AddChidren(cycle); |
| | | UserView.HomePage.Instance.PageIndex += 1; |
| | | cycle.Show(); |
| | | |
| | | var addfl = new FrameLayout |
| | | { |
| | | Height = Application.GetRealHeight(160), |
| | | }; |
| | | middle.AddChidren(addfl); |
| | | var addbtn = new Button |
| | | { |
| | | Height = Application.GetRealHeight(120), |
| | | Width = Application.GetRealWidth(1000), |
| | | X = Application.GetRealWidth(40), |
| | | Y = Application.GetRealHeight(40), |
| | | Radius = (uint)Application.GetRealHeight(30), |
| | | //Text = "添加功能", |
| | | BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor, |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | TextID = MyInternationalizationString.addfunction, |
| | | }; |
| | | addfl.AddChidren(addbtn); |
| | | addbtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | Common.Logic.CurrentLogic.LogicName = logicTextBox.Text.Trim(); |
| | | var deviceTarget = new DeviceTarget(); |
| | | UserView.HomePage.Instance.AddChidren(deviceTarget); |
| | | UserView.HomePage.Instance.PageIndex += 1; |
| | | deviceTarget.Show(); |
| | | }; |
| | | } |
| | | else |
| | | { |
| | | var actionsrowLayout = new RowLayout |
| | | { |
| | | Height = Application.GetRealHeight(160), |
| | | }; |
| | | middle.AddChidren(actionsrowLayout); |
| | | |
| | | var linkType = int.Parse(ListActions[i]["LinkType"].ToString()); |
| | | var actions = ListActions[i]; |
| | | |
| | | switch (linkType) |
| | | { |
| | | case 10: |
| | | { |
| | | var delaytime =actions["DelayTime"].ToString(); |
| | | |
| | | var btnDelayTime = new Button |
| | | { |
| | | X = Application.GetRealWidth(40), |
| | | Width = Application.GetRealWidth(382), |
| | | Height = Application.GetRealHeight(80), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | Text = delaytime, |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | }; |
| | | actionsrowLayout.AddChidren(btnDelayTime); |
| | | |
| | | ///编辑设备状态Button |
| | | var timeedit = new Button |
| | | { |
| | | BackgroundColor =ZigbeeColor.Current.LogicEditBlackColor, |
| | | Text = Language.StringByID(MyInternationalizationString.edit), |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | }; |
| | | actionsrowLayout.AddRightView(timeedit); |
| | | timeedit.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | DeviceTarget.DelayTimeView(actions); |
| | | }; |
| | | |
| | | //if (tag) |
| | | //{ |
| | | // if (ListActions[i + 1]["LinkType"].ToString() == "0") |
| | | // { |
| | | // if (ListActions[i + 1].ContainsKey("Time")) |
| | | // { |
| | | // ListActions[i + 1].Remove("Time"); |
| | | // } |
| | | // ListActions[i + 1].Add("Time", delaytime); |
| | | // ///移除旧数据再添加新数据 |
| | | // //Common.Logic.CurrentLogic.Actions.RemoveAt(i+1); |
| | | // //Common.Logic.CurrentLogic.Actions.Insert(i + 1, Common.Logic.CurrentLogic.Actions[i + 1]); |
| | | // } |
| | | //} |
| | | } |
| | | break; |
| | | case 0: |
| | | { |
| | | |
| | | var obj1 = actions["DeviceAddr"].ToString(); |
| | | var obj2 = actions["Epoint"].ToString(); |
| | | var deviceinof = Common.Logic.LogicDviceList.Find((obj) => { return ((obj.DeviceAddr == obj1) && (obj.DeviceEpoint.ToString() == obj2)); }); |
| | | if (deviceinof == null) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | if (i != 0 && ListActions[i - 1]["LinkType"].ToString() != "10") |
| | | { |
| | | if (ListActions[i].ContainsKey("Time")) |
| | | { |
| | | ListActions[i].Remove("Time"); |
| | | } |
| | | ListActions[i].Add("Time", 0); |
| | | } |
| | | |
| | | ///设备名称Button |
| | | var btndevicename = new Button |
| | | { |
| | | X = Application.GetRealWidth(40), |
| | | Width = Application.GetRealWidth(382), |
| | | Height = Application.GetRealHeight(80), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | Text = deviceinof.DeviceEpointName, |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | }; |
| | | actionsrowLayout.AddChidren(btndevicename); |
| | | |
| | | ///区域(房间)名称Button |
| | | var btnregionname = new Button |
| | | { |
| | | X = Application.GetRealWidth(40), |
| | | Y = Application.GetRealHeight(80), |
| | | Width = Application.GetRealWidth(382), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | Height = Application.GetRealHeight(80), |
| | | Text = "",//Language.StringByID(MyInternationalizationString.customroom), |
| | | TextColor = ZigbeeColor.Current.LogicViewBackgroundColor, |
| | | }; |
| | | actionsrowLayout.AddChidren(btnregionname); |
| | | ///通过设备找到区域(房间)名称 |
| | | Send.RoomNmae(btnregionname, deviceinof); |
| | | ///显示设备条件状态控件 |
| | | var devicestatus = new Button |
| | | { |
| | | Width = Application.GetRealWidth(300), |
| | | Height = Application.GetRealHeight(160), |
| | | Gravity = Gravity.CenterVertical, |
| | | TextAlignment = TextAlignment.CenterRight, |
| | | X = Application.GetRealWidth(1080 - 330), |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | }; |
| | | actionsrowLayout.AddChidren(devicestatus); |
| | | |
| | | ///编辑设备状态Button |
| | | var deviceedit = new Button |
| | | { |
| | | BackgroundColor =ZigbeeColor.Current.LogicEditBlackColor, |
| | | Text = Language.StringByID(MyInternationalizationString.edit), |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | }; |
| | | actionsrowLayout.AddRightView(deviceedit); |
| | | |
| | | ///编辑点击事件 |
| | | deviceedit.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | //var deviceStatePage = new DeviceStatePage(); |
| | | //UserView.HomePage.Instance.AddChidren(deviceStatePage); |
| | | //UserView.HomePage.Instance.PageIndex += 1; |
| | | //deviceStatePage.IsDeviceEditor = true; |
| | | //deviceStatePage.Show(deviceinof); |
| | | |
| | | //ActionModifyDeviceStateView(deviceinof); |
| | | var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor }; |
| | | this.AddChidren(flMain); |
| | | LogicDevicePage.CurrentDeviceStateView(flMain, deviceinof, true); |
| | | }; |
| | | |
| | | |
| | | switch (deviceinof.Type) |
| | | { |
| | | |
| | | case DeviceType.OnOffOutput: |
| | | { |
| | | 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() == "1") |
| | | { |
| | | devicestatus.Text = devicestatus.Text + Language.StringByID(MyInternationalizationString.open); |
| | | } |
| | | else |
| | | { |
| | | devicestatus.Text = devicestatus.Text + Language.StringByID(MyInternationalizationString.close); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | break; |
| | | case DeviceType.WindowCoveringDevice: |
| | | { |
| | | 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") |
| | | { |
| | | devicestatus.Text = devicestatus.Text + Language.StringByID(MyInternationalizationString.open); |
| | | } |
| | | else if (status["Data1"] == "1") |
| | | { |
| | | devicestatus.Text = devicestatus.Text + Language.StringByID(MyInternationalizationString.close); |
| | | } |
| | | else if (status["Data1"] == "5") |
| | | { |
| | | devicestatus.Text = devicestatus.Text + status["Data2"] + "%"; |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | break; |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | break; |
| | | case 2: |
| | | { |
| | | |
| | | var sceneinof = Common.Room.AllRoomSceneUIList.Find((obj) => { return obj.Id.ToString() == actions["DeviceAddr"].ToString(); }); |
| | | if (sceneinof == null) |
| | | { |
| | | continue; |
| | | } |
| | | ///显示逻辑名称 |
| | | var btnlogic = new Button |
| | | { |
| | | X = Application.GetRealWidth(40), |
| | | Width = Application.GetRealWidth(500), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | Gravity = Gravity.CenterVertical, |
| | | Text = sceneinof.Name, |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | //TextColor = 0xff121212, |
| | | }; |
| | | actionsrowLayout.AddChidren(btnlogic); |
| | | |
| | | } |
| | | break; |
| | | case 4: |
| | | { |
| | | var logicinof = Common.Logic.LogicList.Find((obj) => { return obj.LogicId.ToString() == actions["DeviceAddr"].ToString(); }); |
| | | if (logicinof == null) |
| | | { |
| | | continue; |
| | | } |
| | | ///显示逻辑名称 |
| | | var btnlogic = new Button |
| | | { |
| | | X = Application.GetRealWidth(40), |
| | | Width = Application.GetRealWidth(500), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | Gravity = Gravity.CenterVertical, |
| | | Text = logicinof.LogicName, |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | //TextColor = 0xff121212, |
| | | }; |
| | | actionsrowLayout.AddChidren(btnlogic); |
| | | |
| | | |
| | | var logicedit = new Button |
| | | { |
| | | BackgroundColor = ZigbeeColor.Current.LogicEditBlackColor, |
| | | Text = Language.StringByID(MyInternationalizationString.edit), |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | }; |
| | | actionsrowLayout.AddRightView(logicedit); |
| | | logicedit.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | var selectedLogicState = new SelectedLogicState(); |
| | | UserView.HomePage.Instance.AddChidren(selectedLogicState); |
| | | UserView.HomePage.Instance.PageIndex += 1; |
| | | selectedLogicState.IsDeviceEditor = true; |
| | | selectedLogicState.Show(logicinof); |
| | | }; |
| | | |
| | | ///显示Logic条件状态控件 |
| | | var logicstatus = new Button |
| | | { |
| | | Width = Application.GetRealWidth(300), |
| | | Height = Application.GetRealHeight(160), |
| | | Gravity = Gravity.CenterVertical, |
| | | //TextColor = 0xff121212, |
| | | X = Application.GetRealWidth(1080 - 330), |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | TextAlignment=TextAlignment.CenterRight, |
| | | }; |
| | | actionsrowLayout.AddChidren(logicstatus); |
| | | |
| | | if (actions["EnableLogic"].ToString() == "1") |
| | | { |
| | | logicstatus.Text = Language.StringByID(MyInternationalizationString.open1); |
| | | } |
| | | else |
| | | { |
| | | logicstatus.Text = Language.StringByID(MyInternationalizationString.disable); |
| | | } |
| | | } |
| | | break; |
| | | case 6: |
| | | { |
| | | var btnsecurity = new Button |
| | | { |
| | | X = Application.GetRealWidth(40), |
| | | Width = Application.GetRealWidth(700), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | Gravity = Gravity.CenterVertical, |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | //TextColor = 0xff121212, |
| | | TextID = MyInternationalizationString.securitymode, |
| | | }; |
| | | actionsrowLayout.AddChidren(btnsecurity); |
| | | |
| | | |
| | | var btnsecurityedit = new Button |
| | | { |
| | | BackgroundColor = ZigbeeColor.Current.LogicEditBlackColor, |
| | | Text = Language.StringByID(MyInternationalizationString.edit), |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | }; |
| | | actionsrowLayout.AddRightView(btnsecurityedit); |
| | | btnsecurityedit.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | var securityMode = new SecurityMode(); |
| | | UserView.HomePage.Instance.AddChidren(securityMode); |
| | | UserView.HomePage.Instance.PageIndex += 1; |
| | | securityMode.IsDeviceEditor = true; |
| | | securityMode.Show(); |
| | | }; |
| | | |
| | | ///显示安防条件状态控件 |
| | | var securitystatus = new Button |
| | | { |
| | | Width = Application.GetRealWidth(300), |
| | | Height = Application.GetRealHeight(160), |
| | | Gravity = Gravity.CenterVertical, |
| | | //TextColor = 0xff121212, |
| | | X = Application.GetRealWidth(1080 -330), |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | TextAlignment=TextAlignment.CenterRight, |
| | | }; |
| | | actionsrowLayout.AddChidren(securitystatus); |
| | | |
| | | |
| | | if (actions["SecuritySetting"].ToString() == "0") |
| | | { |
| | | if (actions["Password"].ToString() == "888888") |
| | | { |
| | | |
| | | securitystatus.Text = Language.StringByID(MyInternationalizationString.urgentwithdrawal); |
| | | } |
| | | else |
| | | { |
| | | securitystatus.Text = Language.StringByID(MyInternationalizationString.withdrawal); |
| | | |
| | | } |
| | | } |
| | | else if (actions["SecuritySetting"].ToString() == "1") |
| | | { |
| | | if (actions["SecurityModeId"].ToString() == "1") |
| | | { |
| | | |
| | | securitystatus.Text = Language.StringByID(MyInternationalizationString.logicathomegarrison); |
| | | } |
| | | else if (actions["SecurityModeId"].ToString() == "2") |
| | | { |
| | | securitystatus.Text = Language.StringByID(MyInternationalizationString.logicremovehomegarrison); |
| | | } |
| | | } |
| | | |
| | | } |
| | | break; |
| | | } |
| | | ///删除控件 |
| | | var del = new Button |
| | | { |
| | | BackgroundColor = ZigbeeColor.Current.LogicDelBackgroundColor, |
| | | Text = Language.StringByID(MyInternationalizationString.del), |
| | | }; |
| | | actionsrowLayout.AddRightView(del); |
| | | |
| | | del.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | var alert = new Alert(Language.StringByID(MyInternationalizationString.tip), Language.StringByID(MyInternationalizationString.doyouwanttodelete), |
| | | Language.StringByID(MyInternationalizationString.cancel), Language.StringByID(MyInternationalizationString.confrim)); |
| | | alert.ResultEventHandler += (sender1, e1) => |
| | | { |
| | | if (e1) |
| | | { |
| | | Common.Logic.CurrentLogic.Actions.Remove(actions); |
| | | var logicCommunalPage = new LogicCommunalPage(); |
| | | UserView.HomePage.Instance.AddChidren(logicCommunalPage); |
| | | UserView.HomePage.Instance.PageIndex += 1; |
| | | logicCommunalPage.Show(() => { }); |
| | | } |
| | | }; |
| | | alert.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); |
| | | |
| | | var pushRowLayout = new RowLayout |
| | | { |
| | | Height = Application.GetRealHeight(150), |
| | | }; |
| | | middle.AddChidren(pushRowLayout); |
| | | |
| | | var btnpushtitle = new Button |
| | | { |
| | | //Text = "推送设置", |
| | | //TextSize = 16, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | X = Application.GetRealWidth(40), |
| | | //Gravity = Gravity.CenterVertical, |
| | | TextID = MyInternationalizationString.pushset, |
| | | TextColor = ZigbeeColor.Current.LogicViewBackgroundColor, |
| | | Y = Application.GetRealHeight(90), |
| | | Width = Application.GetRealWidth(300), |
| | | Height = Application.GetRealHeight(60), |
| | | TextSize = 16, |
| | | //TextID = MyInternationalizationString.execute, |
| | | }; |
| | | pushRowLayout.AddChidren(btnpushtitle); |
| | | |
| | | var pushswitchRowlayout = new RowLayout |
| | | { |
| | | Height = Application.GetRealHeight(160), |
| | | LineColor = ZigbeeColor.Current.LogicLineColor, |
| | | }; |
| | | middle.AddChidren(pushswitchRowlayout); |
| | | |
| | | var btnswitchtxet = new Button |
| | | { |
| | | //Text = "推送开关", |
| | | X = Application.GetRealWidth(40), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | Gravity = Gravity.CenterVertical, |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | TextID = MyInternationalizationString.pushswitch, |
| | | }; |
| | | pushswitchRowlayout.AddChidren(btnswitchtxet); |
| | | |
| | | var btnswitch = new Button |
| | | { |
| | | Width = Application.GetMinRealAverage(183), |
| | | Height = Application.GetMinRealAverage(123), |
| | | UnSelectedImagePath = "ZigeeLogic/Switch.png", |
| | | SelectedImagePath = "ZigeeLogic/SwitchSelected.png", |
| | | X = Application.GetRealWidth(1080 - 200), |
| | | Gravity = Gravity.CenterVertical, |
| | | }; |
| | | pushswitchRowlayout.AddChidren(btnswitch); |
| | | |
| | | btnswitch.MouseUpEventHandler += (sender1, e1) => |
| | | { |
| | | btnswitch.IsSelected = !btnswitch.IsSelected; |
| | | if (btnswitch.IsSelected) |
| | | { |
| | | |
| | | } |
| | | else |
| | | { |
| | | |
| | | } |
| | | }; |
| | | |
| | | var custompushRowLayout = new RowLayout |
| | | { |
| | | Height = Application.GetRealHeight(160), |
| | | }; |
| | | middle.AddChidren(custompushRowLayout); |
| | | |
| | | var btncustompush = new Button |
| | | { |
| | | TextID = MyInternationalizationString.custompush, |
| | | //Text = "自定义推送", |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | Width = Application.GetRealWidth(300), |
| | | X = Application.GetRealWidth(40), |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | }; |
| | | custompushRowLayout.AddChidren(btncustompush); |
| | | |
| | | |
| | | var custompushback = new Button |
| | | { |
| | | Width = Application.GetRealWidth(110), |
| | | Height = Application.GetRealHeight(110), |
| | | UnSelectedImagePath = "ZigeeLogic/next.png", |
| | | SelectedImagePath = "ZigeeLogic/NextSelecte.png", |
| | | X = Application.GetRealWidth(1080 - 140), |
| | | Gravity = Gravity.CenterVertical, |
| | | }; |
| | | custompushRowLayout.AddChidren(custompushback); |
| | | EventHandler<MouseEventArgs> customclick = (sender, e) => |
| | | { |
| | | var CustomText = new CustomText(); |
| | | UserView.HomePage.Instance.AddChidren(CustomText); |
| | | UserView.HomePage.Instance.PageIndex += 1; |
| | | CustomText.Show(); |
| | | |
| | | }; |
| | | btncustompush.MouseUpEventHandler += customclick; |
| | | custompushback.MouseUpEventHandler += customclick; |
| | | custompushRowLayout.MouseUpEventHandler += customclick; |
| | | #endregion |
| | | |
| | | |
| | | var btnsave = new Button |
| | | { |
| | | Height = Application.GetRealHeight(150),//194 |
| | | Y = middle.Bottom + Application.GetRealHeight(15), |
| | | //Text = "保存", |
| | | Width = Application.GetRealWidth(500), |
| | | Radius = (uint)Application.GetRealHeight(50), |
| | | BackgroundColor = ZigbeeColor.Current.LogicButtonBlueColor, |
| | | X = Application.GetRealWidth(290), |
| | | TextID = MyInternationalizationString.Save, |
| | | }; |
| | | if (Common.Logic.CurrentLogic.Conditions.Count != 0 && Common.Logic.CurrentLogic.Actions.Count != 0) |
| | | { |
| | | AddChidren(btnsave); |
| | | } |
| | | btnsave.MouseUpEventHandler += async (sender, e) => |
| | | saveBtn.clickviewBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | var name = logicTextBox.Text.Trim(); |
| | | |
| | | if (string.IsNullOrEmpty(logicTextBox.Text.Trim())) |
| | | { |
| | | new Alert(Language.StringByID(MyInternationalizationString.Tip), Language.StringByID(MyInternationalizationString.PleaseEnterLogicName), Language.StringByID(MyInternationalizationString.Close)).Show(); |
| | | return; |
| | | } |
| | | var logicname = Common.Logic.LogicList.Find((logic) => Common.Logic.CurrentLogic.LogicId != logic.LogicId && logic.LogicName == name); |
| | | if (logicname != null) |
| | | { |
| | | new Alert(Language.StringByID(MyInternationalizationString.Tip), Language.StringByID(MyInternationalizationString.Rename), Language.StringByID(MyInternationalizationString.Close)).Show(); |
| | | return; |
| | | } |
| | | |
| | | Common.Logic.CurrentLogic.LogicName = name; |
| | | |
| | | //判断是新添加逻辑(默认0)还是修改逻辑 |
| | | CommonPage.Loading.Start(); |
| | | if (Common.Logic.CurrentLogic.LogicId == 0) |
| | | { |
| | | //发送添加逻辑命令 |
| | | var logicifon = await Send.AddModifyLogic(Common.Logic.CurrentLogic); |
| | | if (logicifon != null && logicifon.LogicId != 0) |
| | | { |
| | | Common.Logic.CurrentLogic.LogicId = logicifon.LogicId; |
| | | Common.Logic.LogicList.Add(Common.Logic.CurrentLogic); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //发送修改逻辑命令 |
| | | Send.AddModifyLogic(Common.Logic.CurrentLogic); |
| | | } |
| | | |
| | | CommonPage.Loading.Hide(); |
| | | UserView.HomePage.Instance.RemoveViewByTag("Logic"); |
| | | Category.Category.instance?.RefreshBodyView(); |
| | | //UserView.HomePage.Instance.RemoveAt("Logic1"); |
| | | //Category.Category category = new Category.Category(); |
| | | //UserView.HomePage.Instance.AddChidren(category); |
| | | //UserView.HomePage.Instance.PageIndex += 1; |
| | | //category.Show(2); |
| | | Method.SaveLogic(IfString._Logic, name, IfString.Tag, Common.Logic.CurrentLogic); |
| | | }; |
| | | |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 更新执行周期的方法 |
| | | /// </summary> |
| | | /// <param name="btndisplaycycle">Btndisplaycycle.</param> |
| | | void UpdateWeek(Button btndisplaycycle) |
| | | { |
| | | |
| | | switch (Common.Logic.CurrentLogic.TimeAttribute.Repeat) |
| | | { |
| | | ///0:只执行一次,执行后IsEnable值置;1,今年内执行;2:每天执行;3:每月执行;4:每年执行;5:周重复。 |
| | | case 0: |
| | | { |
| | | btndisplaycycle.Text = Language.StringByID(MyInternationalizationString.executeonce); |
| | | }; break; |
| | | case 1: { }; break; |
| | | case 2: |
| | | { |
| | | btndisplaycycle.Text = Language.StringByID(MyInternationalizationString.everyday); |
| | | }; break; |
| | | case 3: |
| | | { |
| | | |
| | | string len = ""; |
| | | int maxvalue = 0, minvalue = 0; |
| | | var stringvalue = Convert.ToString(Common.Logic.CurrentLogic.TimeAttribute.MonthDate, 2); |
| | | var str = stringvalue.Insert(0, new string('0', 32 - stringvalue.Length)); |
| | | for (int j = 31; j >= 0; j--) |
| | | { |
| | | len += str.Substring(j, 1); |
| | | } |
| | | //找出最小值 |
| | | for (int j = 0; j < len.Length; j++) |
| | | { |
| | | var strvalue = len.Substring(j, 1); |
| | | if (strvalue == "1") |
| | | { |
| | | minvalue = j + 1; |
| | | break; |
| | | } |
| | | } |
| | | //找出最大值 |
| | | for (int j = 0; j < len.Length; j++) |
| | | { |
| | | var strvalue = len.Substring(j, 1); |
| | | if (strvalue == "1") |
| | | { |
| | | maxvalue = j + 1; |
| | | } |
| | | } |
| | | if (minvalue == maxvalue) |
| | | { |
| | | btndisplaycycle.Text = Language.StringByID(MyInternationalizationString.monthly) + minvalue.ToString() + Language.StringByID(MyInternationalizationString.day); |
| | | } |
| | | else |
| | | { |
| | | btndisplaycycle.Text = Language.StringByID(MyInternationalizationString.monthly) + minvalue.ToString() + Language.StringByID(MyInternationalizationString.day) + "-" + Language.StringByID(MyInternationalizationString.monthly) + maxvalue.ToString() + Language.StringByID(MyInternationalizationString.day); |
| | | } |
| | | }; break; |
| | | case 4: |
| | | { |
| | | |
| | | Dictionary<int, int> dictionary = new Dictionary<int, int>(); |
| | | ///找出执行的月份和天数 |
| | | if (Common.Logic.CurrentLogic.TimeAttribute.SelectMonDate.Count != 0) |
| | | { |
| | | for (int i = 0; i < Common.Logic.CurrentLogic.TimeAttribute.SelectMonDate.Count; i++) |
| | | { |
| | | var dayvalue = Common.Logic.CurrentLogic.TimeAttribute.SelectMonDate[i]; |
| | | if (dayvalue != 0) |
| | | { |
| | | dictionary.Add(i + 1, dayvalue); |
| | | } |
| | | } |
| | | } |
| | | if (dictionary.Count != 0 && dictionary.Count == 1) |
| | | { |
| | | string len = "", leng = ""; |
| | | int minvalue = 0,Maximum=0; |
| | | foreach (var value in dictionary) |
| | | { |
| | | ///取出月份 |
| | | var month = value.Key; |
| | | ///取出日数 |
| | | var day = value.Value; |
| | | var maxvalue = Convert.ToString(day, 2); |
| | | var str = maxvalue.Insert(0, new string('0', 32 - maxvalue.Length)); |
| | | for (int j = 31; j >= 0; j--) |
| | | { |
| | | len += str.Substring(j, 1); |
| | | } |
| | | |
| | | for (int j = 0; j < len.Length; j++) |
| | | { |
| | | var strvalue = len.Substring(j, 1); |
| | | if (strvalue == "1") |
| | | { |
| | | minvalue = j + 1; |
| | | break; |
| | | } |
| | | } |
| | | for (int j = 0; j < len.Length; j++) |
| | | { |
| | | var strvalue = len.Substring(j, 1); |
| | | if (strvalue == "1") |
| | | { |
| | | Maximum = j + 1; |
| | | } |
| | | } |
| | | |
| | | if (month.ToString().Length < 2) |
| | | { |
| | | leng = "0" + month.ToString(); |
| | | } |
| | | else |
| | | { |
| | | leng = month.ToString(); |
| | | } |
| | | if (minvalue==Maximum) |
| | | { |
| | | btndisplaycycle.Text = Language.StringByID(MyInternationalizationString.everyyear) + leng + "/" + (minvalue.ToString().Length < 2 ? "0" + minvalue.ToString() : minvalue.ToString()); |
| | | } |
| | | else |
| | | { |
| | | btndisplaycycle.Text = Language.StringByID(MyInternationalizationString.everyyear) + leng + "/" + (minvalue.ToString().Length < 2 ? "0" + minvalue.ToString() : minvalue.ToString()) + "-" + leng + "/" + (Maximum.ToString().Length < 2 ? "0" + Maximum.ToString():Maximum.ToString()); |
| | | } |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | int b = 0; |
| | | string stringtext = ""; |
| | | foreach (var value in dictionary) |
| | | { |
| | | string len = "", leng = ""; |
| | | int minvalue = 0,Maximum=0; |
| | | ///取出月份 |
| | | var month = value.Key; |
| | | ///取出日数 |
| | | var day = value.Value; |
| | | var maxvalue = Convert.ToString(day, 2); |
| | | var str = maxvalue.Insert(0, new string('0', 32 - maxvalue.Length)); |
| | | for (int j = 31; j >= 0; j--) |
| | | { |
| | | len += str.Substring(j, 1); |
| | | } |
| | | |
| | | |
| | | if (month.ToString().Length < 2) |
| | | { |
| | | leng = "0" + month.ToString(); |
| | | } |
| | | else |
| | | { |
| | | leng = month.ToString(); |
| | | } |
| | | |
| | | |
| | | |
| | | if (b == 0) |
| | | { |
| | | for (int j = 0; j < len.Length; j++) |
| | | { |
| | | var strvalue = len.Substring(j, 1); |
| | | if (strvalue == "1") |
| | | { |
| | | minvalue = j + 1; |
| | | break; |
| | | } |
| | | } |
| | | stringtext += leng + "/" + (minvalue.ToString().Length < 2 ? "0" + minvalue.ToString() : minvalue.ToString()) + "-"; |
| | | |
| | | } |
| | | |
| | | if (b == dictionary.Count - 1) |
| | | { |
| | | for (int j = 0; j < len.Length; j++) |
| | | { |
| | | var strvalue = len.Substring(j, 1); |
| | | if (strvalue == "1") |
| | | { |
| | | Maximum = j + 1; |
| | | } |
| | | } |
| | | stringtext += leng + "/" + (Maximum.ToString().Length < 2 ? "0" +Maximum.ToString() :Maximum.ToString()); |
| | | |
| | | } |
| | | b++; |
| | | } |
| | | btndisplaycycle.Text = Language.StringByID(MyInternationalizationString.everyyear) + stringtext; |
| | | } |
| | | |
| | | }; break; |
| | | case 5: |
| | | { |
| | | string len = "", text = ""; |
| | | List<int> listvalueInt = new List<int>(); |
| | | listvalueInt.Clear(); |
| | | var maxvalue = Convert.ToString(Common.Logic.CurrentLogic.TimeAttribute.WeekDay, 2); |
| | | var str = maxvalue.Insert(0, new string('0', 8 - maxvalue.Length)); |
| | | for (int j = 7; j >= 0; j--) |
| | | { |
| | | len += str.Substring(j, 1); |
| | | } |
| | | |
| | | for (int j = 0; j < len.Length; j++) |
| | | { |
| | | var strvalue = len.Substring(j, 1); |
| | | if (strvalue == "1") |
| | | { |
| | | listvalueInt.Add(j + 1); |
| | | |
| | | |
| | | if ((j + 1) == 1) |
| | | { |
| | | text += Language.StringByID(MyInternationalizationString.week1) + Language.StringByID(MyInternationalizationString.mon1) + ","; |
| | | //text += Language.StringByID(MyInternationalizationString.mon) + ","; |
| | | } |
| | | else if ((j + 1) == 2) |
| | | { |
| | | text += Language.StringByID(MyInternationalizationString.week1) + Language.StringByID(MyInternationalizationString.tue1) + ","; |
| | | //text += Language.StringByID(MyInternationalizationString.tue) + ","; |
| | | } |
| | | else if ((j + 1) == 3) |
| | | { |
| | | text += Language.StringByID(MyInternationalizationString.week1) + Language.StringByID(MyInternationalizationString.wed1) + ","; |
| | | //text += Language.StringByID(MyInternationalizationString.wed) + ","; |
| | | } |
| | | else if ((j + 1) == 4) |
| | | { |
| | | text += Language.StringByID(MyInternationalizationString.week1) + Language.StringByID(MyInternationalizationString.thu1) + ","; |
| | | //text += Language.StringByID(MyInternationalizationString.thu) + ","; |
| | | } |
| | | else if ((j + 1) == 5) |
| | | { |
| | | text += Language.StringByID(MyInternationalizationString.week1) + Language.StringByID(MyInternationalizationString.frl1) + ","; |
| | | //text += Language.StringByID(MyInternationalizationString.frl) + ","; |
| | | } |
| | | else if ((j + 1) == 6) |
| | | { |
| | | text += Language.StringByID(MyInternationalizationString.week1) + Language.StringByID(MyInternationalizationString.sat1) + ","; |
| | | //text += Language.StringByID(MyInternationalizationString.sat) + ","; |
| | | } |
| | | else if ((j + 1) == 7) |
| | | { |
| | | text += Language.StringByID(MyInternationalizationString.week1) + Language.StringByID(MyInternationalizationString.sun1) + ","; |
| | | //text += Language.StringByID(MyInternationalizationString.sun) + ","; |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | //暂时隐藏掉,需要显示周末和工作日再放开; |
| | | //if (listvalueInt.Count == 5 && !listvalueInt.Contains(6) && !listvalueInt.Contains(7)) |
| | | //{ |
| | | // btndisplaycycle.Text = Language.StringByID(MyInternationalizationString.workingday); |
| | | //} |
| | | //else if (listvalueInt.Count == 2 && listvalueInt.Contains(6) && listvalueInt.Contains(7)) |
| | | //{ |
| | | // btndisplaycycle.Text = Language.StringByID(MyInternationalizationString.weekend); |
| | | //} |
| | | //else if (listvalueInt.Count == 7) |
| | | //{ |
| | | // btndisplaycycle.Text = Language.StringByID(MyInternationalizationString.everyday); |
| | | //} |
| | | //else |
| | | //{ |
| | | // btndisplaycycle.Text = Language.StringByID(MyInternationalizationString.week1) + text.Replace(Language.StringByID(MyInternationalizationString.week1), "").TrimEnd(','); |
| | | //} |
| | | btndisplaycycle.Text = Language.StringByID(MyInternationalizationString.week1) + text.Replace(Language.StringByID(MyInternationalizationString.week1), "").TrimEnd(','); |
| | | //btndisplaycycle.Text = text.TrimEnd(','); |
| | | }; break; |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | void ConditionView() |
| | | { |
| | | Common.Logic.CurrentLogic.LogicName = logicTextBox.Text.Trim(); |
| | | if (Common.Logic.CurrentLogic.Conditions.Count == 1) |
| | | { |
| | | #region 组合条件View |
| | | FrameLayout flMain = new FrameLayout { BackgroundColor = 0x00000000 }; |
| | | this.AddChidren(flMain); |
| | | flMain.MouseUpEventHandler += (sender2, e2) => |
| | | { |
| | | flMain.RemoveFromParent(); |
| | | }; |
| | | |
| | | var frameLayout = new FrameLayout |
| | | { |
| | | Y = Application.GetRealHeight(1920 - 720), |
| | | Height = Application.GetRealHeight(720), |
| | | BackgroundColor = ZigbeeColor.Current.LogicTopViewBackgroundColor, |
| | | }; |
| | | flMain.AddChidren(frameLayout); |
| | | |
| | | var titlerow = new RowLayout |
| | | { |
| | | Height = Application.GetRealHeight(180), |
| | | }; |
| | | frameLayout.AddChidren(titlerow); |
| | | var titlebtn = new Button |
| | | { |
| | | //Text = "请选择多条件组合", |
| | | TextID = MyInternationalizationString.Multicondition, |
| | | TextSize = 16, |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | }; |
| | | titlerow.AddChidren(titlebtn); |
| | | |
| | | var androw = new RowLayout |
| | | { |
| | | Height = Application.GetRealHeight(180), |
| | | Y = titlerow.Bottom, |
| | | }; |
| | | frameLayout.AddChidren(androw); |
| | | var andbtn = new Button |
| | | { |
| | | Width = Application.GetRealWidth(600), |
| | | TextID = MyInternationalizationString.Allconditions, |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | //Text = "满足全部条件时", |
| | | }; |
| | | androw.AddChidren(andbtn); |
| | | |
| | | var orrow = new RowLayout |
| | | { |
| | | Height = Application.GetRealHeight(180), |
| | | Y = androw.Bottom, |
| | | }; |
| | | frameLayout.AddChidren(orrow); |
| | | var orbtn = new Button |
| | | { |
| | | Width = Application.GetRealWidth(600), |
| | | TextID = MyInternationalizationString.anycondition, |
| | | //Text = "满足任一条件时", |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | }; |
| | | orrow.AddChidren(orbtn); |
| | | |
| | | var cancelbtn = new Button |
| | | { |
| | | TextID = MyInternationalizationString.cancel, |
| | | TextSize = 16, |
| | | Y = orrow.Bottom, |
| | | Height = Application.GetRealHeight(180), |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | }; |
| | | frameLayout.AddChidren(cancelbtn); |
| | | cancelbtn.MouseUpEventHandler += (sender4, e4) => |
| | | { |
| | | flMain.RemoveFromParent(); |
| | | }; |
| | | #endregion |
| | | |
| | | //满足全部条件时点击事件 simulation; |
| | | EventHandler<MouseEventArgs> andclick = (sender6, e6) => |
| | | { |
| | | flMain.RemoveFromParent(); |
| | | Common.Logic.CurrentLogic.Relationship = 0; |
| | | var addLogicPage = new AddLogicPage(); |
| | | UserView.HomePage.Instance.AddChidren(addLogicPage); |
| | | UserView.HomePage.Instance.PageIndex += 1; |
| | | addLogicPage.Show(); |
| | | }; |
| | | androw.MouseUpEventHandler += andclick; |
| | | andbtn.MouseUpEventHandler += andclick; |
| | | |
| | | //满足任一条件时点击事件 |
| | | EventHandler<MouseEventArgs> orclick = (sender6, e6) => |
| | | { |
| | | flMain.RemoveFromParent(); |
| | | Common.Logic.CurrentLogic.Relationship = 1; |
| | | var addLogicPage = new AddLogicPage(); |
| | | UserView.HomePage.Instance.AddChidren(addLogicPage); |
| | | UserView.HomePage.Instance.PageIndex += 1; |
| | | addLogicPage.Show(); |
| | | }; |
| | | orrow.MouseUpEventHandler += orclick; |
| | | orbtn.MouseUpEventHandler += orclick; |
| | | } |
| | | else |
| | | { |
| | | var addLogicPage = new AddLogicPage(); |
| | | UserView.HomePage.Instance.AddChidren(addLogicPage); |
| | | UserView.HomePage.Instance.PageIndex += 1; |
| | | addLogicPage.Show(); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |