using Shared.Phone.UserCenter; using System; using System.Collections.Generic; using System.Text; namespace Shared.Phone.Login.Controls { /// /// 登陆界面的手机号和邮箱来回切换的控件 /// public class PhoneEmailSelectControl : FrameLayout { #region ■ 变量声明___________________________ /// /// 菜单选择事件 1:手机号 2:邮箱 /// public Action SelectMenuEvent = null; /// /// 手机号控件 /// private NormalViewControl btnPhone = null; /// /// 邮箱控件 /// private NormalViewControl btnEmail = null; #endregion #region ■ 初始化_____________________________ /// /// 登陆界面的手机号和邮箱来回切换的控件 /// public PhoneEmailSelectControl() { this.Width = HdlControlLogic.Current.GetPictrueRealSize(905); this.Height = HdlControlLogic.Current.GetPictrueRealSize(170); this.Gravity = Gravity.CenterHorizontal; this.BackgroundImagePath = "Account/PhoneEmail_White.png"; } /// /// 初始化控件(索引会触发回调事件,SelectMenuEvent需要在它之前实现) /// /// 选择时的背景颜色 /// 默认选择的索引 1:手机号 2:邮箱 public void InitControl(uint selectBackColor,int selectIndex) { //手机号 this.btnPhone = new NormalViewControl(HdlControlLogic.Current.GetPictrueRealSize(467), HdlControlLogic.Current.GetPictrueRealSize(127), false); btnPhone.X = HdlControlLogic.Current.GetPictrueRealSize(10); btnPhone.SelectedBackgroundColor = selectBackColor; btnPhone.TextID = R.MyInternationalizationString.PhoneNum; btnPhone.TextColor = UserCenterColor.Current.TextGrayColor3; btnPhone.SelectedTextColor = UserCenterColor.Current.White; btnPhone.TextAlignment = TextAlignment.Center; btnPhone.Radius = (uint)HdlControlLogic.Current.GetPictrueRealSize(127) / 2; this.AddChidren(btnPhone); btnPhone.ButtonClickEvent += (sender, e) => { if (btnPhone.IsSelected == false) { btnPhone.IsBold = true; btnPhone.IsSelected = true; btnEmail.IsBold = false; btnEmail.IsSelected = false; //调用回调函数 this.SelectMenuEvent?.Invoke(1); } }; //邮箱 this.btnEmail = new NormalViewControl(this.btnPhone.Width, this.btnPhone.Height, false); btnEmail.X = this.Width - this.btnPhone.Width - HdlControlLogic.Current.GetPictrueRealSize(10); btnEmail.SelectedBackgroundColor = selectBackColor; btnEmail.TextID = R.MyInternationalizationString.Email; btnEmail.TextColor = UserCenterColor.Current.TextGrayColor3; btnEmail.SelectedTextColor = UserCenterColor.Current.White; btnEmail.TextAlignment = TextAlignment.Center; btnEmail.Radius = (uint)HdlControlLogic.Current.GetPictrueRealSize(127) / 2; this.AddChidren(btnEmail); btnEmail.ButtonClickEvent += (sender, e) => { if (btnEmail.IsSelected == false) { btnPhone.IsBold = false; btnPhone.IsSelected = false; btnEmail.IsBold = true; btnEmail.IsSelected = true; //调用回调函数 this.SelectMenuEvent?.Invoke(2); } }; //设置选择状态 this.SetSelectIndex(selectIndex); } #endregion #region ■ 设置选择状态_______________________ /// /// 设置选择状态(1:手机号 2:邮箱) /// /// 1:手机号 2:邮箱 public void SetSelectIndex(int i_index) { //设置初始值 if (i_index == 1) { btnPhone.IsBold = true; btnPhone.IsSelected = true; if (btnEmail.IsSelected == true) { btnEmail.IsBold = false; btnEmail.IsSelected = false; } //调用回调函数 this.SelectMenuEvent?.Invoke(1); } else if (i_index == 2) { btnEmail.IsBold = true; btnEmail.IsSelected = true; if (btnPhone.IsSelected == true) { btnPhone.IsBold = false; btnPhone.IsSelected = false; } //调用回调函数 this.SelectMenuEvent?.Invoke(2); } } #endregion #region ■ 控件摧毁___________________________ /// /// 控件摧毁 /// public override void RemoveFromParent() { this.SelectMenuEvent = null; base.RemoveFromParent(); } #endregion } }