using System; namespace Shared.Phone.UserCenter.SmartSound.Widget { public class TextDialog : FrameLayout { #region ■ 变量声明___________________________ /// /// 确认按钮事件 /// public Action ComfirmClickEvent; /// /// 标题控件 /// private NormalViewControl btnTitle = null; /// /// 取消按钮 /// private BottomLeftClickButton btnCancel = null; /// /// 确认按钮 /// private BottomRightClickButton btnConfirm = null; #endregion #region ■ 初始化_____________________________ /// /// /// /// 提示内容 /// 确认按钮 Text public TextDialog(string msg,string btnText) { //添加界面 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 btnMsg = new NormalViewControl(frameBack.Width - Application.GetRealWidth(55 * 2), Application.GetRealHeight(180), false); btnMsg.Y = Application.GetRealHeight(141); btnMsg.IsMoreLines = true; btnMsg.TextAlignment = TextAlignment.Center; btnMsg.TextColor = UserCenterColor.Current.TextGrayColor1; btnMsg.Gravity = Gravity.CenterHorizontal; btnMsg.Text = msg; frameBack.AddChidren(btnMsg); //取消 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(btnText); btnConfirm.ButtonClickEvent += (sender, e) => { //回调函数 this.ComfirmClickEvent?.Invoke(); }; } #endregion #region ■ 一般方法___________________________ /// /// 画面关闭 /// public void CloseDialog() { this.ComfirmClickEvent = null; this.RemoveFromParent(); } #endregion #region ■ 设置信息___________________________ /// /// 设置标题信息 /// /// public void SetTitleText(string txtValue) { this.btnTitle.Text = txtValue; } /// /// 设置取消按钮的文本信息 /// /// public void SetCancelButtonText(string txtValue) { this.btnCancel.SetButtonText(txtValue); } /// /// 设置确定按钮的文本信息 /// /// public void SetOkButtonText(string txtValue) { this.btnConfirm.SetButtonText(txtValue); } #endregion } }