黄学彪
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
using System;
using System.Collections.Generic;
 
namespace Shared.Phone
{
    /// <summary>
    /// 做成一个RowLayout型的FrameLayout
    /// </summary>
    public class FrameRowControl : FrameLayoutStatuControl
    {
        #region ■ 变量声明___________________________
 
        /// <summary>
        /// 此控件的识别主键(自定义设置的)
        /// </summary>
        public string MainKeys = string.Empty;
        /// <summary>
        /// 左偏移量,只针对内置控件有效(这是一个真实值,默认不偏移。正数为向右偏移,负数为向左偏移)
        /// </summary>
        public int LeftOffset = 0;
        /// <summary>
        /// 右偏移量,只针对内置控件有效(这是一个真实值,默认不偏移。正数为向右偏移,负数为向左偏移)
        /// </summary>
        public int RightOffset = 0;
        /// <summary>
        /// 左边图标控件的大小
        /// </summary>
        private int leftIconSize = 0;
        /// <summary>
        /// 右边图标控件的大小
        /// </summary>
        private int rightIconSize = 0;
        /// <summary>
        /// 底线控件
        /// </summary>
        private NormalViewControl btnBottomLine = null;
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 做成一个RowLayout型的FrameLayout
        /// </summary>
        /// <param name="i_ChidrenYaxis">子控件Y轴偏移量(【列表控件的rowSpace/2】即可,不懂默认为0即可)</param>
        public FrameRowControl(int i_ChidrenYaxis = 0) : base(i_ChidrenYaxis)
        {
            this.Height = HdlControlResourse.ListViewRowHeight;
            this.Width = Application.CurrentWidth;
        }
 
        #endregion
 
        #region ■ 添加底线___________________________
 
        /// <summary>
        /// <para>添加底线(如果左边有图标,则先添加图标,再添加底线)</para>
        /// <para>它的长度为:当前控件宽度-左右固定间距-左边图片宽度(如果有)-右边的偏移量</para>
        /// </summary>
        public virtual NormalViewControl AddBottomLine()
        {
            if (this.btnBottomLine != null)
            {
                //已经添加了底线
                return btnBottomLine;
            }
            int lineWidth = this.Width - HdlControlResourse.XXLeft * 2 - LeftOffset - RightOffset;
            int XX = HdlControlResourse.XXLeft + LeftOffset;
            if (leftIconSize > 0)
            {
                lineWidth = lineWidth - leftIconSize - Application.GetRealWidth(35);
                XX = XX + leftIconSize + Application.GetRealWidth(35);
            }
            this.btnBottomLine = new NormalViewControl(lineWidth, HdlControlResourse.BottomLineHeight, false);
            btnBottomLine.X = XX;
            btnBottomLine.Y = this.Height - HdlControlResourse.BottomLineHeight;
            btnBottomLine.BackgroundColor = UserCenterColor.Current.ButtomLine;
            base.AddChidren(btnBottomLine);
 
            return btnBottomLine;
        }
 
        #endregion
 
        #region ■ 添加左边Caption____________________
 
        /// <summary>
        /// 添加左边Caption(如果有图标,则先添加图标,再添加Caption)
        /// </summary>
        /// <param name="i_caption">内容</param>
        /// <param name="i_width">宽度</param>
        /// <param name="real">是否计算真实值</param>
        /// <returns></returns>
        public NormalViewControl AddLeftCaption(string i_caption, int i_width, bool real = true)
        {
            if (real == true)
            {
                i_width = Application.GetRealWidth(i_width);
            }
            var contr = this.AddLeftCaption(i_caption, i_width, this.Height, false);
            this.AddChidren(contr, ChidrenBindMode.BindEvent);
            if (chidrenYaxis != 0)
            {
                contr.Y += chidrenYaxis;
            }
 
            return contr;
        }
 
        /// <summary>
        /// 添加左边Caption,此方法不会主动添加到父控件中(如果有图标,则先添加图标,再添加Caption)
        /// </summary>
        /// <param name="i_caption">内容</param>
        /// <param name="i_width">宽度</param>
        /// <param name="i_height">高度</param>
        /// <param name="real">是否计算真实值</param>
        /// <returns></returns>
        public NormalViewControl AddLeftCaption(string i_caption, int i_width, int i_height, bool real = true)
        {
            int XX = HdlControlResourse.XXLeft + LeftOffset;
            if (this.leftIconSize > 0)
            {
                XX += this.leftIconSize + Application.GetRealWidth(35);
            }
            var btnCaption = new NormalViewControl(i_width, i_height, real);
            btnCaption.X = XX;
 
            btnCaption.Text = i_caption;
 
            return btnCaption;
        }
 
