lss
2020-06-10 f37f3a667bd81f78736e381717b82f632cb1fdeb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
using System;
 
namespace Shared.Phone.UserCenter.SmartSound.Widget
{
 
    public class TextDialog : FrameLayout
    {
 
        #region ■ 变量声明___________________________
 
        /// <summary>
        /// 确认按钮事件
        /// </summary>
        public Action ComfirmClickEvent;
                      
        /// <summary>
        /// 标题控件
        /// </summary>
        private NormalViewControl btnTitle = null;
        /// <summary>
        /// 取消按钮
        /// </summary>
        private BottomLeftClickButton btnCancel = null;
        /// <summary>
        /// 确认按钮
        /// </summary>
        private BottomRightClickButton btnConfirm = null;
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 
        /// </summary>
        /// <param name="msg">提示内容</param>
        /// <param name="btnText">确认按钮 Text</param>
        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 ■ 一般方法___________________________
 
        /// <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);
        }
                
        #endregion
    }
}