黄学彪
2019-11-25 5727cf0b9b54da0a191dd1e23cb5abf21320fbff
ZigbeeApp/Shared/Phone/UserCenter/Safety/SafetyManagementMainForm.cs
@@ -52,11 +52,9 @@
        {
            //清空bodyFrame
            this.ClearBodyFrame();
            if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2)
            {
                //初始化右上角图标
                this.InitTopRightIcon();
            }
            //初始化右上角图标
            this.InitTopRightIcon();
            //初始化全部内存信息
            this.InitAllMemoryData();
@@ -168,28 +166,84 @@
        /// </summary>
        private void InitTopRightIcon()
        {
            var btnIcon = new MostRightIconControl(69, 69);
            btnIcon.UnSelectedImagePath = "Item/More.png";
            topFrameLayout.AddChidren(btnIcon);
            btnIcon.InitControl();
            btnIcon.ButtonClickEvent += (sender, e) =>
            //快捷方式
            var btnShortCut = new MostRightIconControl(69, 69);
            btnShortCut.UnSelectedImagePath = "Safeguard/SafetyShortcut.png";
            btnShortCut.SelectedImagePath = "Safeguard/SafetyShortcutSelected.png";
            if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2)
            {
                //菜单控件
                var frameMenu = new TopRightMenuControl(this, 2);
                //防区列表
                string menu1 = Language.StringByID(R.MyInternationalizationString.uGarrisonAreaList);
                frameMenu.AddRowMenu(menu1, "Item/GarrisonList.png", "Item/GarrisonListSelected.png", () =>
                //快捷方式向左移动
                btnShortCut.X = Application.GetRealWidth(855);
                var btnIcon = new MostRightIconControl(69, 69);
                btnIcon.UnSelectedImagePath = "Item/More.png";
                topFrameLayout.AddChidren(btnIcon);
                btnIcon.InitControl();
                btnIcon.ButtonClickEvent += (sender, e) =>
                {
                    var form = new GarrisonAreaListMenuForm();
                    form.AddForm();
                });
                //密码设置
                string menu2 = Language.StringByID(R.MyInternationalizationString.uPasswordSettion);
                frameMenu.AddRowMenu(menu2, "Item/PswSettion.png", "Item/PswSettionSelected.png", () =>
                    //菜单控件
                    var frameMenu = new TopRightMenuControl(2);
                    //防区列表
                    string menu1 = Language.StringByID(R.MyInternationalizationString.uGarrisonAreaList);
                    frameMenu.AddRowMenu(menu1, "Item/GarrisonList.png", "Item/GarrisonListSelected.png", () =>
                    {
                        HdlCheckLogic.Current.CheckSecondarySecurity(() =>
                        {
                            //验证成功
                            var form = new GarrisonAreaListMenuForm();
                            form.AddForm();
                        },
                        () =>
                        {
                            //请前往个人中心{0}设置二次安全验证方式
                            string msg = Language.StringByID(R.MyInternationalizationString.uGotoCenterAndSetSecondAuthentication).Replace("{0}", "\r\n");
                            this.ShowMassage(ShowMsgType.Confirm, msg, () =>
                            {
                                var form = new UserMain.SecondAuthenticationForm();
                                form.AddForm();
                            });
                        });
                    });
                    //密码设置
                    string menu2 = Language.StringByID(R.MyInternationalizationString.uPasswordSettion);
                    frameMenu.AddRowMenu(menu2, "Item/PswSettion.png", "Item/PswSettionSelected.png", () =>
                    {
                        var form = new PasswordMenuForm();
                        form.AddForm();
                    });
                };
            }
            topFrameLayout.AddChidren(btnShortCut);
            btnShortCut.InitControl();
            if (UserCenterResourse.Option.SafetyShortcut == true)
            {
                //使用快捷方式
                btnShortCut.IsSelected = true;
            }
            btnShortCut.ButtonClickEvent += (sender, e) =>
            {
                if (btnShortCut.IsSelected == true)
                {
                    var form = new SafetyPasswordMenuForm();
                    form.AddForm();
                });
                    //确定取消主页的「安防」捷径?
                    this.ShowMassage(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.uCancelSafetyShortcutMsg), () =>
                    {
                        UserCenterResourse.Option.SafetyShortcut = false;
                        UserCenterResourse.Option.Save();
                        btnShortCut.IsSelected = false;
                    });
                }
                else
                {
                    //确定创建「安防」捷径到主页?
                    this.ShowMassage(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.uCreatSafetyShortcutMsg), () =>
                    {
                        UserCenterResourse.Option.SafetyShortcut = true;
                        UserCenterResourse.Option.Save();
                        btnShortCut.IsSelected = true;
                    });
                }
            };
        }
@@ -444,16 +498,19 @@
            {
                return;
            }
            var timeValue = (DateTime.Now - oldGetOnlineTime).Milliseconds;
            if (timeValue <= 10000)
            if (oldGetOnlineTime.Year != 1900)
            {
                //最少要间隔十秒,才去重新获取
                return;
                var timeValue = (DateTime.Now - oldGetOnlineTime).TotalSeconds;
                if (timeValue < 10)
                {
                    //最少要间隔十秒,才去重新获取
                    return;
                }
            }
            oldGetOnlineTime = DateTime.Now;
            //从设备列表中获取在线状态
            HdlThreadLogic.Current.RunThread(async () =>
            HdlThreadLogic.Current.RunThread(() =>
            {
                //首先获取这些传感器所在的网关
                var listWay = new List<ZbGateway>();
@@ -474,18 +531,18 @@
                        //界面关闭
                        return;
                    }
                    await Common.LocalDevice.Current.GetDeviceListFromGateway(zbway, this.ReceiveDeviceStatuPush, ShowErrorMode.NO);
                    Common.LocalDevice.Current.GetDeviceListFromGateway(zbway, false, this.ReceiveDeviceStatuPush, ShowErrorMode.NO);
                }
            });
        }
        /// <summary>
        /// 接受设备在线推送(不要忘记最后它会推送一个Null的东西过来)
        /// 接受设备在线推送
        /// </summary>
        /// <param name="device"></param>
        private void ReceiveDeviceStatuPush(CommonDevice device)
        {
            if (this.Parent == null || device == null)
            if (this.Parent == null)
            {
                //界面关闭
                return;