using Shared.Common; using System; namespace Shared.Phone.UserCenter.User { /// /// 个人信息画面 /// public class UserInformationForm : UserCenterCommonForm { #region ■ 变量声明___________________________ /// /// 列表控件的FrameLayout /// private FrameLayout ListViewframeLayout = null; #endregion #region ■ 初始化_____________________________ /// /// 画面显示(底层会固定调用此方法,借以完成画面创建) /// public void ShowForm() { //因为别的画面会调用这个函数,然后刷新画面 bodyFrameLayout.RemoveAll(); //设置头部信息 base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uPersonalInfo)); //为了能够显示模块图样 bodyFrameLayout.BackgroundColor = UserCenterColor.Current.TopFrameLayout; ListViewframeLayout = new FrameLayout(); bodyFrameLayout.AddChidren(ListViewframeLayout); //初始化上部的信息 var topFrame = this.InitTopBodyFrame(); //初始化中部的信息 var midll = this.InitMiddleBodyFrame(topFrame); //初始化底部部的信息 this.InitBottomBodyFrame(midll); } #endregion #region ■ 初始化上段控件_____________________ /// /// 初始化上部的信息 /// private SpecialFrameLayout InitTopBodyFrame() { var specialTopFrame = new SpecialFrameLayout(340, 20); specialTopFrame.BackgroundColor = UserCenterColor.Current.BodyFrameLayout; ListViewframeLayout.AddChidren(specialTopFrame); //用户图标 var btnUserIcon = new ProfilePhotoControl(); btnUserIcon.Y = Application.GetRealHeight(40); btnUserIcon.Gravity = Gravity.CenterHorizontal; btnUserIcon.UnSelectedImagePath = "Account/Admin.png"; specialTopFrame.AddChidren(btnUserIcon); //身份 var btnAuthority = new ViewNormalControl(specialTopFrame.Width); btnAuthority.TextAlignment = TextAlignment.Center; btnAuthority.Y = btnUserIcon.Bottom + Application.GetRealHeight(20); btnAuthority.TextColor = UserCenterColor.Current.TextGrayColor; btnAuthority.Gravity = Gravity.CenterHorizontal; btnAuthority.Text = UserCenterResourse.UserInfo.AuthorityText; specialTopFrame.AddChidren(btnAuthority); return specialTopFrame; } #endregion #region ■ 初始化中段控件_____________________ /// /// 初始化中部的信息 /// private SpecialFrameLayout InitMiddleBodyFrame(SpecialFrameLayout specialTopFrame) { var specialMidFrame = new SpecialFrameLayout(450, 0); specialMidFrame.BackgroundColor = UserCenterColor.Current.BodyFrameLayout; specialMidFrame.Y = specialTopFrame.Bottom + Application.GetRealHeight(50); ListViewframeLayout.AddChidren(specialMidFrame); //用户名称 string caption = Language.StringByID(R.MyInternationalizationString.uUserName); string nameValue = UserCenterResourse.UserInfo.UserName; var btnUserName = new EditorNameValueRow(caption, nameValue); specialMidFrame.AddChidren(btnUserName); btnUserName.InitControl(); //请输入用户名称 btnUserName.SetEmptyNameTip(Language.StringByID(R.MyInternationalizationString.uPleaseInputUserName)); //编辑用户名称 btnUserName.SetDialogTitle(Language.StringByID(R.MyInternationalizationString.uEditorUserName)); btnUserName.ActionNameChangedEvent += (userName) => { //更新用户名 this.SaveUserName(userName); }; var rowEmail = new RowLayout(); rowEmail.Y = btnUserName.Bottom; rowEmail.Height = ControlCommonResourse.ListViewRowHeight; specialMidFrame.AddChidren(rowEmail); //Email var btnEmailView = new RowTopGrayView(false); btnEmailView.TextID = R.MyInternationalizationString.uEmail; rowEmail.AddChidren(btnEmailView); var btnEmail = new RowBottomGrayView(false); btnEmail.Text = UserCenterResourse.UserInfo.Email; rowEmail.AddChidren(btnEmail); //修改/绑定邮箱 var btnEmailEditor = new RowMostRightTextView(); btnEmailEditor.TextColor = UserCenterColor.Current.TextBlueColor; //绑定 btnEmailEditor.TextID = string.IsNullOrEmpty(btnEmail.Text) == true ? R.MyInternationalizationString.uBinding : R.MyInternationalizationString.uEditor2; rowEmail.AddChidren(btnEmailEditor); btnEmailEditor.ReSetYaxis(UViewAlignment.Bottom); btnEmailEditor.MouseUpEventHandler += (sender, e) => { if (string.IsNullOrEmpty(btnEmail.Text) == true) { var form = new CheckNewEmailForm(); //身份验证,然后才能打开界面 this.CheckUserAuthenticationAndShowForm(form); } else { var form = new CheckOldEmailForm(); this.AddForm(form); } }; var rowPhone = new RowLayout(); rowPhone.Y = rowEmail.Bottom; rowPhone.Height = ControlCommonResourse.ListViewRowHeight; specialMidFrame.AddChidren(rowPhone, HeightAutoMode.IncreaseOnly); //手机号码 var btnPhoneView = new RowTopGrayView(false); btnPhoneView.TextID = R.MyInternationalizationString.uPhone; rowPhone.AddChidren(btnPhoneView); var btnPhone = new RowBottomGrayView(false); btnPhone.Text = UserCenterResourse.UserInfo.Phone; rowPhone.AddChidren(btnPhone); //修改/绑定手机号 var btnPhoneEditor = new RowMostRightTextView(); btnPhoneEditor.TextColor = UserCenterColor.Current.TextBlueColor; //绑定 btnPhoneEditor.TextID = string.IsNullOrEmpty(btnPhone.Text) == true ? R.MyInternationalizationString.uBinding : R.MyInternationalizationString.uEditor2; rowPhone.AddChidren(btnPhoneEditor); btnPhoneEditor.ReSetYaxis(UViewAlignment.Bottom); btnPhoneEditor.MouseUpEventHandler += (sender, e) => { if (string.IsNullOrEmpty(btnPhone.Text) == true) { var form = new CheckNewPhoneNumForm(); //身份验证,然后才能打开界面 this.CheckUserAuthenticationAndShowForm(form); } else { var form = new CheckOldPhoneNumForm(); this.AddForm(form); } }; return specialMidFrame; } #endregion #region ■ 初始化下段控件_____________________ /// /// 初始化底部部的信息 /// private void InitBottomBodyFrame(SpecialFrameLayout specialMidFrame) { var specialBomFrame = new SpecialFrameLayout(ControlCommonResourse.ListViewRowHeight * 2, 0, false); specialBomFrame.Y = specialMidFrame.Bottom + Application.GetRealHeight(50); specialBomFrame.BackgroundColor = UserCenterColor.Current.BodyFrameLayout; ListViewframeLayout.AddChidren(specialBomFrame); //修改密码(行) var rowPsw = new StatuRowLayout(); specialBomFrame.AddChidren(rowPsw, HeightAutoMode.AutoOnly); //修改密码 var btnPsw = new RowCenterView(false); btnPsw.TextID = R.MyInternationalizationString.uChangedPassword; rowPsw.AddChidren(btnPsw); //向右图标 var btnRinght = rowPsw.AddRightIconControl(); rowPsw.MouseUpEvent += (sender, e) => { var form = new EditorPasswordForm(); this.AddForm(form); }; ////Touch ID验证(行) //var rowTouch = new RowLayout(); //rowTouch.Y = rowPsw.Bottom; //rowTouch.Height = ControlCommonResourse.ListViewRowHeight; //specialBomFrame.AddChidren(rowTouch, HeightAutoMode.IncreaseOnly); ////Touch ID验证 //var btnTouchView = new RowTopBlackView(false); //btnTouchView.TextID = R.MyInternationalizationString.uTouchIDCheck; //btnTouchView.TextAlignment = TextAlignment.CenterLeft; //rowTouch.AddChidren(btnTouchView); ////Msg:开启后,每次打开程序时都需要指纹验证 //var btnTouchMsg = new RowBottomGrayView(false); //btnTouchMsg.TextID = R.MyInternationalizationString.uNeedFingerprintAfterActionProgram; //btnTouchMsg.TextAlignment = TextAlignment.CenterLeft; //rowTouch.AddChidren(btnTouchMsg); ////开关按钮 //var btnSwich = new SwichControl(); //rowTouch.AddChidren(btnSwich); //btnSwich.MouseUpEventHandler += (sender, e) => //{ // btnSwich.IsSelected = !btnSwich.IsSelected; //}; //初始化退出账号的FrameLayout this.InitLogoutFrameLayout(specialBomFrame.Bottom + Application.GetRealHeight(50)); } /// /// 初始化退出账号的FrameLayout /// private void InitLogoutFrameLayout(int YY) { var specialFrame = new SpecialFrameLayout(bodyFrameLayout.Height - YY, 0, false); specialFrame.Y = YY; specialFrame.BackgroundColor = UserCenterColor.Current.BodyFrameLayout; ListViewframeLayout.AddChidren(specialFrame); //退出账号(行) var rowLogout = new StatuRowLayout(); specialFrame.AddChidren(rowLogout, HeightAutoMode.IncreaseAll); //退出账号 var btnLogout = new RowCenterView(false); btnLogout.TextID = R.MyInternationalizationString.uLogoutAccount; rowLogout.AddChidren(btnLogout); //向右图标 var btnRinght2 = rowLogout.AddRightIconControl(); rowLogout.MouseUpEvent += (sender, e) => { //确定退出当前账号? string msg = Language.StringByID(R.MyInternationalizationString.uLogoutAccountMsg); this.ShowConfirmMsg(msg, "DoLogoutAccount"); }; } /// /// 退出账号 /// public void DoLogoutAccount() { UserCenterLogic.ReLoginAgain(Common.Config.Instance.Account); } #endregion #region ■ 更新用户名_________________________ /// /// 更新用户名 /// /// 昵称 private async void SaveUserName(string userName) { if (UserCenterResourse.UserInfo.UserName == userName) { return; } //打开进度条 this.ShowProgressBar(); var pra = new SaveUserNamePra(); pra.UserName = userName; bool result = await UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/UpdateUserName", pra); //关闭进度条 this.CloseProgressBar(); if (result == false) { return; } //用户名称修改成功! string msg = Language.StringByID(R.MyInternationalizationString.uUserNameSaveSuccess); this.ShowTip(msg); UserCenterResourse.UserInfo.UserName = userName; } #endregion #region ■ 身份验证___________________________ /// /// 身份验证 /// /// /// private void CheckUserAuthenticationAndShowForm(UserCenterCommonForm form) { var dialog = new DialogInputFrameControl(this, DialogFrameMode.OnlyPassword); dialog.SetTipText(Language.StringByID(R.MyInternationalizationString.PleaseInputOldPsw)); dialog.SetTitleText(Language.StringByID(R.MyInternationalizationString.uUserAuthentication)); dialog.ComfirmClickEvent += () => { if (dialog.InputText != Config.Instance.Password) { //原密码错误 string msg = Language.StringByID(R.MyInternationalizationString.UpdatePassword_OldPwdNoYes); this.ShowErrorMsg(msg); return; } dialog.CloseDialog(); this.AddForm(form); }; } #endregion #region ■ 界面重新激活事件___________________ /// /// 自身的上层界面关闭后,它自身处于最上层时,触发的事件 /// public override void FormActionAgainEvent() { //重新刷新界面 this.ShowForm(); } #endregion } }