using System; namespace Shared.Phone.UserCenter.Password { /// /// 修改账号密码画面 /// public class EditorAccountPasswordForm : EditorCommonForm { #region ■ 变量声明___________________________ /// /// 密码错误信息控件 /// private NormalViewControl msgControl = null; #endregion #region ■ 初始化_____________________________ /// /// 画面显示(底层会固定调用此方法,借以完成画面创建) /// public void ShowForm() { //设定标题 base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uChangedPassword)); //初始化中部控件 this.InitMiddleFrame(); } /// /// 初始化中部控件 /// private void InitMiddleFrame() { //清空bodyFrame this.ClearBodyFrame(); var frameBackGroud = new FrameLayout(); frameBackGroud.BackgroundColor = UserCenterColor.Current.White; frameBackGroud.Height = Application.GetRealHeight(521); bodyFrameLayout.AddChidren(frameBackGroud); //请输入原密码 var rowOldPsw = new FrameRowControl(); //关闭状态提示 rowOldPsw.UseClickStatu = false; rowOldPsw.Y = Application.GetRealHeight(26); frameBackGroud.AddChidren(rowOldPsw); var txtoldPsw = new TextInputControl(Application.GetRealWidth(800), rowOldPsw.Height); txtoldPsw.X = HdlControlResourse.XXLeft; txtoldPsw.SecureTextEntry = true; txtoldPsw.PlaceholderText = Language.StringByID(R.MyInternationalizationString.PleaseInputOldPsw); rowOldPsw.AddChidren(txtoldPsw); //底线 var btnOldLine = rowOldPsw.AddBottomLine(); //联动线的状态 txtoldPsw.btnLine = btnOldLine; //图标 var btnoldPswIcon = rowOldPsw.AddMostRightEmptyIcon(58, 58); btnoldPswIcon.UnSelectedImagePath = "Item/HidenPWD.png"; btnoldPswIcon.SelectedImagePath = "Item/UnHidenPWD.png"; btnoldPswIcon.ButtonClickEvent += (sender, e) => { btnoldPswIcon.IsSelected = !btnoldPswIcon.IsSelected; txtoldPsw.SecureTextEntry = !txtoldPsw.SecureTextEntry; }; //忘记密码? var btnForgotPsw = new NormalViewControl(300, 49, true); btnForgotPsw.Y = rowOldPsw.Bottom + Application.GetRealHeight(23); btnForgotPsw.TextSize = 12; btnForgotPsw.TextColor = UserCenterColor.Current.TextOrangeColor; btnForgotPsw.TextID = R.MyInternationalizationString.ForgotPasswordMsg; btnForgotPsw.TextAlignment = TextAlignment.CenterRight; frameBackGroud.AddChidren(btnForgotPsw); btnForgotPsw.X = bodyFrameLayout.Width - HdlControlResourse.XXLeft - btnForgotPsw.Width; btnForgotPsw.ButtonClickEvent += (sender, e) => { var form = new ForgotAccountPasswordForm(); form.AddForm(); }; //请输入新密码 var rowNewPsw = new FrameRowControl(); //关闭状态提示 rowNewPsw.UseClickStatu = false; rowNewPsw.Y = Application.GetRealHeight(236); frameBackGroud.AddChidren(rowNewPsw); var txtNewPsw = new TextInputControl(Application.GetRealWidth(800), rowNewPsw.Height); txtNewPsw.X = HdlControlResourse.XXLeft; txtNewPsw.SecureTextEntry = true; txtNewPsw.PlaceholderText = Language.StringByID(R.MyInternationalizationString.uPleaseInputNewPassword); rowNewPsw.AddChidren(txtNewPsw); //底线 var btnNewLine = rowNewPsw.AddBottomLine(); //联动线的状态 txtNewPsw.btnLine = btnNewLine; //图标 var btnNewPswIcon = rowNewPsw.AddMostRightEmptyIcon(58, 58); btnNewPswIcon.UnSelectedImagePath = "Item/HidenPWD.png"; btnNewPswIcon.SelectedImagePath = "Item/UnHidenPWD.png"; btnNewPswIcon.ButtonClickEvent += (sender, e) => { btnNewPswIcon.IsSelected = !btnNewPswIcon.IsSelected; txtNewPsw.SecureTextEntry = !txtNewPsw.SecureTextEntry; }; //请重复输入新密码 var rowConfirmPsw = new FrameRowControl(); //关闭状态提示 rowConfirmPsw.UseClickStatu = false; rowConfirmPsw.Y = rowNewPsw.Bottom + Application.GetRealHeight(10); frameBackGroud.AddChidren(rowConfirmPsw); var txtConfirmPsw = new TextInputControl(Application.GetRealWidth(800), rowConfirmPsw.Height); txtConfirmPsw.X = HdlControlResourse.XXLeft; txtConfirmPsw.SecureTextEntry = true; txtConfirmPsw.PlaceholderText = Language.StringByID(R.MyInternationalizationString.uPleaseRepeatInputNewPassword); rowConfirmPsw.AddChidren(txtConfirmPsw); //图标 var btnConfirmPswIcon = rowConfirmPsw.AddMostRightEmptyIcon(58, 58); btnConfirmPswIcon.UnSelectedImagePath = "Item/HidenPWD.png"; btnConfirmPswIcon.SelectedImagePath = "Item/UnHidenPWD.png"; btnConfirmPswIcon.ButtonClickEvent += (sender, e) => { btnConfirmPswIcon.IsSelected = !btnConfirmPswIcon.IsSelected; txtConfirmPsw.SecureTextEntry = !txtConfirmPsw.SecureTextEntry; }; //错误信息 this.msgControl = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(58), false); msgControl.Y = Application.GetRealHeight(582); msgControl.TextAlignment = TextAlignment.Center; msgControl.TextColor = 0xfff75858; msgControl.IsBold = true; bodyFrameLayout.AddChidren(msgControl); //确认修改 var btnfinish = new BottomClickButton(688); btnfinish.Y = Application.GetRealHeight(708); btnfinish.TextID = R.MyInternationalizationString.DoEditor; bodyFrameLayout.AddChidren(btnfinish); btnfinish.ButtonClickEvent += (sender, e) => { msgControl.Text = string.Empty; //密码检测 bool flage = this.CheckPassword(txtoldPsw.Text, txtNewPsw.Text, txtConfirmPsw.Text); if (flage == false) { return; } //保存密码 this.SavePassword(txtoldPsw.Text, txtConfirmPsw.Text); }; } #endregion #region ■ 保存密码___________________________ /// /// 保存密码 /// /// /// private void SavePassword(string i_oldPsw, string i_newPsw) { //编辑密码 var result = HdlAccountLogic.Current.EditorPassword(i_oldPsw, i_newPsw); if (result == false) { return; } //密码已经修改,请重新登录 string msg = Language.StringByID(R.MyInternationalizationString.uPasswordIsHadChangedAndLoginAgain); this.ShowMassage(ShowMsgType.Remind, msg, () => { //从新登录 HdlAccountLogic.Current.ReLoginAgain(Common.Config.Instance.Account); }, Language.StringByID(R.MyInternationalizationString.Login)); } #endregion #region ■ 一般方法___________________________ /// /// 密码检测 /// /// 输入的旧密码 /// 输入的新密码 /// 输入的确认密码 /// private bool CheckPassword(string oldPsw, string newPsw, string newPsw2) { if (oldPsw == string.Empty) { //请输入原密码 this.msgControl.TextID = R.MyInternationalizationString.PleaseInputOldPsw; return false; } if (newPsw == string.Empty) { //请输入新密码 this.msgControl.TextID = R.MyInternationalizationString.uPleaseInputNewPassword; return false; } if (newPsw2 == string.Empty) { //请重复输入新密码 this.msgControl.TextID = R.MyInternationalizationString.uPleaseRepeatInputNewPassword; return false; } if (newPsw != newPsw2) { //确认密码不一致,请重新输入 this.msgControl.TextID = R.MyInternationalizationString.SecondPswNotEqual1; return false; } if (newPsw == oldPsw) { //新密码和原密码一致,请重新输入 this.msgControl.TextID = R.MyInternationalizationString.uNewPswAndOldPswIsEqual; return false; } if (newPsw.Length < 6 || newPsw.Length > 13) { //密码长度为6-13个字符 string textValue = Language.StringByID(R.MyInternationalizationString.PswLengthMsg); if (textValue.Contains("{0}") == true) { textValue = string.Format(textValue, "6-13"); } this.msgControl.Text = textValue; return false; } return true; } #endregion } }