        #endregion
 
        #region ■ 添加左边输入框_____________________
 
        /// <summary>
        /// 添加左边输入框(如果有图标,则先添加图标,再添加输入框)
        /// </summary>
        /// <param name="i_txtValue">初始内容</param>
        /// <param name="i_width">宽度</param>
        /// <param name="real">是否计算真实值</param>
        /// <returns></returns>
        public TextInputControl AddLeftInput(string i_txtValue, int i_width, bool real = true)
        {
            if (real == true)
            {
                i_width = Application.GetRealWidth(i_width);
            }
            int XX = HdlControlResourse.XXLeft + LeftOffset;
            if (this.leftIconSize > 0)
            {
                XX += this.leftIconSize + Application.GetRealWidth(35);
            }
            var contr = new TextInputControl(i_width, this.Height, false);
            contr.Text = i_txtValue;
            contr.X = XX;
 
            this.AddChidren(contr, ChidrenBindMode.NotBind);
            if (chidrenYaxis != 0)
            {
                contr.Y += chidrenYaxis;
            }
 
            return contr;
        }
 
        #endregion
 
        #region ■ 添加左边图标_______________________
 
        /// <summary>
        /// 添加左边图标
        /// </summary>
        /// <param name="i_Iconsize">图标大小</param>
        /// <param name="i_IconPath">图标地址</param>
        /// <returns></returns>
        public IconViewControl AddLeftIcon(int i_Iconsize = 81, string i_IconPath = null)
        {
            var btnIcon = new IconViewControl(i_Iconsize);
            btnIcon.X = HdlControlResourse.XXLeft + LeftOffset;
            btnIcon.Gravity = Gravity.CenterVertical;
            if (i_IconPath != null)
            {
                btnIcon.UnSelectedImagePath = i_IconPath;
            }
            this.AddChidren(btnIcon, ChidrenBindMode.BindEvent);
            if (chidrenYaxis != 0)
            {
                btnIcon.Y += chidrenYaxis;
            }
 
            this.leftIconSize = btnIcon.IconSize;
            return btnIcon;
        }
 
        #endregion
 
        #region ■ 添加向右的图标_____________________
 
        /// <summary>
        /// 添加向右的图标
        /// </summary>
        public IconViewControl AddRightArrow()
        {
            var btnRight = new IconViewControl(58);
            btnRight.Gravity = Gravity.CenterVertical;
            btnRight.X =this.Width - btnRight.IconSize - HdlControlResourse.XXLeft + RightOffset;
            btnRight.UnSelectedImagePath = "Item/RightNext.png";
            this.AddChidren(btnRight, ChidrenBindMode.BindEvent);
 
            if (chidrenYaxis != 0)
            {
                btnRight.Y += chidrenYaxis;
            }
 
            this.rightIconSize = btnRight.Width;
 
            return btnRight;
        }
 
        /// <summary>
        /// 添加最右边的空白图片控件
        /// </summary>
        /// <param name="i_width">控件空度(非真实值)</param>
        /// <param name="i_height">控件高度(非真实值)</param>
        /// <returns></returns>
        public MostRightIconControl AddMostRightEmptyIcon(int i_width, int i_height)
        {
            var btnContr = new MostRightIconControl(i_width, i_height);
            btnContr.UseClickStatu = false;
            this.AddChidren(btnContr, ChidrenBindMode.NotBind);
            btnContr.InitControl();
            //复合控件需要特殊处理
            this.ChangedChidrenBindMode(btnContr, ChidrenBindMode.BindEvent);
            if (RightOffset != 0)
            {
                btnContr.X += RightOffset;
            }
 
            this.rightIconSize = this.GetPictrueRealSize(i_width);
            if (chidrenYaxis != 0)
            {
                btnContr.btnIcon.Y += chidrenYaxis;
            }
 
            return btnContr;
        }
 
        #endregion
 
        #region ■ 添加右边的开关图标_________________
 
