| | |
| | | |
| | | public LockLogicList() |
| | | { |
| | | Tag = "LockLogicList"; |
| | | Tag = "LockListView"; |
| | | } |
| | | VerticalRefreshLayout middle; |
| | | public void Show() |
| | | { |
| | | |
| | | #region 最上面的布局代码 |
| | | var topRowLayout = new RowLayout |
| | | #region 上面的布局代码 |
| | | TopView view = new TopView(); |
| | | this.AddChidren(view.TopRowView()); |
| | | view.toptitleNameBtn.TextID = MyInternationalizationString.linkageevent; |
| | | view.clickBtn.MouseDownEventHandler += (sender, e) => { RemoveFromParent(); }; |
| | | //加大点击热键 |
| | | var addiocnclick = new Button |
| | | { |
| | | BackgroundColor = ZigbeeColor.Current.LogicTopBackgroundColor, |
| | | Height = Application.GetRealHeight(184), |
| | | LineColor = ZigbeeColor.Current.LogicRowLayoutTopLineColor, |
| | | Width = Application.GetRealWidth(108+58), |
| | | Height = Application.GetRealHeight(72+20), |
| | | X = Application.GetRealWidth(1080 - 108 - 58), |
| | | Y = Application.GetRealHeight(184 - 72), |
| | | }; |
| | | this.AddChidren(topRowLayout); |
| | | |
| | | var titleName = new Button |
| | | { |
| | | TextSize = 17, |
| | | TextColor = ZigbeeColor.Current.LogicTextBlackColor, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | X = Application.GetRealWidth(176), |
| | | Width = Application.GetRealWidth(600), |
| | | Height = Application.GetRealHeight(69), |
| | | Y = Application.GetRealHeight(92), |
| | | TextID = MyInternationalizationString.linkageevent, |
| | | IsBold = true, |
| | | }; |
| | | topRowLayout.AddChidren(titleName); |
| | | |
| | | var clickBtn = new Button |
| | | { |
| | | Width = Application.GetRealWidth(81 + 51), |
| | | Height = Application.GetRealHeight(58 + 40), |
| | | Y = Application.GetRealHeight(98 - 40), |
| | | }; |
| | | topRowLayout.AddChidren(clickBtn); |
| | | clickBtn.MouseDownEventHandler += (sender, e) => |
| | | { |
| | | RemoveFromParent(); |
| | | }; |
| | | |
| | | var back = new Button |
| | | { |
| | | Width = Application.GetRealWidth(30), |
| | | Height = Application.GetRealHeight(51), |
| | | X = Application.GetRealWidth(81), |
| | | Y = Application.GetRealHeight(98), |
| | | //Gravity = Gravity.CenterVertical; |
| | | UnSelectedImagePath = "ZigeeLogic/back.png", |
| | | }; |
| | | topRowLayout.AddChidren(back); |
| | | back.MouseDownEventHandler += (sender, e) => |
| | | { |
| | | RemoveFromParent(); |
| | | }; |
| | | view.topRowLayout.AddChidren(addiocnclick); |
| | | |
| | | var addiocn = new Button |
| | | { |
| | | Width = Application.GetRealWidth(72), |
| | | Height = Application.GetRealHeight(72), |
| | | Width = Application.GetMinRealAverage(72), |
| | | Height = Application.GetMinRealAverage(72), |
| | | X = Application.GetRealWidth(1080 - 108 - 58), |
| | | UnSelectedImagePath = "ZigeeLogic/lockadd.png", |
| | | Y = Application.GetRealHeight(184 - 72 - 20), |
| | | }; |
| | | topRowLayout.AddChidren(addiocn); |
| | | addiocn.MouseUpEventHandler += (sender, e) => |
| | | view.topRowLayout.AddChidren(addiocn); |
| | | |
| | | EventHandler<MouseEventArgs> addclick = (sender, e) => |
| | | { |
| | | //new一个新逻辑对象; |
| | | Common.Logic.CurrentLogic = new Common.Logic(); |
| | | Common.Logic.CurrentLogic.IsEnable = 1;//默认为开 |
| | | Common.Logic.CurrentLogic.LogicType = 1; |
| | | Common.Logic.CurrentLogic.LogicType = 1;//标记自动化类型 |
| | | Common.Logic.CurrentLogic.Relationship = 1; |
| | | Common.Logic.CurrentLogic.LogicName = Language.StringByID(MyInternationalizationString.automation1); |
| | | //Common.Logic.CurrentLogic.LogicCustomPushText = Common.Logic.CurrentLogic.LogicName + Language.StringByID(MyInternationalizationString.defaulttext); |
| | | Common.Logic.CurrentLogic.LogicName = Language.StringByID(MyInternationalizationString.linkageevent); |
| | | var lockLogicCommunalPage = new LockLogicCommunalPage(); |
| | | UserView.HomePage.Instance.AddChidren(lockLogicCommunalPage); |
| | | UserView.HomePage.Instance.PageIndex += 1; |
| | | lockLogicCommunalPage.Show(() => { }); |
| | | }; |
| | | #endregion |
| | | |
| | | addiocnclick.MouseUpEventHandler += addclick; |
| | | addiocn.MouseUpEventHandler += addclick; |
| | | |
| | | #endregion |
| | | middle = new VerticalRefreshLayout |
| | | { |
| | | Y = topRowLayout.Bottom, |
| | | Height = Application.GetRealHeight(1920 - 184), |
| | | Y = view.topRowLayout.Bottom, |
| | | Height = Application.GetRealHeight(Method.H - 184), |
| | | BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, |
| | | }; |
| | | this.AddChidren(middle); |
| | |
| | | /// </summary> |
| | | public async void Read() |
| | | { |
| | | |
| | | CommonPage.Loading.Start(); |
| | | if (Common.Logic.LockLogicList.Count == 0) |
| | | if (!BoolExist()) |
| | | { |
| | | var Idlist = await Send.GetLogicId(1); |
| | | if (Idlist.Count != 0) |
| | |
| | | for (int j = 0; j < listlogic.Count; j++) |
| | | { |
| | | var logic = listlogic[j]; |
| | | if (logic.LogicType == 0) |
| | | if (logic.LogicType != 1) |
| | | { |
| | | continue; |
| | | } |
| | | bool yes = false; |
| | | for (int a = 0; a < logic.Accounts.Count; a++) |
| | | { |
| | | if (logic.Accounts[a]["Account"].ToString() == Config.Instance.Guid) |
| | | { |
| | | //查找自己账号下的创建联动事件; |
| | | yes = true; |
| | | break; |
| | | } |
| | | } |
| | | if (yes) |
| | | { |
| | | Common.Logic.LockLogicList.Add(listlogic[j]); |
| | | } |
| | | Common.Logic.LockLogicList.Add(logic); |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | /// <summary> |
| | | /// 加载自动化列表的界面 |
| | | /// </summary> |
| | | public void Automationview() |
| | | public void Automationview() |
| | | { |
| | | middle.RemoveAll(); |
| | | |
| | | if (Common.Logic.LockLogicList.Count == 0) |
| | | //if (Common.Logic.LockLogicList.Count == 0) |
| | | if (!BoolExist()) |
| | | { |
| | | //就是为了显示引导添加图标; |
| | | var noFrameLayout = new FrameLayout |
| | |
| | | for (int i = 0; i < Common.Logic.LockLogicList.Count; i++) |
| | | { |
| | | var logic = Common.Logic.LockLogicList[i]; |
| | | if (!Exist(logic)) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | var logicRowlayout = new RowLayout |
| | | { |
| | | Width = Application.GetRealWidth(1080), |
| | | Height = Application.GetRealHeight(190), |
| | | LineColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, |
| | | BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor, |
| | | SubViewWidth = Application.GetRealWidth(184),//改变编辑控件宽度多少; |
| | | |
| | | }; |
| | | middle.AddChidren(logicRowlayout); |
| | |
| | | |
| | | var logicswitchBtn = new Button |
| | | { |
| | | Width = Application.GetMinRealAverage(104), |
| | | Height = Application.GetMinRealAverage(63), |
| | | Width = Application.GetRealWidth(104), |
| | | Height = Application.GetRealHeight(63), |
| | | UnSelectedImagePath = "ZigeeLogic/logicclose.png", |
| | | SelectedImagePath = "ZigeeLogic/logicopen.png", |
| | | X = logicRowlayout.Width - Application.GetRealWidth(104 + 58), |
| | |
| | | |
| | | }; |
| | | |
| | | |
| | | ///删除 |
| | | var del = new Button |
| | | { |
| | |
| | | logicRowlayout.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.LockLogicList.Remove(logic); |
| | | Automationview(); |
| | | Send.DelLogic(logic.LogicId); |
| | | } |
| | | }; |
| | | var alert = new ShowMsgControl(ShowMsgType.Confirm, |
| | | Language.StringByID(MyInternationalizationString.doyouwanttodelete), |
| | | Language.StringByID(MyInternationalizationString.confrim)); |
| | | alert.Show(); |
| | | alert.ConfirmClickEvent += () => |
| | | { |
| | | Common.Logic.LockLogicList.Remove(logic); |
| | | Automationview(); |
| | | Send.DelLogic(logic.LogicId); |
| | | }; |
| | | |
| | | }; |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 查找该门锁是否存在自动化 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | private bool BoolExist() |
| | | { |
| | | bool yes = false; |
| | | for (int i = 0; i < Common.Logic.LockLogicList.Count; i++) |
| | | { |
| | | var logic = Common.Logic.LockLogicList[i]; |
| | | if (logic.LogicType != 1) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | if (Exist(logic)) |
| | | { |
| | | yes = true; |
| | | //存在就退出 |
| | | break; |
| | | } |
| | | } |
| | | return yes; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 查找这一条自动化是否属于该门锁 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | private bool Exist(Common.Logic logic) |
| | | { |
| | | for (int j = 0; j < logic.Accounts.Count; j++) |
| | | { |
| | | //Option4是设备mac;Option2是设备端口; |
| | | if (logic.Accounts[j]["Option4"].ToString() == Send.CurrentDoorLock.DeviceAddr) |
| | | { |
| | | //查找是否是那个门锁; |
| | | //如果不是该门锁联动事件不显示出来; |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | } |
| | | } |