陈嘉乐
2020-05-06 f11472b25796a83f70d526b13f2b0cba24c665f2
ZigbeeApp/Shared/Phone/Device/Logic/SoneLogicList.cs
@@ -11,12 +11,20 @@
        /// <summary>
        /// 给Sone门锁徐梅更新界面用的
        /// </summary>
        ///
        public SoneLogicList()
        {
            Tag = "SoneLogic";
        }
        public async void Show(Action action = null, bool bool_If = false)
        /// <summary>
        ///
        /// </summary>
        /// <param name="action">给徐梅刷新界面用的</param>
        /// <param name="bool_If"></param>
        public Action<bool> action;
        public async void Show()
        {
            #region  界面的布局代码
            UserView.HomePage.Instance.ScrollEnabled = false;//锁住左滑
            TopView view = new TopView();
@@ -27,7 +35,7 @@
                UserView.HomePage.Instance.ScrollEnabled = true;
                if (action != null)
                {
                    action();
                    action(Send.CurrentDoorLock.IsDoorLockNormallyMode);
                }
                RemoveFromParent();
@@ -64,7 +72,7 @@
            };
            fLayout.AddChidren(modeIconBtn);
            if (bool_If)
            if (Send.CurrentDoorLock.IsDoorLockNormallyMode)
            {
                /// 查找是否存在时效性自动化;有的话就返回自动化对象;
                var logic = await SkipView.GetLogicIfon();
@@ -92,34 +100,29 @@
                    TextSize = 16,
                };
                openModeFl.AddChidren(closeBtn);
                closeBtn.MouseUpEventHandler += (sender, e) =>
                closeBtn.MouseUpEventHandler += async (sender, e) =>
                {
                    var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Confirm,
                   Language.StringByID(MyInternationalizationString.doyouwanttodelete),
                   Language.StringByID(MyInternationalizationString.confrim));
                    alert.Show();
                    alert.ConfirmClickEvent += async () =>
                    var result = await UserCenter.DoorLock.DoorLockCommonInfo.DelNormallyOpenMode(Send.CurrentDoorLock);
                    if (result)
                    {
                        var bool_ = await UserCenter.DoorLock.DoorLockCommonInfo.DelNormallyOpenMode(new ZigBee.Device.DoorLock { });
                        if (bool_)
                        {
                        }
                        else { }
                        if (logic != null)
                        {
                            ///有可能只有常开模式,没有时效性自动化
                            ///没有判断的话,逻辑会为空,抛出异常;
                            Send.DelLogic(logic.LogicId);
                        }
                        Send.CurrentDoorLock.IsDoorLockNormallyMode = false;
                        this.RemoveFromParent();
                        var soneLogicList = new SoneLogicList();
                        UserView.HomePage.Instance.AddChidren(soneLogicList);
                        UserView.HomePage.Instance.PageIndex += 1;
                        soneLogicList.Show();
                    };
                    }
                    else
                    {
                        LogicView.TipView.ShowFlashTip("关闭失败");
                    }
                };
                ///显示失效设置时间文本控件
