mac
2023-10-18 282f291d9279319b0e6b4a882b02ed2b50501c04
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
using System;
using HDL_ON.UI.Music;
using Shared;
namespace HDL_ON.UI.UI2.FuntionControlView.Aks.CommonView
{
    /// <summary>
    /// 自定义按键容器
    /// </summary>
    public class ButtonFramLayout : BaseFramLayout
    {
 
        public const int widthFrameLayout = 78;
        public const int heightFrameLayout = 84-6;
        public const int lineW = 1;
        public const int cornerValue = 8;
 
       
 
        public ButtonFramLayout(int width= widthFrameLayout, int height= heightFrameLayout)
        {
            this.Width = Application.GetRealWidth(width);
            this.Height = Application.GetRealHeight(height);
            //this.Radius = (uint)Application.GetRealHeight(cornerValue);
        }
 
        Button btnImage = new Button
        {
            Y = Application.GetRealHeight(12),
            Width = Application.GetRealWidth(32),
            Height = Application.GetRealWidth(32),
            UnSelectedImagePath = "AksIcon/kai.png",
            Gravity = Gravity.CenterHorizontal,
            Name = "btnImage",
        };
        Button btnName = new Button
        {
            Y = Application.GetRealHeight(12 + 26 + 8),//(12 + 32 + 8)
            Width = Application.GetRealWidth(widthFrameLayout),
            Height = Application.GetRealHeight(20),
            TextSize = TextSize.Text14,
            TextColor = MusicColor.TextColor,
            TextAlignment = TextAlignment.Center,
            Gravity = Gravity.CenterHorizontal,
            Padding = new Padding(0, 0, 0, 0),
            Name = "btnName",
 
 
        };
        Button btnTopLine = new Button
        {
            Width = Application.GetRealWidth(widthFrameLayout),
            Height = Application.GetRealHeight(lineW),
            BackgroundColor = MusicColor.ViewColor,
            Name = "btnTopLine",
        };
        Button btnBottomLine = new Button
        {
            Width = Application.GetRealWidth(widthFrameLayout),
            Height = Application.GetRealHeight(lineW),
            BackgroundColor = MusicColor.ViewColor,
            Name = "btnBottomLine",
            Y = Application.GetRealHeight(heightFrameLayout - 1),
        };
        Button btnLeftLine = new Button
        {
            Width = Application.GetRealWidth(lineW),
            Height = Application.GetRealHeight(heightFrameLayout),
            BackgroundColor = MusicColor.ViewColor,
            Name = "btnLeftLine",
 
        };
        Button btnRightLine = new Button
        {
            Width = Application.GetRealWidth(lineW),
            Height = Application.GetRealHeight(heightFrameLayout),
            BackgroundColor = MusicColor.ViewColor,
            X = Application.GetRealWidth(widthFrameLayout - 1),
            Name = "btnRightLine",
 
        };
        /// <summary>
        /// 添加布局
        /// </summary>
        /// <param name="parent"></param>
        public void AddView(FrameLayout parent)
        {
            parent.AddChidren(this);
            this.AddChidren(btnImage);
            this.AddChidren(btnName);
        }
 
        public void AddImageView()
        {
            this.AddChidren(btnImage);
 
        }
        public void AddNameView()
        {
            this.AddChidren(btnName);
        }
 
        /// <summary>
        /// 添加左边线
        /// </summary>
        public void AddLeftLine()
        {
            btnLeftLine.Height = this.Height;
            this.AddChidren(btnLeftLine);
        }
        /// <summary>
        /// 添加右边线
        /// </summary>
        public void AddRightLine()
        {
            btnRightLine.Height = this.Height;
            btnRightLine.X = this.Width - Application.GetRealWidth(1);
            this.AddChidren(btnRightLine);
        }
 
        /// <summary>
        /// 添加顶部边线
        /// </summary>
        public void AddTopLine()
        {
            btnTopLine.Width = this.Width;
            this.AddChidren(btnTopLine);
        }
        /// <summary>
        /// 添加底部边线
        /// </summary>
        public void AddBottomLine()
        {
            btnBottomLine.Y = this.Height - Application.GetRealHeight(1);
            btnBottomLine.Width = this.Width;
            this.AddChidren(btnBottomLine);
        }
 
        public Button GetImageButton()
        {
            return this.btnImage;
        }
        public Button GetNameButton()
        {
            return btnName;
        }
 
        /// <summary>
        /// 事件监听方法
        /// </summary>
        /// <param name="action">回调(第一个是父类对象;第二个是图标对象;第三个是状态对象</param>
        public void SetClickListener(Action<FrameLayout, Button, Button> action)
        {
            EventHandler<MouseEventArgs> UpClick = (sender, e) =>
            {
                action?.Invoke(this, btnImage, btnName);
                this.BackgroundColor = 0x00000000;
 
                //弹起来还原背景颜色
            };
            this.MouseUpEventHandler += UpClick;
            btnImage.MouseUpEventHandler += UpClick;
            btnName.MouseUpEventHandler += UpClick;
 
            EventHandler<MouseEventArgs> CancelClick = (sender, e) =>
            {
                this.BackgroundColor = 0x00000000;
                //弹起来还原背景颜色
            };
            this.MouseUpOutsideEventHandler += CancelClick;
            btnImage.MouseUpOutsideEventHandler += CancelClick;
            btnName.MouseUpOutsideEventHandler += CancelClick;
 
            EventHandler<MouseEventArgs> DownClick = (sender, e) =>
            {
              
                //按下去改变背景颜色
                this.BackgroundColor = AksCommonMethod.seleBackgroundColor;
 
            };
 
            this.MouseDownEventHandler += DownClick;
            btnImage.MouseDownEventHandler += DownClick;
            btnName.MouseDownEventHandler += DownClick;
        }
        /// <summary>
        /// 设置图标
        /// </summary>
        /// <param name="stringId"></param>
        public void SetButtonImage(int stringId)
        {
 
            switch (stringId)
            {
                case StringId.kai:
                    {
                        this.btnImage.UnSelectedImagePath = "AksIcon/kai.png";
                    }
                    break;
            }
        }
 
 
    }
}