wjc
2023-08-04 36540bdc906f402f4c55cc7460b6facfd344a793
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
using System;
using HDL_ON.UI.Music;
using Shared;
namespace HDL_ON.UI.UI2.FuntionControlView.Aks.CommonView
{
    public class NumberFrameLayout
    {
        public NumberFrameLayout()
        {
        }
        private uint UpBackgroundColor = MusicColor.WhiteColor;
        private uint DownBackgroundColor = 0xff454635;
        private Action<Button> action = null;
        public FrameLayout layout = new FrameLayout
        {
 
            Height = Application.GetRealHeight(368),
            Width = Application.GetRealWidth(343),
            Radius = (uint)Application.GetRealHeight(17),
            BackgroundColor = MusicColor.WhiteColor,
        };
 
        Button btn1 = new Button
        {
            Width = Application.GetRealWidth(78),
            Height = Application.GetRealHeight(84),
            Text = "1",
            TextSize = TextSize.Text20,
            TextColor = MusicColor.TextColor,
            TextAlignment = TextAlignment.Center,
            IsBold = true,
        };
        Button btn2 = new Button
        {
            Width = Application.GetRealWidth(78),
            Height = Application.GetRealHeight(84),
            Text = "2",
            TextSize = TextSize.Text20,
            TextColor = MusicColor.TextColor,
            TextAlignment = TextAlignment.Center,
            IsBold = true,
        };
        Button btn3 = new Button
        {
            Width = Application.GetRealWidth(78),
            Height = Application.GetRealHeight(84),
            Text = "3",
            TextSize = TextSize.Text20,
            TextColor = MusicColor.TextColor,
            TextAlignment = TextAlignment.Center,
            IsBold = true,
        };
        Button btn4 = new Button
        {
            Width = Application.GetRealWidth(78),
            Height = Application.GetRealHeight(84),
            Text = "4",
            TextSize = TextSize.Text20,
            TextColor = MusicColor.TextColor,
            TextAlignment = TextAlignment.Center,
            IsBold = true,
        };
        Button btn5 = new Button
        {
            Width = Application.GetRealWidth(78),
            Height = Application.GetRealHeight(84),
            Text = "5",
            TextSize = TextSize.Text20,
            TextColor = MusicColor.TextColor,
            TextAlignment = TextAlignment.Center,
            IsBold = true,
        };
        Button btn6 = new Button
        {
            Width = Application.GetRealWidth(78),
            Height = Application.GetRealHeight(84),
            Text = "6",
            TextSize = TextSize.Text20,
            TextColor = MusicColor.TextColor,
            TextAlignment = TextAlignment.Center,
            IsBold = true,
        };
 
        Button btn7 = new Button
        {
            Width = Application.GetRealWidth(78),
            Height = Application.GetRealHeight(84),
            Text = "7",
            TextSize = TextSize.Text20,
            TextColor = MusicColor.TextColor,
            TextAlignment = TextAlignment.Center,
            IsBold = true,
        };
        Button btn8 = new Button
        {
            Width = Application.GetRealWidth(78),
            Height = Application.GetRealHeight(84),
            Text = "8",
            TextSize = TextSize.Text20,
            TextColor = MusicColor.TextColor,
            TextAlignment = TextAlignment.Center,
            IsBold = true,
        };
        Button btn9 = new Button
        {
            Width = Application.GetRealWidth(78),
            Height = Application.GetRealHeight(84),
            Text = "9",
            TextSize = TextSize.Text20,
            TextColor = MusicColor.TextColor,
            TextAlignment = TextAlignment.Center,
            IsBold = true,
        };
        Button btn0 = new Button
        {
            Width = Application.GetRealWidth(78),
            Height = Application.GetRealHeight(84),
            Text = "0",
            TextSize = TextSize.Text20,
            TextColor = MusicColor.TextColor,
            TextAlignment = TextAlignment.Center,
            IsBold = true,
        };
 
        Button btn = new Button
        {
            Width = Application.GetRealWidth(78),
            Height = Application.GetRealHeight(84),
            Text = "-/--",
            TextSize = TextSize.Text20,
            TextColor = MusicColor.TextColor,
            TextAlignment = TextAlignment.Center,
            IsBold = true,
        };
 
