黄学彪
2020-04-13 3793a9a38ac6c4c4111c2bba3a35a71c30601e82
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
using System;
using System.Collections.Generic;
using System.Text;
 
namespace Shared.Phone.UserCenter
{
    /// <summary>
    /// 输入框控件的最初原型(不建议修改和直接使用):标准字体颜色,文字向左靠齐,14号字
    /// </summary>
    public class TextInputBase : EditText
    {
        #region ■ 变量声明___________________________
 
        /// <summary>
        /// 联动底线
        /// </summary>
        private NormalViewControl btnLineTemp = null;
        /// <summary>
        /// 联动底线(值输入之后,线的颜色会变)
        /// </summary>
        public NormalViewControl btnLine
        {
            set
            {
                this.btnLineTemp = value;
                //光标事件
                this.FoucsChanged -= this.TxtCode_FoucsChangedEvent;
                this.FoucsChanged += this.TxtCode_FoucsChangedEvent;
            }
        }
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 输入框控件的最初原型(不建议修改和直接使用):标准字体颜色,文字向左靠齐,14号字
        /// </summary>
        public TextInputBase()
        {
            //测试,全体输入框为14号字
            this.TextSize = 14;
 
            this.PlaceholderTextColor = UserCenterColor.Current.TextTipColor;
            this.TextColor = UserCenterColor.Current.TextColor1;
            this.TextAlignment = TextAlignment.CenterLeft;
        }
 
        /// <summary>
        /// 初始化控件大小(不以平均值进行真实数值计算)
        /// </summary>
        /// <param name="i_Width">宽度</param>
        /// <param name="i_Height">高度</param>
        /// <param name="real">是否计算真实值</param>
        public void InitSize(int i_Width, int i_Height, bool real = true)
        {
            if (real == true)
            {
                i_Width = Application.GetRealWidth(i_Width);
                i_Height = Application.GetRealHeight(i_Height);
            }
 
            this.Height = i_Height;
            this.Width = i_Width;
        }
 
        /// <summary>
        /// 初始化控件大小(不以平均值进行真实数值计算)
        /// </summary>
        /// <param name="i_Width">宽度</param>
        /// <param name="real">是否计算真实值</param>
        public void InitSize(int i_Width, bool real = true)
        {
            if (real == true)
            {
                i_Width = Application.GetRealWidth(i_Width);
            }
 
            this.Height = ControlCommonResourse.NormalControlHeight;
            this.Width = i_Width;
        }
 
        /// <summary>
        /// 初始化控件大小(以平均值进行真实数值计算)
        /// </summary>
        /// <param name="i_Width">宽度</param>
        /// <param name="i_Height">高度</param>
        /// <param name="real">是否计算真实值</param>
        public void InitAvgSize(int i_Width, int i_Height, bool real = true)
        {
            if (real == true)
            {
                i_Width = Application.GetMinRealAverage(i_Width);
                i_Height = Application.GetMinRealAverage(i_Height);
            }
 
            this.Height = i_Height;
            this.Width = i_Width;
        }
 
        #endregion
 
        #region ■ 事件_______________________________
 
        /// <summary>
        /// 焦点变更事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TxtCode_FoucsChangedEvent(object sender, FocusEventArgs e)
        {
            if (e.Focus == false)
            {
                if (btnLineTemp != null)
                {
                    btnLineTemp.BackgroundColor = UserCenterColor.Current.ButtomLine;
                }
            }
            else
            {
                if (btnLineTemp != null)
                {
                    btnLineTemp.BackgroundColor = UserCenterColor.Current.TextFrameSelectColor;
                }
            }
        }
 
        #endregion
 
        #region ■ 一般方法___________________________
 
        /// <summary>
        /// Y轴重置(真实数值,没有父容器无效)
        /// </summary>
        /// <param name="alignment">上下对齐方式</param>
        /// <param name="Space">上下两部分的间距</param>
        public void ReSetYaxis(UViewAlignment alignment, int Space = 0)
        {
            if (this.Parent == null)
            {
                return;
            }
            //Y轴重置
            this.Y = HdlControlLogic.Current.GetControlChidrenYaxis(this.Parent.Height, this.Height, alignment, Space);
        }
        #endregion
    }
}