New file |
| | |
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using System.Text;
|
| | |
|
| | | namespace Shared.Phone.UserCenter
|
| | | {
|
| | | /// <summary>
|
| | | /// <para>做成一个弹窗型,左下角是【取消按钮】,右下角是【确认按钮】的弹窗控件</para>
|
| | | /// <para>New的时候,就已经加入到了界面</para>
|
| | | /// </summary>
|
| | | public class DialogInputControl : FrameLayout
|
| | | {
|
| | | #region ■ 变量声明___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 确认按钮事件
|
| | | /// </summary>
|
| | | public Action<string> ComfirmClickEvent;
|
| | | /// <summary>
|
| | | /// 输入框的文本信息
|
| | | /// </summary>
|
| | | public string Text
|
| | | {
|
| | | get { return txtInput.Text.Trim(); }
|
| | | set { this.txtInput.Text = value; }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 输入框控件
|
| | | /// </summary>
|
| | | private TextInputControl txtInput = null;
|
| | | /// <summary>
|
| | | /// 标题控件
|
| | | /// </summary>
|
| | | private NormalViewControl btnTitle = null;
|
| | | /// <summary>
|
| | | /// 取消按钮
|
| | | /// </summary>
|
| | | private BottomLeftClickButton btnCancel = null;
|
| | | /// <summary>
|
| | | /// 确认按钮
|
| | | /// </summary>
|
| | | private BottomRightClickButton btnConfirm = null;
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 初始化_____________________________
|
| | |
|
| | | /// <summary>
|
| | | /// <para>做成一个弹窗型,左下角是【取消按钮】,右下角是【确认按钮】的弹窗控件</para>
|
| | | /// <para>New的时候,就已经加入到了界面</para>
|
| | | /// </summary>
|
| | | /// <param name="i_MaxByte">文本框最大输入的byte数(默认36个byte)</param>
|
| | | public DialogInputControl(int i_MaxByte = 36)
|
| | | {
|
| | | //添加界面
|
| | | var nowForm = UserView.HomePage.Instance.GetChildren(UserView.HomePage.Instance.ChildrenCount - 1);
|
| | | if (nowForm == null || (nowForm is ViewGroup) == false)
|
| | | {
|
| | | return;
|
| | | }
|
| | | this.BackgroundColor = UserCenterColor.Current.DialogBackColor;
|
| | | ((ViewGroup)nowForm).AddChidren(this);
|
| | |
|
| | | //白色背景框
|
| | | var frameBack = new FrameLayout();
|
| | | frameBack.Height = Application.GetRealHeight(507);
|
| | | frameBack.Width = Application.GetRealWidth(792);
|
| | | frameBack.BackgroundColor = UserCenterColor.Current.White;
|
| | | frameBack.Y = Application.GetRealHeight(691);
|
| | | frameBack.Gravity = Gravity.CenterHorizontal;
|
| | | frameBack.Radius = (uint)Application.GetRealHeight(17);
|
| | | this.AddChidren(frameBack);
|
| | | //标题信息
|
| | | this.btnTitle = new NormalViewControl(frameBack.Width, Application.GetRealHeight(65), false);
|
| | | btnTitle.Y = Application.GetRealHeight(68);
|
| | | btnTitle.TextColor = UserCenterColor.Current.TextColor1;
|
| | | btnTitle.TextSize = 16;
|
| | | btnTitle.TextAlignment = TextAlignment.Center;
|
| | | frameBack.AddChidren(btnTitle);
|
| | |
|
| | | //初始化边框
|
| | | var frameText = new FrameLayout();
|
| | | frameText.Width = Application.GetRealWidth(677);
|
| | | frameText.Height = Application.GetRealHeight(100);
|
| | | frameText.Y = Application.GetRealHeight(198);
|
| | | frameText.Gravity = Gravity.CenterHorizontal;
|
| | | frameText.BorderColor = 0xff676767;
|
| | | frameText.BorderWidth = 1;
|
| | | frameText.Radius = (uint)Application.GetRealHeight(17);
|
| | | frameBack.AddChidren(frameText);
|
| | | //输入框
|
| | | this.txtInput = new TextInputControl(frameText.Width - Application.GetRealWidth(20), frameText.Height, false);
|
| | | txtInput.TextAlignment = TextAlignment.Center;
|
| | | txtInput.Gravity = Gravity.CenterHorizontal;
|
| | | frameText.AddChidren(txtInput);
|
| | | if (i_MaxByte > 0)
|
| | | {
|
| | | this.txtInput.MaxByte = i_MaxByte;
|
| | | }
|
| | |
|
| | | //取消
|
| | | this.btnCancel = new BottomLeftClickButton(Application.GetRealWidth(396), Application.GetRealHeight(127));
|
| | | frameBack.AddChidren(btnCancel);
|
| | | btnCancel.InitControl(Language.StringByID(R.MyInternationalizationString.uCancel));
|
| | | btnCancel.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //移除界面
|
| | | this.CloseDialog();
|
| | | };
|
| | |
|
| | | //确认
|
| | | this.btnConfirm = new BottomRightClickButton(frameBack.Width - btnCancel.Width, btnCancel.Height);
|
| | | frameBack.AddChidren(btnConfirm);
|
| | | btnConfirm.InitControl(Language.StringByID(R.MyInternationalizationString.OkMsg));
|
| | | btnConfirm.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | if (this.Text == string.Empty && string.IsNullOrEmpty(this.txtInput.PlaceholderText) == false)
|
| | | {
|
| | | var alert = new ShowMsgControl(ShowMsgType.Tip, this.txtInput.PlaceholderText);
|
| | | alert.Show();
|
| | | return;
|
| | | }
|
| | | //回调函数
|
| | | this.ComfirmClickEvent?.Invoke(this.Text);
|
| | | };
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 一般方法___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 画面关闭
|
| | | /// </summary>
|
| | | public void CloseDialog()
|
| | | {
|
| | | this.ComfirmClickEvent = null;
|
| | | this.RemoveFromParent();
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 设置信息___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 设置标题信息
|
| | | /// </summary>
|
| | | /// <param name="txtValue"></param>
|
| | | public void SetTitleText(string txtValue)
|
| | | {
|
| | | this.btnTitle.Text = txtValue;
|
| | | }
|
| | | /// <summary>
|
| | | /// 设置取消按钮的文本信息
|
| | | /// </summary>
|
| | | /// <param name="txtValue"></param>
|
| | | public void SetCancelButtonText(string txtValue)
|
| | | {
|
| | | this.btnCancel.SetButtonText(txtValue);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 设置确定按钮的文本信息
|
| | | /// </summary>
|
| | | /// <param name="txtValue"></param>
|
| | | public void SetOkButtonText(string txtValue)
|
| | | {
|
| | | this.btnConfirm.SetButtonText(txtValue);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 设置输入框灰色字体说明
|
| | | /// </summary>
|
| | | /// <param name="txtValue"></param>
|
| | | public void SetTipText(string txtValue)
|
| | | {
|
| | | if (this.txtInput != null)
|
| | | {
|
| | | this.txtInput.PlaceholderText = txtValue;
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | | }
|
| | | }
|