using System; using System.Collections.Generic; using System.Text; namespace Shared.Phone.UserCenter.UserMain { /// /// 二次安全验证 /// public class SecondAuthenticationForm : EditorCommonForm { #region ■ 变量声明___________________________ #endregion #region ■ 初始化_____________________________ /// /// 画面显示(底层会固定调用此方法,借以完成画面创建) /// public void ShowForm() { //设置头部信息 base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uSecondAuthentication)); //初始化中部信息 this.InitMiddleFrame(); } /// /// 初始化中部信息 /// private void InitMiddleFrame() { //清空bodyFrame this.ClearBodyFrame(); var frameTop = new FrameListControl(12); frameTop.Height = Application.GetRealHeight(446); 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(); var rowPsw = new FrameRowControl(frameTop.rowSpace / 2); frameTop.AddChidren(rowPsw); //密码验证 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) { //去修改 btnSettion1.TextID = R.MyInternationalizationString.uGotoEditor; } //底线 rowPsw.AddBottomLine(); var rowGesture = new FrameRowControl(frameTop.rowSpace / 2); frameTop.AddChidren(rowGesture); //手势验证 rowGesture.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uGestureAuthentication), 400); //右箭头 rowGesture.AddRightArrow(); //去设置 var btnSettion2 = rowGesture.AddMostRightView(Language.StringByID(R.MyInternationalizationString.uGotoSettion), 400); if (string.IsNullOrEmpty(UserCenterResourse.Option.GestureAuthentication) == false) { //去修改 btnSettion2.TextID = R.MyInternationalizationString.uGotoEditor; } //二次安全验证将用于下列操作 var btnTitle = new NormalViewControl(800, 49, true); btnTitle.X = ControlCommonResourse.XXLeft; btnTitle.Y = frameTop.Bottom + Application.GetRealHeight(35); btnTitle.TextSize = 12; btnTitle.TextColor = UserCenterColor.Current.TextGrayColor3; btnTitle.TextID = R.MyInternationalizationString.uSecondarySecurityWillBeUsedForTheFollowingOperations; bodyFrameLayout.AddChidren(btnTitle); var frameButtom = new FrameListControl(12); frameButtom.Y = btnTitle.Bottom + Application.GetRealHeight(23); frameButtom.Height = Application.GetRealHeight(449); frameButtom.BackgroundColor = UserCenterColor.Current.White; bodyFrameLayout.AddChidren(frameButtom); var rowAdmin = new FrameRowControl(frameButtom.rowSpace / 2); rowAdmin.UseClickStatu = false; frameButtom.AddChidren(rowAdmin); //管理员授权 rowAdmin.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uAdministratorAuthorization), 400); //授权成员成为管理员 var btnMsg = rowAdmin.AddMostRightView(Language.StringByID(R.MyInternationalizationString.uAuthorizedMembersBecomeAdministrators), 400); btnMsg.TextSize = 12; btnMsg.TextColor = UserCenterColor.Current.TextGrayColor2; //底线 rowAdmin.AddBottomLine(); var rowLock = new FrameRowControl(frameTop.rowSpace / 2); rowLock.UseClickStatu = false; frameButtom.AddChidren(rowLock); //远程开锁 var btnUnLock = rowLock.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uRemoteUnLocks), 400, 58); btnUnLock.Y = Application.GetRealHeight(12) + rowLock.chidrenYaxis; rowLock.AddChidren(btnUnLock, ChidrenBindMode.NotBind); //通过APP开启门锁 var btnUnLockByApp = rowLock.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uUnLockDoorByApp), 400, 40); btnUnLockByApp.Y = Application.GetRealHeight(72) + rowLock.chidrenYaxis; btnUnLockByApp.TextSize = 12; btnUnLockByApp.TextColor = UserCenterColor.Current.TextGrayColor1; rowLock.AddChidren(btnUnLockByApp, ChidrenBindMode.NotBind); //开关按钮 var btnLockSwicth = rowLock.AddMostRightSwitchIcon(); //底线 rowLock.AddBottomLine(); btnLockSwicth.IsSelected = UserCenterResourse.Option.DoorUnLockByRemote; var rowSafety = new FrameRowControl(frameButtom.rowSpace / 2); rowSafety.UseClickStatu = false; frameButtom.AddChidren(rowSafety); //安防设置 rowSafety.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uSafetySettion), 400); //配置防区 var btnMsg2 = rowSafety.AddMostRightView(Language.StringByID(R.MyInternationalizationString.uGarrisonConfiguration), 400); btnMsg2.TextSize = 12; btnMsg2.TextColor = UserCenterColor.Current.TextGrayColor2; //指纹验证 btnFingerSwicth.ButtonClickEvent += (sender, e) => { if (btnFingerSwicth.IsSelected == false) { TouchIDUtils.TouchIDSupperType type = TouchIDUtils.getTouchIDSupperType(); if (type == TouchIDUtils.TouchIDSupperType.None) { //开启指纹验证失败!请前往手机{0}设置开启指纹开锁验证 string msg = Language.StringByID(R.MyInternationalizationString.uUseFingerprintAuthenticationFailMsg); msg = msg.Replace("{0}", "\r\n"); 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); });//处理指纹验证 }); } else { //如果设置有安全验证,想要修改它,必须先通过安全验证 //如果没有设置有安全验证,则无需验证 HdlCheckLogic.Current.CheckSecondarySecurity( () => { this.DoFingerprintAuthentication(btnFingerSwicth, btnLockSwicth); },//处理指纹验证 () => { this.DoFingerprintAuthentication(btnFingerSwicth, btnLockSwicth); });//处理指纹验证 } }; //密码验证 rowPsw.ButtonClickEvent += (sender, e) => { //如果没有密码验证 if (string.IsNullOrEmpty(UserCenterResourse.Option.PswAuthentication) == true) { //如果设置有其他验证方式,则需要验证,否则直接跳过验证 HdlCheckLogic.Current.CheckSecondarySecurity( () => { var form = new Password.EditorSecondaryPasswordForm(); form.AddForm(); }, () => { var form = new Password.EditorSecondaryPasswordForm(); form.AddForm(); }); } else { var form = new Password.EditorSecondaryPasswordForm(); form.AddForm(); } }; //手势验证 rowGesture.ButtonClickEvent += (sender, e) => { //如果没有手势验证 if (string.IsNullOrEmpty(UserCenterResourse.Option.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(); } }; //远程开锁 btnLockSwicth.ButtonClickEvent += (sender, e) => { //如果设置有安全验证,想要修改它,必须先通过安全验证 //如果没有设置有安全验证,则无需验证 HdlCheckLogic.Current.CheckSecondarySecurity( () => { this.DoRemoteUnLocks(btnLockSwicth); },//处理远程开锁 () => { this.DoRemoteUnLocks(btnLockSwicth); });//处理远程开锁 }; } #endregion #region ■ 指纹验证___________________________ /// /// 指纹验证 /// /// /// private void DoFingerprintAuthentication(MostRightIconControl btnFingerSwicth, MostRightIconControl btnLockSwicth) { if (btnFingerSwicth.IsSelected == false) { TouchIDUtils.TouchIDSupperType type = TouchIDUtils.getTouchIDSupperType(); if (type == TouchIDUtils.TouchIDSupperType.None) { //开启指纹验证失败!请前往手机{0}设置开启指纹开锁验证 string msg = Language.StringByID(R.MyInternationalizationString.uUseFingerprintAuthenticationFailMsg); if (msg.Contains("{0}") == true) { msg = string.Format(msg, "\r\n"); } this.ShowMassage(ShowMsgType.Normal, msg); return; } UserCenterResourse.Option.FingerprintAuthentication = !btnFingerSwicth.IsSelected; UserCenterResourse.Option.Save(); //重新刷新界面 this.InitMiddleFrame(); } else { if (string.IsNullOrEmpty(UserCenterResourse.Option.GestureAuthentication) == true && string.IsNullOrEmpty(UserCenterResourse.Option.PswAuthentication) == true && btnLockSwicth.IsSelected == true) { //所有验证都取消了,则取消远程开锁功能 UserCenterResourse.Option.DoorUnLockByRemote = false; } UserCenterResourse.Option.FingerprintAuthentication = !btnFingerSwicth.IsSelected; UserCenterResourse.Option.Save(); //重新刷新界面 this.InitMiddleFrame(); } } #endregion #region ■ 远程开锁___________________________ /// /// 远程开锁 /// /// private void DoRemoteUnLocks(MostRightIconControl btnLockSwicth) { if (btnLockSwicth.IsSelected == false && string.IsNullOrEmpty(UserCenterResourse.Option.GestureAuthentication) == true && string.IsNullOrEmpty(UserCenterResourse.Option.PswAuthentication) == true) { TouchIDUtils.TouchIDSupperType type = TouchIDUtils.getTouchIDSupperType(); if (type == TouchIDUtils.TouchIDSupperType.None || UserCenterResourse.Option.FingerprintAuthentication == false) { //远程开锁开启失败,请先设置{0}二次安全验证方式 string msg = Language.StringByID(R.MyInternationalizationString.uUseUnLockByRemoteFailMsg); if (msg.Contains("{0}") == true) { msg = string.Format(msg, "\r\n"); } this.ShowMassage(ShowMsgType.Normal, msg); return; } } UserCenterResourse.Option.DoorUnLockByRemote = !btnLockSwicth.IsSelected; UserCenterResourse.Option.Save(); //重新刷新界面 this.InitMiddleFrame(); } #endregion #region ■ 界面重新激活事件___________________ /// /// 自身的上层界面关闭后,它自身处于最上层时,触发的事件 /// public override int FormActionAgainEvent() { //重新刷新界面 this.InitMiddleFrame(); return 1; } #endregion } }