陈嘉乐
2020-05-06 f11472b25796a83f70d526b13f2b0cba24c665f2
ZigbeeApp/Shared/Phone/Device/Logic/SoneLogicList.cs
@@ -8,12 +8,23 @@
{
    public class SoneLogicList : FrameLayout
    {
        /// <summary>
        /// 给Sone门锁徐梅更新界面用的
        /// </summary>
        ///
        public SoneLogicList()
        {
            Tag = "SoneLogic";
        }
        /// <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();
@@ -22,7 +33,13 @@
            view.clickBtn.MouseDownEventHandler += (sender, e) =>
            {
                UserView.HomePage.Instance.ScrollEnabled = true;
                if (action != null)
                {
                    action(Send.CurrentDoorLock.IsDoorLockNormallyMode);
                }
                RemoveFromParent();
            };
            var middle = new FrameLayout
@@ -54,10 +71,11 @@
                SelectedImagePath = "ZigeeLogic/openMode.png",
            };
            fLayout.AddChidren(modeIconBtn);
            var logic = await SkipView.GetLogicIfon();
            if (logic != null)
            {
            if (Send.CurrentDoorLock.IsDoorLockNormallyMode)
            {
                /// 查找是否存在时效性自动化;有的话就返回自动化对象;
                var logic = await SkipView.GetLogicIfon();
                fLayout.Height = Application.GetRealHeight(780);//改变高度
                modeIconBtn.IsSelected = true;//改变图标状态
@@ -82,26 +100,33 @@
                    TextSize = 16,
                };
                openModeFl.AddChidren(closeBtn);
                closeBtn.MouseUpEventHandler += (sender,e) => {
                    var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Confirm,
                   Language.StringByID(MyInternationalizationString.doyouwanttodelete),
                   Language.StringByID(MyInternationalizationString.confrim));
                    alert.Show();
                    alert.ConfirmClickEvent += () =>
                closeBtn.MouseUpEventHandler += async (sender, e) =>
                {
                    var result = await UserCenter.DoorLock.DoorLockCommonInfo.DelNormallyOpenMode(Send.CurrentDoorLock);
                    if (result)
                    {
                        Send.DelLogic(logic.LogicId);
                        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("关闭失败");
                    }
                };
                ///显示失效设置时间文本控件
                var timeTextBtn= new Button
                var timeTextBtn = new Button
                {
                    Y = Application.GetRealHeight(127 + 69),
                    X = Application.GetRealWidth(225),
@@ -111,19 +136,23 @@
                    TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                    Text = "时效性常开设置12:20",
                };
                openModeFl.AddChidren(timeTextBtn);
                if (logic != null)
                {
                    ///有时效性常开才显示时间条件文本
                    openModeFl.AddChidren(timeTextBtn);
                }
                ///时效性常开只有一个条件;
                try
                {
                    var y = DateTime.Now.ToString("yy");//那一年
                    var m = DateTime.Now.ToString("mm");//那一月
                    var d = DateTime.Now.ToString("dd");//那一天
                    var h =int.Parse(DateTime.Now.ToString("HH"));//当前系统时间
                    var h = int.Parse(DateTime.Now.ToString("HH"));//当前系统时间
                    var me = DateTime.Now.ToLongDateString();
                    var timeInt = int.Parse(logic.Conditions[0]["DoorLockOpenDelayTime"]);
                    int dayInt = (h + timeInt)/ 24;//算出几天后执行
                    int dayInt = (h + timeInt) / 24;//算出几天后执行
                    int hour = (h + timeInt) % 24;//算出几天后那个时间执行
                    timeTextBtn.Text = "时效性常开设置" + y + "年" + m + "月" + d + dayInt + "号" + timeInt + "时"+ "执行";
                    timeTextBtn.Text = "时效性常开设置" + y + "年" + m + "月" + d + dayInt + "号" + timeInt + "时" + "执行";
                }
                catch { }
@@ -155,7 +184,8 @@
                    TextSize = 15,
                    TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                    TextAlignment = TextAlignment.CenterLeft,
                    Text = "时效性常开设置",
                    // Text = "时效性常开设置",
                    TextID = MyInternationalizationString.timeSetSone,
                };
                modeFl.AddChidren(modeTextBtn);
                ///下一级菜单图标控件
@@ -165,9 +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);
                nextIconBtn.MouseUpEventHandler += (sender, e) =>
                 {
                     LogicView.TipView.ShowConfrimTip(() =>
                     {///再次确认
                       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();
                                 }
                             }
                             catch
                             {
                             }
                         });
                     });
                 };
            }
            #endregion
@@ -202,7 +281,8 @@
                TextSize = 24,
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                TextAlignment = TextAlignment.CenterLeft,
                Text = "常开自动化",
                //Text = "常开自动化",
                TextID = MyInternationalizationString.openAutomationSone,
            };
            addLogicfL.AddChidren(addTextBtn);
            ///添加自动化图标的控件
@@ -217,18 +297,7 @@
            addLogicfL.AddChidren(addIconBtn);
            addIconBtn.MouseUpEventHandler += (sender, e) =>
            {
                ZigBee.Device.DoorLock doorLock = null;
                if (doorLock == null)
                {
                    ///防止抛异常
                    doorLock = new ZigBee.Device.DoorLock();
                }
                Send.CurrentDoorLock = doorLock;
                Common.Logic.LogicDviceList.Clear();
                if (Common.Logic.LogicDviceList.Count == 0)
                {
                    Common.Logic.LogicDviceList.AddRange(LocalDevice.Current.listAllDevice.ToArray());
                }
                //读取系统当前时间:时-分
                //读取系统当前时间:时-分
                var h = DateTime.Now.ToString("HH");
@@ -245,7 +314,7 @@
                timeConditionsInfo.Add("StartMin", m);
                Dictionary<string, object> actionsInfo = new Dictionary<string, object>();
                actionsInfo.Add("LinkType", 8);
                actionsInfo.Add("DeviceAddr", doorLock.DeviceAddr);
                actionsInfo.Add("DeviceAddr", Send.CurrentDoorLock.DeviceAddr);
                actionsInfo.Add("Epoint", "200");
                actionsInfo.Add("PassData", "055704010113");//默认门锁常关
                //new一个新逻辑对象;
@@ -328,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
@@ -352,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
                {