        /// <summary>
        /// 添加右边的开关图标
        /// </summary>
        /// <returns></returns>
        public MostRightIconControl AddMostRightSwitchIcon()
        {
            var btnSwitch = this.AddMostRightEmptyIcon(104, 63);
            this.ChangedChidrenBindMode(btnSwitch, ChidrenBindMode.NotBind);
            btnSwitch.UnSelectedImagePath = "Item/Switch2.png";
            btnSwitch.SelectedImagePath = "Item/Switch2Selected.png";
 
            return btnSwitch;
        }
 
        #endregion
 
        #region ■ 添加最右的显示文本_________________
 
        /// <summary>
        /// 添加最右的显示文本(如果右边有图标的话,先添加图标后,再添加这个文本)
        /// </summary>
        /// <param name="i_text"></param>
        /// <param name="i_width"></param>
        /// <param name="real"></param>
        /// <returns></returns>
        public NormalViewControl AddMostRightView(string i_text, int i_width, bool real = true)
        {
            if (real == true)
            {
                i_width = Application.GetRealWidth(i_width);
            }
            var btnContr = AddMostRightView(i_text, i_width, this.Height, false);
            this.AddChidren(btnContr, ChidrenBindMode.BindEvent);
            if (chidrenYaxis != 0)
            {
                btnContr.Y += chidrenYaxis;
            }
 
            return btnContr;
        }
 
        /// <summary>
        /// 添加最右的显示文本,此方法不会主动添加到父控件中(如果右边有图标的话,先添加图标后,再添加这个文本)
        /// </summary>
        /// <param name="i_caption">内容</param>
        /// <param name="i_width">宽度</param>
        /// <param name="i_height">高度</param>
        /// <param name="real">是否计算真实值</param>
        /// <returns></returns>
        public NormalViewControl AddMostRightView(string i_text, int i_width, int i_height, bool real = true)
        {
            if (real == true)
            {
                i_width = Application.GetRealWidth(i_width);
                i_height = Application.GetRealHeight(i_height);
            }
            var btnContr = new NormalViewControl(i_width, i_height, false);
            btnContr.X = this.Width - HdlControlResourse.XXLeft - i_width - rightIconSize + RightOffset;
            btnContr.Height = i_height;
            btnContr.TextAlignment = TextAlignment.CenterRight;
            btnContr.TextColor = UserCenterColor.Current.TextGrayColor1;
            btnContr.Text = i_text;
 
            return btnContr;
        }
 
        #endregion
 
        #region ■ 添加上部的显示文本_________________
 
        /// <summary>
        /// 添加上部的显示文本(如果有图标,则先添加图标,再添加文本)
        /// </summary>
        /// <param name="i_caption">内容</param>
        /// <param name="i_width">宽度</param>
        /// <param name="real">是否计算真实值</param>
        /// <returns></returns>
        public NormalViewControl AddTopView(string i_caption, int i_width, bool real = true)
        {
            if (real == true)
            {
                i_width = Application.GetRealWidth(i_width);
            }
            var contr = this.AddLeftCaption(i_caption, i_width, Application.GetRealHeight(60), false);
            contr.TextSize = 15;
            //当指定实际坐标时,这里需要的偏移量为2倍
            contr.Y = Application.GetRealHeight(12) + this.chidrenYaxis * 2;
            this.AddChidren(contr, ChidrenBindMode.BindEvent);
 
            return contr;
        }
 
        #endregion
 
        #region ■ 添加下部的显示文本_________________
 
        /// <summary>
        /// 添加下部的显示文本(如果有图标,则先添加图标,再添加文本)
        /// </summary>
        /// <param name="i_caption">内容</param>
        /// <param name="i_width">宽度</param>
        /// <param name="real">是否计算真实值</param>
        /// <returns></returns>
        public NormalViewControl AddBottomView(string i_caption, int i_width, bool real = true)
        {
            if (real == true)
            {
                i_width = Application.GetRealWidth(i_width);
            }
            var contr = this.AddLeftCaption(i_caption, i_width, Application.GetRealHeight(50), false);
            //当指定实际坐标时,这里需要的偏移量为2倍
            contr.Y = Application.GetRealHeight(72) + this.chidrenYaxis * 2;
            contr.TextSize = 12;
            contr.TextColor = UserCenterColor.Current.TextGrayColor1;
            this.AddChidren(contr, ChidrenBindMode.BindEvent);
 
            return contr;
        }
 
        #endregion
    }
}