黄学彪
2021-01-28 1fcf2302f79f9cbea5ef17c3688311ed65cfabb4
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
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>
        private Dialog FrameDialog = null;
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 初始化底层控件(返回的是四周有圆角的白色区域控件),此方法由封装控件底层调用,请勿随便调用
        /// </summary>
        public NormalFrameLayout InitBaseControl()
        {
            //整个灰色界面
            this.FrameDialog?.Close();
            this.FrameDialog = new Dialog();
 
            var dialogBody = new NormalFrameLayout();
            FrameDialog.AddChidren(dialogBody);
            FrameDialog.Show();
            dialogBody.ButtonClickEvent += (sender, e) =>
            {
                if (ClickBackClose == true && this.btnCancel != null)
                {
                    this.btnCancel.ButtonClickEvent?.Invoke(this.btnCancel, null);
                }
            };
 
            //白色背景
            var frameWhiteBack = new NormalFrameLayout();
            frameWhiteBack.Width = Application.GetRealWidth(343);
            frameWhiteBack.Height = RowHeight * (RowCount + 1);
            frameWhiteBack.Radius = (uint)Application.GetRealWidth(12);
            frameWhiteBack.Gravity = Gravity.CenterHorizontal;
            frameWhiteBack.Y = dialogBody.Height - RowHeight * (RowCount + 1) - 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;
            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.X = frameWhiteBack.Width - Application.GetRealWidth(90) - btnCancel.X;
            btnConfirm.Y = btnCancel.Y;
            btnConfirm.TextAlignment = TextAlignment.CenterRight;
            btnConfirm.TextColor = CSS_Color.MainColor;
            btnConfirm.TextID = StringId.Confirm;
            frameWhiteBack.AddChidren(btnConfirm);
 
            return frameWhiteBack;
        }
 
        #endregion
 
        #region ■ 一般方法___________________________
 
        /// <summary>
        /// 关闭界面
        /// </summary>
        public virtual void Close()
        {
            this.FrameDialog?.Close();
        }
 
        #endregion
    }
}