黄学彪
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
125
126
127
128
129
130
131
132
133
134
135
136
137
using Shared;
using HDL_ON.UI.CSS;
using System;
using System.Collections.Generic;
using System.Text;
 
namespace HDL_ON.Stan
{
    /// <summary>
    /// 底部项目编辑控件
    /// </summary>
    public class BottomItemEditorControl : BottomDialogCommon
    {
        #region ■ 变量声明___________________________
 
        /// <summary>
        /// 结束事件(0:点击了取消 1:点击了确定)
        /// </summary>
        public Action<int> FinishEvent = null;
        /// <summary>
        /// 列表控件
        /// </summary>
        private VerticalListControl listView = null;
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 有标题的弹窗型菜单编辑控件
        /// </summary>
        /// <param name="i_RowCount">菜单行数(不含标题)</param>
        /// <param name="i_title">标题</param>
        /// <param name="clickBackClose">点击背景时,是否关闭弹窗</param>
        public BottomItemEditorControl(int i_RowCount, string i_title, bool clickBackClose = true)
        {
            //最大显示7个
            base.RowCount = i_RowCount > 7 ? 7 : i_RowCount;
            base.ClickBackClose = clickBackClose;
            base.StrTitle = i_title;
        }
 
        /// <summary>
        /// 初始化控件
        /// </summary>
        private void InitControl()
        {
            //已经初始化
            if (base.btnCancel != null) { return; }
 
            //初始化底层控件
            var frameWhiteBack = base.InitBaseControl();
            //取消
            base.btnCancel.ButtonClickEvent += (sender, e) =>
            {
                base.Close();
                this.FinishEvent?.Invoke(0);
                this.FinishEvent = null;
            };
 
            //确认
            base.btnConfirm.ButtonClickEvent += (sender, e) =>
            {
                base.Close();
                this.FinishEvent?.Invoke(1);
                this.FinishEvent = null;
            };
 
            //列表控件
            this.listView = new VerticalListControl();
            listView.Y = btnConfirm.Bottom;
            listView.Height = this.RowCount * this.RowHeight;
            frameWhiteBack.AddChidren(listView);
        }
 
        #endregion
 
        #region ■ 添加菜单___________________________
 
        /// <summary>
        /// 添加菜单行
        /// </summary>
        /// <param name="i_textView">左边显示的文字</param>
        /// <param name="i_textValue">右边显示的值(</param>
        /// <param name="clickEvent">单击菜单执行的事件(参数为右边显示值的那个控件)</param>
        public void AddRowMenu(string i_textView, string i_textValue, Action<NormalViewControl> clickEvent)
        {
            //先初始化控件
            this.InitControl();
 
            //它的上一行
            var rowBefor = this.listView.GetChildren(this.listView.ChildrenCount - 1) as FrameRowControl;
            if (rowBefor != null)
            {
                //画底线
                var btnLine = rowBefor.AddBottomLine();
                btnLine.Width = rowBefor.Width - Application.GetRealWidth(20) * 2;
                btnLine.Gravity = Gravity.CenterHorizontal;
            }
 
            //行
            var rowContr = new FrameRowControl();
            rowContr.LeftOffset = Application.GetRealWidth(20) - HdlControlResourse.XXLeft;
            rowContr.RightOffset = - rowContr.LeftOffset;
            rowContr.Width = this.listView.Width;
            rowContr.Height = this.RowHeight;
            this.listView.AddChidren(rowContr);
            //显示文本
            var btnView = rowContr.AddLeftCaption(i_textView, 150);
            btnView.Width = btnView.GetRealWidthByText();
            btnView.TextColor = CSS_Color.FirstLevelTitleColor;
            //添加右箭头
            rowContr.AddRightArrow();
            //添加右边的文本
            var btnValue = rowContr.AddMostRightView(i_textValue, 150);
            rowContr.ButtonClickEvent += (sender, e) =>
            {
                clickEvent?.Invoke(btnValue);
            };
        }
 
        #endregion
 
        #region ■ 一般方法___________________________
 
        /// <summary>
        /// 关闭界面
        /// </summary>
        public override void Close()
        {
            base.Close();
            this.FinishEvent = null;
        }
 
        #endregion
    }
}