wjc
2023-08-01 f8283c8ebef3e0af8bd990c3e86cc9d010ba528e
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
using System;
using HDL_ON.UI.Music;
using Shared;
namespace HDL_ON.UI.UI2.FuntionControlView.Aks.CommonView
{
    public class MenuFramLayout : BaseFramLayout
    {
        private uint UpBackgroundColor = 0x00000000;
        private uint DownBackgroundColor = 0xff454635;
        public const int widthFrameLayout = 180;
        public const int heightFrameLayout = 180;
        public const int cornerValue = 90;
 
        public MenuFramLayout(int width = widthFrameLayout, int height = heightFrameLayout)
        {
            this.Width = Application.GetMinRealAverage(width);
            this.Height = Application.GetMinRealAverage(height);
            this.Radius = (uint)Application.GetRealHeight(cornerValue);
            this.BackgroundColor = MusicColor.ViewColor;
            this.Gravity = Gravity.CenterHorizontal;
        }
        Button btnTop = new Button
        {
            Y = Application.GetMinRealAverage(16),
            X = Application.GetMinRealAverage(78),
            Width = Application.GetRealWidth(24),
            Height = Application.GetRealHeight(20),
            UnSelectedImagePath = "AksIcon/shang.png",
        };
        Button btnBottom = new Button
        {
            Y = Application.GetMinRealAverage(144),
            X = Application.GetMinRealAverage(78),
            Width = Application.GetRealWidth(24),
            Height = Application.GetRealHeight(20),
            UnSelectedImagePath = "AksIcon/xia.png",
        };
        Button btnLeft = new Button
        {
            Y = Application.GetMinRealAverage(78),
            X = Application.GetMinRealAverage(16),
            Width = Application.GetRealWidth(20),
            Height = Application.GetRealHeight(24),
            UnSelectedImagePath = "AksIcon/zuo.png",
 
        };
        Button btnRight = new Button
        {
            Y = Application.GetMinRealAverage(78),
            X = Application.GetMinRealAverage(144),
            Width = Application.GetRealWidth(20),
            Height = Application.GetRealHeight(24),
            UnSelectedImagePath = "AksIcon/you.png",
 
        };
 
        Button btnOkbj = new Button
        {
            Y = Application.GetMinRealAverage(52),
            X = Application.GetMinRealAverage(52),
            Width = Application.GetMinRealAverage(76),
            Height = Application.GetMinRealAverage(76),
            Radius = (uint)Application.GetRealHeight(38),
            BackgroundColor = MusicColor.WhiteColor,
 
 
        };
        Button btnOk = new Button
        {
            Y = Application.GetMinRealAverage(76),
            X = Application.GetMinRealAverage(76),
            Width = Application.GetMinRealAverage(28),
            Height = Application.GetMinRealAverage(28),
            Radius = (uint)Application.GetRealHeight(14),
            BackgroundColor = MusicColor.SelectedColor,
        };
 
        public void AddView(FrameLayout layout)
        {
            this.AddChidren(btnTop);
            this.AddChidren(btnBottom);
            this.AddChidren(btnLeft);
            this.AddChidren(btnRight);
            this.AddChidren(btnOkbj);
            this.AddChidren(btnOk);
            layout.AddChidren(this);
 
        }
 
        /// <summary>
        /// 上
        /// </summary>
        /// <param name="action"></param>
        public void SetTopClickListener(Action<Button> action)
        {
            EventHandler<MouseEventArgs> UpClick = (sender, e) =>
            {
                //btnTop.BackgroundColor = this.UpBackgroundColor;
                btnTop.IsSelected = false;
                action?.Invoke(btnTop);
                //弹起来还原背景颜色
            };
            btnTop.MouseUpEventHandler += UpClick;
 
 
            EventHandler<MouseEventArgs> DownClick = (sender, e) =>
            {
                //按下去改变背景颜色
                btnTop.BackgroundColor = this.DownBackgroundColor;
            };
            btnTop.MouseDownEventHandler += DownClick;
        }
 
        /// <summary>
        /// 下
        /// </summary>
        /// <param name="action"></param>
        public void SetBottomClickListener(Action<Button> action)
        {
            EventHandler<MouseEventArgs> UpClick = (sender, e) =>
            {
                //btnBottom.BackgroundColor = this.UpBackgroundColor;
                btnBottom.IsSelected = false;
                action?.Invoke(btnBottom);
                //弹起来还原背景颜色
            };
            btnBottom.MouseUpEventHandler += UpClick;
 
 
            EventHandler<MouseEventArgs> DownClick = (sender, e) =>
            {
                //按下去改变背景颜色
                btnBottom.BackgroundColor = this.DownBackgroundColor;
            };
            btnBottom.MouseDownEventHandler += DownClick;
        }
        /// <summary>
        /// 左
        /// </summary>
        /// <param name="action"></param>
        public void SetLeftClickListener(Action<Button> action)
        {
            EventHandler<MouseEventArgs> UpClick = (sender, e) =>
            {
                //btnLeft.BackgroundColor = this.UpBackgroundColor;
                btnLeft.IsSelected = false;
                action?.Invoke(btnLeft);
                //弹起来还原背景颜色
            };
            btnLeft.MouseUpEventHandler += UpClick;
 
 
            EventHandler<MouseEventArgs> DownClick = (sender, e) =>
            {
                //按下去改变背景颜色
                btnLeft.BackgroundColor = this.DownBackgroundColor;
            };
            btnLeft.MouseDownEventHandler += DownClick;
        }
        /// <summary>
        /// 右
        /// </summary>
        /// <param name="action"></param>
        public void SetRightClickListener(Action<Button> action)
        {
            EventHandler<MouseEventArgs> UpClick = (sender, e) =>
            {
                //btnRight.BackgroundColor = this.UpBackgroundColor;
                btnRight.IsSelected = false;
                action?.Invoke(btnRight);
                //弹起来还原背景颜色
            };
            btnRight.MouseUpEventHandler += UpClick;
 
 
            EventHandler<MouseEventArgs> DownClick = (sender, e) =>
            {
                //按下去改变背景颜色
                btnRight.BackgroundColor = this.DownBackgroundColor;
            };
            btnRight.MouseDownEventHandler += DownClick;
        }
 
 
 
        /// <summary>
        /// ok
        /// </summary>
        /// <param name="action"></param>
        public void SetOkClickListener(Action<Button> action)
        {
            EventHandler<MouseEventArgs> UpClick = (sender, e) =>
            {
                btnOk.BackgroundColor = MusicColor.SelectedColor;// this.UpBackgroundColor;
                action?.Invoke(btnOk);
                //弹起来还原背景颜色
            };
            btnOk.MouseUpEventHandler += UpClick;
 
 
            EventHandler<MouseEventArgs> DownClick = (sender, e) =>
            {
                //按下去改变背景颜色
                btnOk.BackgroundColor = this.DownBackgroundColor;
            };
            btnOk.MouseDownEventHandler += DownClick;
        }
 
        public void SetClickUpBackgroundColor(uint backgroundColor)
        {
            this.UpBackgroundColor = backgroundColor;
 
        }
 
        public void SetClickDownBackgroundColor(uint backgroundColor)
        {
            this.DownBackgroundColor = backgroundColor;
        }
 
 
 
    }
}