黄学彪
2020-12-16 0d9f64668fd7350d6a21fd157e32009a96d98134
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
using System;
using Shared.Common;
namespace Shared.Phone.Device.CommonForm
{
    public class LeftIconButtonRow: FrameLayout
    {
        #region ◆ 变量__________________________
        /// <summary>
        /// 图片
        /// </summary>
        public Button IconButton;
        /// <summary>
        /// 标题
        /// </summary>
        public Button TitleButton;
        /// <summary>
        /// 下划线
        /// </summary>
        public FrameLayout Line;
        /// <summary>
        /// 点击事件
        /// </summary>
        public Action<LeftIconButtonRow, MouseEventArgs> ButtonClickEvent;
        /// <summary>
        /// ClickBtn
        /// </summary>
        public Button ClickBtn;
        /// <summary>
        /// v_Selected
        /// </summary>
        private bool v_Selected;
 
        public bool IsSelected
        {
            set
            {
                v_Selected = value;
                try
                {
                    SetStatu(v_Selected);
                }
                catch { };
            }
            get
            {
                return v_Selected;
            }
        }
 
        #endregion
 
        public LeftIconButtonRow(int width = 449, int height = 150, int x = 0, int y = 0)
        {
            X = x;
            Y = y;
            Width = Application.GetRealWidth(width);
            Height = Application.GetRealHeight(height);
        }
 
        #region ◆ 初始化__________________________
 
        /// <summary>
        /// Init
        /// </summary>
        /// <param name="iconPath">Icon path.</param>
        /// <param name="iconSelectedPath">Icon selected path.</param>
        /// <param name="title">Title.</param>
        public void Init(string iconPath, string iconSelectedPath, string title, bool hadLine = true)
        {
            IconButton = new Button()
            {
                X = Application.GetRealWidth(80),
                Height = HdlControlLogic.Current.GetPictrueRealSize(80),
                Width = HdlControlLogic.Current.GetPictrueRealSize(80),
                UnSelectedImagePath = iconPath,
                SelectedImagePath = iconSelectedPath,
                Gravity = Gravity.CenterVertical,
                Tag = this.Tag
            };
            AddChidren(IconButton);
 
            TitleButton = new Button()
            {
                X = Application.GetRealWidth(173),
                Height = Application.GetRealHeight(80),
                Width = Application.GetRealWidth(220),
                TextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor,
                SelectedTextColor = ZigbeeColor.Current.GXCTextBlackColor,
                Text = title,
                TextAlignment = TextAlignment.CenterLeft,
                Gravity = Gravity.CenterVertical,
                Tag = this.Tag,
                TextSize=14
            };
            AddChidren(TitleButton);
 
            Line = new FrameLayout()
            {
                X = Application.GetRealWidth(80),
                Y = this.Height - 1,
                Width = Application.GetRealWidth(369),
                Height = 1,
                BackgroundColor = Common.ZigbeeColor.Current.GXCGrayLineColor2
            };
            if (hadLine)
            {
                AddChidren(Line);
            }
 
            IconButton.MouseUpEventHandler += Button_MouseUpEventHandler;
            TitleButton.MouseUpEventHandler += Button_MouseUpEventHandler;
        }
        #endregion
 
        #region ◆ 选中状态__________________________
 
        /// <summary>
        /// 设置状态
        /// </summary>
        /// <param name="statu"></param>
        private void SetStatu(bool statu)
        {
            IconButton.IsSelected = statu;
            TitleButton.IsSelected = statu;
            TitleButton.IsBold = statu;
        }
        /// <summary>
        /// 选中
        /// </summary>
        public void SetSelectedStatu()
        {
            SetStatu(true);
        }
        /// <summary>
        /// 不选中
        /// </summary>
        public void SetUnSelectedStatu()
        {
            SetStatu(false);
        }
        /// <summary>
        /// HidenLine
        /// </summary>
        /// <param name="statu"></param>
        public void HidenLine(bool statu)
        {
            Line.Visible = !statu;
        }
        /// <summary>
        /// 设置标题颜色
        /// </summary>
        /// <param name="color"></param>
        /// <param name="selectedColor"></param>
        public void SetTitleColor(uint color,uint selectedColor)
        {
            TitleButton.TextColor = color;
            TitleButton.SelectedTextColor = selectedColor;
        }
        #endregion
 
        #region ◆ 点击事件_________________________
 
        /// <summary>
        /// 点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_MouseUpEventHandler(object sender, MouseEventArgs e)
        {
            try
            {
                this.ButtonClickEvent?.Invoke(this, e);
            }
            catch (Exception ex)
            {
            }
        }
        #endregion
    }
}