tzy
2021-05-14 0fa1534827bd21d763216550d11006fc1441c6cb
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
using Shared;
using HDL_ON.UI.CSS;
using System;
using System.Collections.Generic;
using System.Text;
 
namespace HDL_ON.Stan
{
    /// <summary>
    /// 底部弹窗的底层共通
    /// </summary>
    public class BottomDialogCommon
    {
        #region ■ 变量声明___________________________
 
        /// <summary>
        /// 取消控件
        /// </summary>
        public NormalViewControl btnCancel = null;
        /// <summary>
        ///  确认控件
        /// </summary>
        public NormalViewControl btnConfirm = null;
        /// <summary>
        /// 标题
        /// </summary>
        public string StrTitle = null;
        /// <summary>
        /// 行高度
        /// </summary>
        public int RowHeight = Application.GetRealHeight(50);
        /// <summary>
        /// 行数
        /// </summary>
        public int RowCount = 0;
        /// <summary>
        /// 点击背景时,是否关闭弹窗
        /// </summary>
        public bool ClickBackClose = true;
        /// <summary>
        /// 点击确认时关闭界面(有些界面特殊,不关闭)
        /// </summary>
        public bool ClickConfirmClose = true;
        /// <summary>
        /// 整个弹窗对象
        /// </summary>
        private Dialog FrameDialog = null;
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 初始化底层控件(返回的是四周有圆角的白色区域控件),此方法由封装控件底层调用,请勿随便调用
        /// </summary>
        /// <param name="i_whiteWidth">白色区域的宽度,最好不要改这个东西</param>
        /// <param name="real">是否计算真实值</param>
        /// <returns></returns>
        public NormalFrameLayout InitBaseControl(int i_whiteWidth = 343, bool real = true)
        {
            //整个灰色界面
            this.FrameDialog?.Close();
            this.FrameDialog = new Dialog();
 
            var dialogBody = new NormalFrameLayout();
            FrameDialog.AddChidren(dialogBody);
            dialogBody.ButtonClickEvent += (sender, e) =>
            {
                if (ClickBackClose == true && this.btnCancel != null)
                {
                    this.btnCancel.ButtonClickEvent?.Invoke(this.btnCancel, null);
                }
            };
 
            //标题高度
            int titleHeight = Application.GetRealHeight(50);
 
            //白色背景(样子悬浮于界面,四个角都是圆角)
            var frameWhiteBack = new NormalFrameLayout();
            frameWhiteBack.Width = real == true ? Application.GetRealWidth(i_whiteWidth) : i_whiteWidth;
            frameWhiteBack.Height = RowHeight * RowCount + titleHeight;
            frameWhiteBack.Radius = (uint)Application.GetRealWidth(12);
            frameWhiteBack.Gravity = Gravity.CenterHorizontal;
            //它的底部有个20的间距
            frameWhiteBack.Y = dialogBody.Height - RowHeight * RowCount - titleHeight - Application.GetRealHeight(20);
            frameWhiteBack.BackgroundColor = CSS_Color.MainBackgroundColor;
            dialogBody.AddChidren(frameWhiteBack);
 
            //取消
            this.btnCancel = new NormalViewControl(90, 48, true);
            btnCancel.X = HdlControlResourse.XXLeft;
            btnCancel.Y = Application.GetRealHeight(2);
            btnCancel.TextColor = CSS_Color.PromptingColor1;
            btnCancel.TextID = StringId.Cancel;
            btnCancel.TextSize = CSS_FontSize.TextFontSize;
            btnCancel.Width = btnCancel.GetRealWidthByText();
            frameWhiteBack.AddChidren(btnCancel);
 
            //标题
            var btnTitle = new NormalViewControl(243, 22, true);
            btnTitle.Y = Application.GetRealHeight(15);
            btnTitle.TextAlignment = TextAlignment.Center;
            btnTitle.Gravity = Gravity.CenterHorizontal;
            btnTitle.IsBold = true;
            btnTitle.TextSize = CSS_FontSize.SubheadingFontSize;
            btnTitle.TextColor = CSS_Color.FirstLevelTitleColor;
            btnTitle.Text = this.StrTitle;
            frameWhiteBack.AddChidren(btnTitle);
 
            //确认
            this.btnConfirm = new NormalViewControl(90, 48, true);
            btnConfirm.Y = btnCancel.Y;
            btnConfirm.TextAlignment = TextAlignment.CenterRight;
            btnConfirm.TextColor = CSS_Color.MainColor;
            btnConfirm.TextID = StringId.Confirm;
            btnConfirm.TextSize = CSS_FontSize.TextFontSize;
            btnConfirm.Width = btnConfirm.GetRealWidthByText();
            frameWhiteBack.AddChidren(btnConfirm);
            btnConfirm.X = frameWhiteBack.Width - btnConfirm.Width - btnCancel.X;
 
            FrameDialog.Show();
 
            return frameWhiteBack;
        }
 
        #endregion
 
        #region ■ 一般方法___________________________
 
        /// <summary>
        /// 关闭界面
        /// </summary>
        public virtual void Close()
        {
            this.FrameDialog?.Close();
        }
 
        #endregion
    }
}