xm
2020-07-21 9a4b76398009cf76c508d61f7e48fb6f5cb7ac2d
ZigbeeApp/Shared/Phone/UserCenter/UserMain/SecondAuthenticationForm.cs
@@ -23,6 +23,13 @@
            //设置头部信息
            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uSecondAuthentication));
            var btntitle = (Button)topFrameLayout.GetTagByKey("txtTitle");
            btntitle.MouseLongEventHandler += (sender, e) =>
            {
                //显示数字命令窗口
                this.ShowKeyNumberComandDialog();
            };
            //初始化中部信息
            this.InitMiddleFrame();
        }
@@ -40,34 +47,44 @@
            frameTop.BackgroundColor = UserCenterColor.Current.White;
            bodyFrameLayout.AddChidren(frameTop);
            var rowFinger = new FrameRowControl(frameTop.rowSpace / 2);
            rowFinger.UseClickStatu = false;
            frameTop.AddChidren(rowFinger);
            //指纹验证
            var btnFinger = rowFinger.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uFingerprintAuthentication), 400, 58);
            btnFinger.Y = Application.GetRealHeight(12) + rowFinger.chidrenYaxis;
            rowFinger.AddChidren(btnFinger, ChidrenBindMode.NotBind);
            //仅对本机有效
            var btnEffect= rowFinger.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uOnlyEffectToThisPhone), 400, 40);
            btnEffect.Y = Application.GetRealHeight(72) + rowFinger.chidrenYaxis;
            btnEffect.TextSize = 12;
            btnEffect.TextColor = UserCenterColor.Current.TextGrayColor1;
            rowFinger.AddChidren(btnEffect, ChidrenBindMode.NotBind);
            //开关按钮
            var btnFingerSwicth = rowFinger.AddMostRightSwitchIcon();
            btnFingerSwicth.IsSelected = UserCenterResourse.Option.FingerprintAuthentication;
            //底线
            rowFinger.AddBottomLine();
            MostRightIconControl btnFingerSwicth = null;
            var touchIDSupper = TouchIDUtils.getTouchIDSupperType();
            if (touchIDSupper == TouchIDUtils.TouchIDSupperType.TouchID)
            {
                var rowFinger = new FrameRowControl(frameTop.rowSpace / 2);
                rowFinger.UseClickStatu = false;
                frameTop.AddChidren(rowFinger);
                //指纹验证
                var btnFinger = rowFinger.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uFingerprintAuthentication), 400, 58);
                btnFinger.Y = Application.GetRealHeight(12) + rowFinger.chidrenYaxis;
                rowFinger.AddChidren(btnFinger, ChidrenBindMode.NotBind);
                //仅对本机有效
                var btnEffect = rowFinger.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uOnlyEffectToThisPhone), 400, 40);
                btnEffect.Y = Application.GetRealHeight(72) + rowFinger.chidrenYaxis;
                btnEffect.TextSize = 12;
                btnEffect.TextColor = UserCenterColor.Current.TextGrayColor1;
                rowFinger.AddChidren(btnEffect, ChidrenBindMode.NotBind);
                //开关按钮
                btnFingerSwicth = rowFinger.AddMostRightSwitchIcon();
                btnFingerSwicth.IsSelected = UserCenterResourse.AccountOption.FingerprintAuthentication;
                //底线
                rowFinger.AddBottomLine();
            }
            var rowPsw = new FrameRowControl(frameTop.rowSpace / 2);
            frameTop.AddChidren(rowPsw);
            //如果这个手机不支持TouchId的话,则容器减去这个行的高度
            if (touchIDSupper != TouchIDUtils.TouchIDSupperType.TouchID)
            {
                frameTop.Height -= rowPsw.Height;
            }
            //密码验证
            rowPsw.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uPasswordAuthentication), 400);
            //右箭头
            rowPsw.AddRightArrow();
            //去设置
            var btnSettion1 = rowPsw.AddMostRightView(Language.StringByID(R.MyInternationalizationString.uGotoSettion), 400);
            if (string.IsNullOrEmpty(UserCenterResourse.Option.PswAuthentication) == false)
            if (string.IsNullOrEmpty(UserCenterResourse.AccountOption.PswAuthentication) == false)
            {
                //去修改
                btnSettion1.TextID = R.MyInternationalizationString.uGotoEditor;
@@ -83,20 +100,25 @@
            rowGesture.AddRightArrow();
            //去设置
            var btnSettion2 = rowGesture.AddMostRightView(Language.StringByID(R.MyInternationalizationString.uGotoSettion), 400);
            if (string.IsNullOrEmpty(UserCenterResourse.Option.GestureAuthentication) == false)
            if (string.IsNullOrEmpty(UserCenterResourse.AccountOption.GestureAuthentication) == false)
            {
                //去修改
                btnSettion2.TextID = R.MyInternationalizationString.uGotoEditor;
            }
            //二次安全验证将用于下列操作
            var btnTitle = new NormalViewControl(800, 49, true);
            var btnTitle = new NormalViewControl(800, 50, true);
            btnTitle.X = ControlCommonResourse.XXLeft;
            btnTitle.Y = frameTop.Bottom + Application.GetRealHeight(35);
            btnTitle.Y = frameTop.Bottom + Application.GetRealHeight(34);
            btnTitle.TextSize = 12;
            btnTitle.TextColor = UserCenterColor.Current.TextGrayColor3;
            btnTitle.TextID = R.MyInternationalizationString.uSecondarySecurityWillBeUsedForTheFollowingOperations;
            bodyFrameLayout.AddChidren(btnTitle);
            btnTitle.ButtonClickEvent += (sender, e) =>
            {
                //隐匿功能点击
                this.HideOptionClick(btnTitle);
            };
            var frameButtom = new FrameListControl(12);
            frameButtom.Y = btnTitle.Bottom + Application.GetRealHeight(23);
@@ -133,7 +155,7 @@
            var btnLockSwicth = rowLock.AddMostRightSwitchIcon();
            //底线
            rowLock.AddBottomLine();
            btnLockSwicth.IsSelected = UserCenterResourse.Option.DoorUnLockByRemote;
            btnLockSwicth.IsSelected = UserCenterResourse.AccountOption.DoorUnLockByRemote;
            var rowSafety = new FrameRowControl(frameButtom.rowSpace / 2);
            rowSafety.UseClickStatu = false;
@@ -146,34 +168,48 @@
            btnMsg2.TextColor = UserCenterColor.Current.TextGrayColor2;
            //指纹验证
            btnFingerSwicth.ButtonClickEvent += (sender, e) =>
            if (btnFingerSwicth != null)
            {
                if (btnFingerSwicth.IsSelected == false)
                btnFingerSwicth.ButtonClickEvent += (sender, e) =>
                {
                    TouchIDUtils.TouchIDSupperType type = TouchIDUtils.getTouchIDSupperType();
                    if (type == TouchIDUtils.TouchIDSupperType.None)
                    if (btnFingerSwicth.IsSelected == false)
                    {
                        //开启指纹验证失败!请前往手机{0}设置开启指纹开锁验证
                        string msg = Language.StringByID(R.MyInternationalizationString.uUseFingerprintAuthenticationFailMsg);
                        if (msg.Contains("{0}") == true)
                        TouchIDUtils.TouchIDSupperType type = TouchIDUtils.getTouchIDSupperType();
                        if (type == TouchIDUtils.TouchIDSupperType.None)
                        {
                            msg = string.Format(msg, "\r\n");
                            //开启指纹验证失败!请前往手机{0}设置开启指纹开锁验证
                            string msg = Language.StringByID(R.MyInternationalizationString.uUseFingerprintAuthenticationFailMsg);
                            msg = msg.Replace("{0}", "\r\n");
                            this.ShowMassage(ShowMsgType.Normal, msg);
                            return;
                        }
                        this.ShowMassage(ShowMsgType.Normal, msg);
                        return;
                        //将Touch ID用于「ZigBee」{0}更改安防设置和开启门锁时使用
                        string msg2 = Language.StringByID(R.MyInternationalizationString.uUseFingerprintAuthenticationMsg);
                        msg2 = msg2.Replace("{0}", "\r\n");
                        this.ShowMassage(ShowMsgType.Confirm, msg2, () =>
                        {
                            //如果设置有安全验证,想要修改它,必须先通过安全验证
                            //如果没有设置有安全验证,则无需验证
                            HdlCheckLogic.Current.CheckSecondarySecurity(
                                    () => { this.DoFingerprintAuthentication(btnFingerSwicth, btnLockSwicth); },//处理指纹验证
                                    () => { this.DoFingerprintAuthentication(btnFingerSwicth, btnLockSwicth); });//处理指纹验证
                        });
                    }
                }
                //如果设置有安全验证,想要修改它,必须先通过安全验证
                //如果没有设置有安全验证,则无需验证
                HdlCheckLogic.Current.CheckSecondarySecurity(
                    () => { this.DoFingerprintAuthentication(btnFingerSwicth, btnLockSwicth); },//处理指纹验证
                    () => { this.DoFingerprintAuthentication(btnFingerSwicth, btnLockSwicth); });//处理指纹验证
            };
                    else
                    {
                        //如果设置有安全验证,想要修改它,必须先通过安全验证
                        //如果没有设置有安全验证,则无需验证
                        HdlCheckLogic.Current.CheckSecondarySecurity(
                                () => { this.DoFingerprintAuthentication(btnFingerSwicth, btnLockSwicth); },//处理指纹验证
                                () => { this.DoFingerprintAuthentication(btnFingerSwicth, btnLockSwicth); });//处理指纹验证
                    }
                };
            }
            //密码验证
            rowPsw.ButtonClickEvent += (sender, e) =>
            {
                //如果没有密码验证
                if (string.IsNullOrEmpty(UserCenterResourse.Option.PswAuthentication) == true)
                if (string.IsNullOrEmpty(UserCenterResourse.AccountOption.PswAuthentication) == true)
                {
                    //如果设置有其他验证方式,则需要验证,否则直接跳过验证
                    HdlCheckLogic.Current.CheckSecondarySecurity(
@@ -190,15 +226,17 @@
            rowGesture.ButtonClickEvent += (sender, e) =>
            {
                //如果没有手势验证
                if (string.IsNullOrEmpty(UserCenterResourse.Option.GestureAuthentication) == true)
                if (string.IsNullOrEmpty(UserCenterResourse.AccountOption.GestureAuthentication) == true)
                {
                    //如果设置有其他验证方式,则需要验证,否则直接跳过验证
                    HdlCheckLogic.Current.CheckSecondarySecurity(
                   () => { },
                   () => { });
                   () => { var form = new Password.EditorGesturePasswordForm(); form.AddForm(); },
                   () => { var form = new Password.EditorGesturePasswordForm(); form.AddForm(); });
                }
                else
                {
                    var form = new Password.EditorGesturePasswordForm();
                    form.AddForm();
                }
            };
            //远程开锁
@@ -237,31 +275,23 @@
                    this.ShowMassage(ShowMsgType.Normal, msg);
                    return;
                }
                //将Touch ID用于「ZigBee」{0}更改安防设置和开启门锁时使用
                string msg2 = Language.StringByID(R.MyInternationalizationString.uUseFingerprintAuthenticationMsg);
                if (msg2.Contains("{0}") == true)
                {
                    msg2 = string.Format(msg2, "\r\n");
                }
                this.ShowMassage(ShowMsgType.Confirm, msg2, () =>
                {
                    UserCenterResourse.Option.FingerprintAuthentication = !btnFingerSwicth.IsSelected;
                    UserCenterResourse.Option.Save();
                    //重新刷新界面
                    this.InitMiddleFrame();
                });
                UserCenterResourse.AccountOption.FingerprintAuthentication = !btnFingerSwicth.IsSelected;
                UserCenterResourse.AccountOption.Save();
                //重新刷新界面
                this.InitMiddleFrame();
            }
            else
            {
                if (string.IsNullOrEmpty(UserCenterResourse.Option.GestureAuthentication) == true
                    && string.IsNullOrEmpty(UserCenterResourse.Option.PswAuthentication) == true
                if (string.IsNullOrEmpty(UserCenterResourse.AccountOption.GestureAuthentication) == true
                    && string.IsNullOrEmpty(UserCenterResourse.AccountOption.PswAuthentication) == true
                    && btnLockSwicth.IsSelected == true)
                {
                    //所有验证都取消了,则取消远程开锁功能
                    UserCenterResourse.Option.DoorUnLockByRemote = false;
                    UserCenterResourse.AccountOption.DoorUnLockByRemote = false;
                }
                UserCenterResourse.Option.FingerprintAuthentication = !btnFingerSwicth.IsSelected;
                UserCenterResourse.Option.Save();
                UserCenterResourse.AccountOption.FingerprintAuthentication = !btnFingerSwicth.IsSelected;
                UserCenterResourse.AccountOption.Save();
                //重新刷新界面
                this.InitMiddleFrame();
            }
@@ -278,11 +308,11 @@
        private void DoRemoteUnLocks(MostRightIconControl btnLockSwicth)
        {
            if (btnLockSwicth.IsSelected == false
                && string.IsNullOrEmpty(UserCenterResourse.Option.GestureAuthentication) == true
                && string.IsNullOrEmpty(UserCenterResourse.Option.PswAuthentication) == true)
                && string.IsNullOrEmpty(UserCenterResourse.AccountOption.GestureAuthentication) == true
                && string.IsNullOrEmpty(UserCenterResourse.AccountOption.PswAuthentication) == true)
            {
                TouchIDUtils.TouchIDSupperType type = TouchIDUtils.getTouchIDSupperType();
                if (type == TouchIDUtils.TouchIDSupperType.None || UserCenterResourse.Option.FingerprintAuthentication == false)
                if (type == TouchIDUtils.TouchIDSupperType.None || UserCenterResourse.AccountOption.FingerprintAuthentication == false)
                {
                    //远程开锁开启失败,请先设置{0}二次安全验证方式
                    string msg = Language.StringByID(R.MyInternationalizationString.uUseUnLockByRemoteFailMsg);
@@ -294,8 +324,8 @@
                    return;
                }
            }
            UserCenterResourse.Option.DoorUnLockByRemote = !btnLockSwicth.IsSelected;
            UserCenterResourse.Option.Save();
            UserCenterResourse.AccountOption.DoorUnLockByRemote = !btnLockSwicth.IsSelected;
            UserCenterResourse.AccountOption.Save();
            //重新刷新界面
            this.InitMiddleFrame();
        }
