黄学彪
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
using System;
using System.Collections.Generic;
using System.Text;
 
namespace Shared.Phone
{
    /// <summary>
    /// 位于右下角的单击控件
    /// </summary>
    public class BottomRightClickButton : FrameLayoutStatuControl
    {
        #region ■ 变量声明___________________________
 
#if Android
        /// <summary>
        /// 按钮(没初始化之前,它为null)
        /// </summary>
        private NormalViewControl btnConfirm = null;
        /// <summary>
        /// 顶部圆角
        /// </summary>
        private NormalViewControl btnTopTemp = null;
        /// <summary>
        /// 左下角圆角
        /// </summary>
        private NormalViewControl btnBomTemp = null;
#endif
#if iOS
        /// <summary>
        /// 按钮(没初始化之前,它为null)
        /// </summary>
        private NormalClickButton btnConfirm = null;
#endif
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 位于右下角的单击控件
        /// </summary>
        /// <param name="i_width">宽度,真实值</param>
        /// <param name="i_height">高度,真实值</param>
        /// <param name="i_radius">圆角度(只对安卓有效)</param>
        public BottomRightClickButton(int i_width, int i_height, int i_radius = 17)
        {
            this.Height = i_height;
            this.Width = i_width;
            this.Gravity = Gravity.BottomRight;
 
#if Android
            this.RadiusEx = i_radius;
#endif
        }
 
        /// <summary>
        /// 初始化控件
        /// </summary>
        /// <param name="i_text">文本信息</param>
        public void InitControl(string i_text)
        {
#if Android
            this.BackgroundColor = UserCenterColor.Current.ClickButtonDefultColor;
            //把上圆角覆盖为方角
            this.btnTopTemp = new NormalViewControl(this.Width, Application.GetRealHeight(40), false);
            btnTopTemp.BackgroundColor = UserCenterColor.Current.ClickButtonDefultColor;
            this.AddChidren(btnTopTemp, ChidrenBindMode.BindEvent);
            //把左下圆角覆盖为方角
            this.btnBomTemp = new NormalViewControl(this.Width / 2, Application.GetRealHeight(40), false);
            btnBomTemp.BackgroundColor = UserCenterColor.Current.ClickButtonDefultColor;
            btnBomTemp.Gravity = Gravity.BottomLeft;
            this.AddChidren(btnBomTemp, ChidrenBindMode.BindEvent);
            //确认按钮
            this.btnConfirm = new NormalViewControl(this.Width - Application.GetRealWidth(10), Application.GetRealHeight(60), false);
            btnConfirm.IsBold = true;
            btnConfirm.Gravity = Gravity.Center;
            btnConfirm.TextColor = UserCenterColor.Current.White;
            btnConfirm.Text = i_text;
            btnConfirm.TextAlignment = TextAlignment.Center;
            this.AddChidren(btnConfirm, ChidrenBindMode.BindEvent);
 
            //重写控件点击状态
            this.SelectStatuEvent += (statu) =>
            {
                if (statu == true)
                {
                    this.BackgroundColor = UserCenterColor.Current.ButtonClickStatuColor;
                    btnTopTemp.BackgroundColor = UserCenterColor.Current.ButtonClickStatuColor;
                    btnBomTemp.BackgroundColor = UserCenterColor.Current.ButtonClickStatuColor;
                    btnConfirm.BackgroundColor = UserCenterColor.Current.ButtonClickStatuColor;
                }
                else
                {
                    this.BackgroundColor = UserCenterColor.Current.ClickButtonDefultColor;
                    btnTopTemp.BackgroundColor = UserCenterColor.Current.ClickButtonDefultColor;
                    btnBomTemp.BackgroundColor = UserCenterColor.Current.ClickButtonDefultColor;
                    btnConfirm.BackgroundColor = UserCenterColor.Current.ClickButtonDefultColor;
                }
            };
#endif
#if iOS
            //确认按钮
            this.btnConfirm = new NormalClickButton(this.Width, this.Height, false);
            btnConfirm.IsBold = true;
            btnConfirm.Gravity = Gravity.BottomRight;
            btnConfirm.TextColor = UserCenterColor.Current.White;
            btnConfirm.Text = i_text;
            btnConfirm.TextAlignment = TextAlignment.Center;
            btnConfirm.BackgroundColor = UserCenterColor.Current.ClickButtonDefultColor;
            btnConfirm.oldBackgroundColor = UserCenterColor.Current.ClickButtonDefultColor;
            this.AddChidren(btnConfirm, ChidrenBindMode.BindEvent);
#endif
        }
 
        #endregion
 
        #region ■ 一般方法___________________________
 
        /// <summary>
        /// 设置按钮的文本信息
        /// </summary>
        /// <param name="txtValue"></param>
        public void SetButtonText(string txtValue)
        {
            if (this.btnConfirm != null)
            {
                this.btnConfirm.Text = txtValue;
            }
        }
 
        #endregion
    }
}