using System; using System.Collections.Generic; using System.Text; namespace Shared.Phone.UserCenter { /// /// 做成一个用来编辑名字的行控件(分上下两部分) /// public class EditorNameValueRow : StatuRowLayout { /// /// 名称变更事件 /// public delegate void _ActionNameChangedEvent(string nameValue); /// /// 称变更事件 /// public _ActionNameChangedEvent ActionNameChangedEvent; /// /// 上段控件(caption) /// public RowTopGrayView btnTop = null; /// /// 下段控件(nameValue) /// public RowBottomBlackView btnName = null; /// /// 弹窗的标题信息 /// private string dialogTitle = string.Empty; /// /// 当弹窗的输入框为空时,显示的提示信息 /// private string nameTip = string.Empty; /// /// 做成一个用来编辑名字的行控件(分上下两部分) /// /// 上段标题信息 /// 名称值 /// 是否拥有图片在左边 public EditorNameValueRow(string caption, string nameValue, bool hadPictrue = false) { btnTop = new RowTopGrayView(hadPictrue); btnTop.Text = caption; btnName = new RowBottomBlackView(hadPictrue); btnName.Text = nameValue; string oldValue = nameValue; this.MouseUpEvent += (sender, e) => { //获取当前正在激活的画面 UserCenterCommonForm nowform = UserCenterLogic.GetNowActionForm(); if (nowform == null) { //这种情况应该不存在 return; } //弹窗界面 var form = new DialogInputFrameControl(nowform, DialogFrameMode.OnlyInput); form.InputText = this.btnName.Text; form.SetTipText(this.nameTip); form.SetTitleText(this.dialogTitle); form.ComfirmClickEvent += () => { //没有回调函数 if (ActionNameChangedEvent == null) { form.CloseDialog(); return; } string value = form.InputText.Trim(); if (value == string.Empty) { //请输入XXXX var contr = new ErrorMsgControl(nameTip); contr.Show(); return; } //值没有改变的话,则不处理 if (value == oldValue) { form.CloseDialog(); return; } oldValue = value; btnName.Text = value; form.CloseDialog(); //调用回调函数 this.ActionNameChangedEvent(value); }; }; } /// /// 初始化控件 /// /// X轴偏移量 public void InitControl(int XXValue = -1) { this.AddChidren(btnTop); this.AddChidren(btnName); var right = this.AddRightIconControl(); if (XXValue != -1) { btnTop.X += XXValue; btnName.X += XXValue; right.X += XXValue; } } /// /// 设置弹窗的标题信息 /// /// public void SetDialogTitle(string i_dialogTitle) { this.dialogTitle = i_dialogTitle; } /// /// 当弹窗的输入框为空时,显示的提示信息 /// /// public void SetEmptyNameTip(string i_nameTip) { this.nameTip = i_nameTip; } } }