        Button btn_jia = new Button
        {
            Width = Application.GetRealWidth(78),
            Height = Application.GetRealHeight(84),
            TextID = StringId.pindaojia,
            TextSize = TextSize.Text20,
            TextColor = MusicColor.TextColor,
            TextAlignment = TextAlignment.Center,
            IsBold = true,
 
 
        };
 
        Button btn_jian = new Button
        {
            Width = Application.GetRealWidth(78),
            Height = Application.GetRealHeight(84),
            TextID = StringId.pindaojian,
            TextSize = TextSize.Text20,
            TextColor = MusicColor.TextColor,
            TextAlignment = TextAlignment.Center,
            IsBold = true,
 
 
        };
 
        /// <summary>
        /// 添加布局
        /// </summary>
        /// <param name="parent"></param>
        public void AddView(FrameLayout parent)
        {
            parent.AddChidren(layout);
            layout.AddChidren(btn1);
            layout.AddChidren(btn2);
            layout.AddChidren(btn3);
            layout.AddChidren(btn4);
            layout.AddChidren(btn5);
            layout.AddChidren(btn6);
            layout.AddChidren(btn7);
            layout.AddChidren(btn8);
            layout.AddChidren(btn9);
            layout.AddChidren(btn0);
            layout.AddChidren(btn);
            layout.AddChidren(btn_jia);
            layout.AddChidren(btn_jian);
 
            btn1.Y = Application.GetRealHeight(16);
            btn1.X = Application.GetRealWidth(16);
            btn2.Y = Application.GetRealHeight(16);
            btn2.X = btn1.Right;
            btn3.Y = Application.GetRealHeight(16);
            btn3.X = btn2.Right;
            btn_jia.Y = Application.GetRealHeight(16);
            btn_jia.X = btn3.Right;
 
            btn4.Y = btn1.Bottom;
            btn4.X = Application.GetRealWidth(16);
            btn5.Y = btn2.Bottom;
            btn5.X = btn4.Right;
            btn6.Y = btn3.Bottom;
            btn6.X = btn5.Right;
            btn_jian.Y = btn_jia.Bottom;
            btn_jian.X = btn6.Right;
 
            btn7.Y = btn6.Bottom;
            btn7.X = Application.GetRealWidth(16);
            btn8.Y = btn5.Bottom;
            btn8.X = btn7.Right;
            btn9.Y = btn6.Bottom;
            btn9.X = btn8.Right;
            btn.Y = btn_jian.Bottom;
            btn.X = btn9.Right;
 
            btn0.Y = btn8.Bottom;
            btn0.X = Application.GetRealWidth(16 + 78);
 
            btn1.MouseDownEventHandler += (sen, e) => ClickListener(btn1);
 
            btn2.MouseDownEventHandler += (sen, e) => ClickListener(btn2);
 
            btn3.MouseDownEventHandler += (sen, e) => ClickListener(btn3);
 
            btn4.MouseDownEventHandler += (sen, e) => ClickListener(btn4);
 
            btn5.MouseDownEventHandler += (sen, e) => ClickListener(btn5);
 
            btn6.MouseDownEventHandler += (sen, e) => ClickListener(btn6);
 
            btn7.MouseDownEventHandler += (sen, e) => ClickListener(btn7);
 
            btn8.MouseDownEventHandler += (sen, e) => ClickListener(btn8);
 
            btn9.MouseDownEventHandler += (sen, e) => ClickListener(btn9);
 
            btn0.MouseDownEventHandler += (sen, e) => ClickListener(btn0);
 
            btn.MouseDownEventHandler += (sen, e) => ClickListener(btn);
 
            btn_jia.MouseDownEventHandler += (sen, e) => ClickListener(btn_jia);
 
            btn_jian.MouseDownEventHandler += (sen, e) => ClickListener(btn_jian);
 
 
        }
 
        private void ClickListener(Button button)
        {
            if (button == null)
            {
                return;
            }
            button.BackgroundColor = DownBackgroundColor;
            action?.Invoke(button);
            button.MouseUpEventHandler += (sen, e) =>
            {
                button.BackgroundColor = UpBackgroundColor;
            };
        }
 
 
        /// <summary>
        /// 事件监听方法
        /// </summary>
        /// <param name="action">回调(点击控件对象</param>
        public void SetClickListener(Action<Button> action)
        {
            this.action = action;
        }
 
    }
}