using System; using System.Collections.Generic; using System.Text; namespace Shared.Phone.UserCenter { /// /// 安防校验管理员密码的弹窗画面 /// public class SafetyAdminValidatedControl : DialogInputFrameControl { /// /// 验证是否成功 /// public bool IsSuccess = false; /// /// 安防校验管理员密码的弹窗画面 /// public SafetyAdminValidatedControl() : base(null, DialogFrameMode.None) { //获取当前正在激活的画面 UserCenterCommonForm form = UserCenterLogic.GetNowActionForm(); if (form == null) { //这种情况应该不存在 var contr = new ErrorMsgControl("ERROR:Not Found The ActionForm!"); contr.Show(); return; } form.AddChidren(this); //初始化框架 this.InitframeControl(DialogFrameMode.None); //中间靠齐的一个框 var frameCenter = new SpecialFrameLayout(this.InputControlWidth + 10, 200, 0); frameCenter.Gravity = Gravity.Center; base.frameMiddle.AddChidren(frameCenter); //输入框的边框 SpecialFrameLayout frameLine = this.InitInputTextLine(); frameLine.Gravity = Gravity.Frame; frameCenter.AddChidren(frameLine); frameLine.Radius = (uint)frameLine.Height / 2; //输入框 EditInputText txtInput = this.InitInputControl(frameLine); txtInput.SecureTextEntry = true; txtInput.PlaceholderTextColor = UserCenterColor.Current.TextTipColor; txtInput.PlaceholderText = Language.StringByID(R.MyInternationalizationString.uPleaseInputAdministratorPassword); frameLine.AddChidren(txtInput, HeightAutoMode.IncreaseOnly); var frameCheck = new SpecialFrameLayout(this.InputControlWidth, 10, 0); frameCheck.Y = frameLine.Bottom + Application.GetRealHeight(50); frameCenter.AddChidren(frameCheck); //Check图标 var btnCheck = new IconViewControl(80); btnCheck.UnSelectedImagePath = "Account/Check.png"; btnCheck.SelectedImagePath = "Account/CheckSelected.png"; frameCheck.AddChidren(btnCheck, HeightAutoMode.IncreaseAll); btnCheck.MouseUpEventHandler += (sender, e) => { btnCheck.IsSelected = !btnCheck.IsSelected; }; //本次登陆不再询问 var btnView = new ViewNormalControl(frameCheck.Width - btnCheck.Width - Application.GetRealWidth(5)); btnView.X = btnCheck.Right + Application.GetRealWidth(10); btnView.TextID = R.MyInternationalizationString.uCurrentLandingNotAskAgain; frameCheck.AddChidren(btnView, HeightAutoMode.IncreaseAll); btnView.MouseUpEventHandler += (sender, e) => { btnCheck.IsSelected = !btnCheck.IsSelected; }; //最后让图标居中 btnCheck.Gravity = Gravity.CenterVertical; //完成最终初始化 this.FinishInitControl(); //设置输入框提示信息:管理员密码 this.SetOkButtonText(Language.StringByID(R.MyInternationalizationString.uVerification)); this.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAdministratorPassword)); this.ComfirmClickEvent += () => { if (txtInput.Text == string.Empty) { //请输入管理员密码 string msg = Language.StringByID(R.MyInternationalizationString.uPleaseInputAdministratorPassword); var contr = new Phone.UserCenter.ErrorMsgControl(msg); contr.Show(); return; } //尝试登陆 this.DoLogin(txtInput.Text, btnCheck.IsSelected); }; } /// /// 尝试登陆 /// /// /// /// private async void DoLogin(string password, bool NotAsk) { //尝试登陆 bool result = await Common.LocalSafeguard.Current.AdminLogin(password); if (result == true) { this.IsSuccess = true; Common.LocalSafeguard.Current.NotAskAgain = NotAsk; if (NotAsk == true) { Common.LocalSafeguard.Current.SetAdminPswInMenmory(password); } Application.RunOnMainThread(() => { this.CloseDialog(); }); } } } }