@@ -192,59 +195,58 @@
                    Height = Application.GetMinRealAverage(104),
                    X = Application.GetRealWidth(861),
                    Y = Application.GetRealHeight(17),
                    UnSelectedImagePath = "ZigeeLogic/next.png",
                    UnSelectedImagePath = "ZigeeLogic/nextIconSone.png",
                };
                modeFl.AddChidren(nextIconBtn);
                var clickBtn = new Button
                {
                    Y = Application.GetRealHeight(478),
                    X = Application.GetRealWidth(58),
                    Height = Application.GetRealHeight(138),
                    Width = Application.GetRealWidth(1022),
                };
                // modeFl.AddChidren(clickBtn);
                nextIconBtn.MouseUpEventHandler += (sender, e) =>
               {
                   Logic.LogicView.TipView tipView = new LogicView.TipView();
                 {
                   FrameLayout fLayout1 = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicTranslucentColor };
                   this.AddChidren(fLayout1);
                   tipView.ShowTip(fLayout1);
                   //string msg = Language.StringByID(R.MyInternationalizationString.SetDoorLockNomallyOpen).Replace("{0}", "\r\n");
                   //var confirm = Language.StringByID(R.MyInternationalizationString.Confrim);
                   //var alert = new UserCenter.DoorLock.ShowDoorLockMsgControl(UserCenter.DoorLock.ShowDoorLockMsgControl.DoorLockMsgType.Confirm, msg, confirm);
                   //alert.Show();
                   //alert.ConfirmClickEvent += () =>
                   // {
                   //     string msgTimeInValidSetting = Language.StringByID(R.MyInternationalizationString.DoorLockOpenAllTheTime);
                   //     var timeConfrim = Language.StringByID(R.MyInternationalizationString.Confrim);
                   //     var alertTimeInValidSetting = new UserCenter.DoorLock.ShowDoorLockMsgControl(UserCenter.DoorLock.ShowDoorLockMsgControl.DoorLockMsgType.InValid, msgTimeInValidSetting, timeConfrim);
                   //     alertTimeInValidSetting.Show();
                   //     alertTimeInValidSetting.InvalidTimeAction += async (obj) =>
                   //     {
                     LogicView.TipView.ShowConfrimTip(() =>
                   //         var result = await new ZigBee.Device.DoorLock { }.SetNormallyOpenModeFuncAsync(true);
                   //         //var res = await Shared.Phone.Device.Logic.SkipView.LockAddModifyLogic(DoorLockCommonInfo.NormallyOpenModeInvalidTime, doorLock);
                   //     };
                   // };
                     {///再次确认
                       LogicView.TipView.ShowInputTip(true, async (str) =>
                         {///确认发送命令
                           try
                             {
                               ///xm
                               var result = await UserCenter.DoorLock.DoorLockCommonInfo.SetNormallyOpenModeFuncAsync(Send.CurrentDoorLock);
                                 if (!result)
                                 {
                                     LogicView.TipView.ShowFlashTip("开启失败");
                                     return;
                                 }
                                 else
                                 {
                                   ///因为有常开模式下才可以创建失效逻辑;
                                   SkipView.GetLogicAll();//删除之前所有失效逻辑
                                   var addResult = await SkipView.LockAddModifyLogic(int.Parse(str), Send.CurrentDoorLock);//添加一条失效逻辑
                                   if (!addResult)
                                     {
                                         ///提示失败
                                         LogicView.TipView.ShowFlashTip("添加失败");
                                         return;
                                     }
                                     Send.CurrentDoorLock.IsDoorLockNormallyMode = true;
                                     this.RemoveFromParent();
                                     var soneLogicList = new SoneLogicList();
                                     UserView.HomePage.Instance.AddChidren(soneLogicList);
                                     UserView.HomePage.Instance.PageIndex += 1;
                                     soneLogicList.Show();
                   //   //UserCenter.DoorLock.DoorLockCommonInfo.NomallyOpenModeInvalidTimeDialog(new ZigBee.Device.DoorLock { });
                                 }
                             }
                             catch
                             {
                   //UserCenter.DoorLock.DoorLockCommonInfo.NomallyOpenModeStartDialog(new ZigBee.Device.DoorLock { }, () =>
                   //{
                   //});
                   // var d = await SkipView.LockAddModifyLogic(12, Send.CurrentDoorLock);
                             }
                         });
                   // var contr = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Tip, "sdgdgdfhfhfhgjggfg");
                   //contr.Show();
                   //contr.ConfirmClickEvent += () =>
                   //  {
                   //  };
                     });
                   //UserCenter.DoorLock.DoorLockCommonInfo.NomallyOpenModeInvalidTimeDialog();
               };
                 };
            }
            #endregion
@@ -395,14 +397,11 @@
        /// 加载自动化列表
        /// </summary>
        /// <param name="verticalRefresh"></param>
        RowLayout selectedRow = new RowLayout() { Tag = "0" };//记录左滑状态
        int i = 1;
        private void RefreshView(VerticalRefreshLayout verticalRefresh)
        {
            verticalRefresh.RemoveAll();
            for (int i = 0; i < 6; i++)
            {
                Common.Logic.SoneLogicList.Add(new Common.Logic { LogicName = i.ToString() });
            }
            foreach (var logic in Common.Logic.SoneLogicList)
            {
                #region  自动化布局View
@@ -419,17 +418,19 @@
                    LineColor = ZigbeeColor.Current.LogicBackgroundColor,
                    BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor,
                    SubViewWidth = Application.GetRealWidth(184),//改变编辑控件宽度多少;
                    Tag = i.ToString(),
                };
                fLayout.AddChidren(logicRow);
                //左滑菜单事件
                logicRow.OpenMenuAction += () =>
                {
                    //if (selectedRow.Tag.ToString() != logicRowlayout.Tag.ToString())
                    //{   //保留左滑只有一个;
                    //    selectedRow.HideMenu();//
                    //}
                    //selectedRow = logicRowlayout;
                    if (selectedRow.Tag.ToString() != logicRow.Tag.ToString())
                    {   //保留左滑只有一个;
                        selectedRow.HideMenu();//
                    }
                    selectedRow = logicRow;
                };
                i++;
                ///显示逻辑名称的控件
                var nameBtn = new Button
                {