@@ -316,5 +346,113 @@
        }
        #endregion
        #region ■ 隐匿功能___________________________
        /// <summary>
        /// 点击合计
        /// </summary>
        private int clickCount = 0;
        /// <summary>
        /// 点击的那瞬间的时间
        /// </summary>
        private DateTime clickTime;
        /// <summary>
        /// 隐匿功能
        /// </summary>
        private void HideOptionClick(NormalViewControl btnTitle)
        {
            if (clickCount == 0)
            {
                clickTime = DateTime.Now;
            }
            clickCount++;
            if (clickCount >= 10)
            {
                if ((DateTime.Now - clickTime).TotalSeconds > 3)
                {
                    clickCount = 0;
                    return;
                }
                btnTitle.CanClick = false;
                HdlThreadLogic.Current.RunThread(() =>
                {
                    this.ShowProgressBar();
                    var result = HdlBackupLogic.Current.LoadHideOption();
                    this.CloseProgressBar();
                    if (result == true)
                    {
                        this.ShowMassage(ShowMsgType.Tip, "刷新隐匿配置成功");
                    }
                    else
                    {
                        this.ShowMassage(ShowMsgType.Tip, "刷新隐匿配置失败");
                    }
                });
            }
        }
        /// <summary>
        /// 显示数字命令窗口
        /// </summary>
        private void ShowKeyNumberComandDialog()
        {
            //生成一个弹窗画面
            var dialogForm = new DialogInputControl();
            dialogForm.SetTitleText("?????");
            //按下确认按钮
            dialogForm.ComfirmClickEvent += ((textValue) =>
            {
                dialogForm.CloseDialog();
                if (textValue.StartsWith("2887") == true)
                {
                    var myTime = DateTime.Now;
                    string strTime1 = myTime.ToString("HHmm");
                    int value1 = Convert.ToInt32(strTime1.Substring(3, 1));
                    string check1 = "2887" + strTime1 + (7 + value1).ToString();
                    myTime = myTime.AddMinutes(-1);
                    string strTime2 = myTime.ToString("HHmm");
                    int value2 = Convert.ToInt32(strTime2.Substring(3, 1));
                    string check2 = "2887" + strTime2 + (7 + value2).ToString();
                    myTime = myTime.AddMinutes(2);
                    string strTime3 = myTime.ToString("HHmm");
                    int value3 = Convert.ToInt32(strTime3.Substring(3, 1));
                    string check3 = "2887" + strTime3 + (7 + value3).ToString();
                    if (textValue == check1 || textValue == check2 || textValue == check3)
                    {
                        //开启隐藏菜单
                        UserCenterResourse.HideOption.CenterHideMenu = 1;
                    }
                }
                if (textValue == "84651666")
                {
                    //显示设备历史版本
                    UserCenterResourse.HideOption.DeviceHistory = 1;
                }
                if (textValue == "12349")
                {
                    //强制跳转真实设备界面
                    UserCenterResourse.HideOption.GotoRealDeviceForm = 1;
                }
                if (textValue == "12348")
                {
                    //强制跳转网关界面
                    UserCenterResourse.HideOption.GotoGatewayProductInfoForm = 1;
                }
                if (textValue == "abcdef1")
                {
                    //强制变更常开模式的时间为分钟
                    UserCenterResourse.HideOption.DoorLockNomallyOpenTimeMode = 1;
                }
                this.ShowMassage(ShowMsgType.Tip, "Ok!");
            });
        }
        #endregion
    }
}