wxr
2020-06-16 f6fd8acd7c53c44187e70b4709443318a628f4b5
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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
using System;
using System.Collections.Generic;
using System.Security;
using Shared;
namespace HDL_ON.UI.Music
{
    public class A31MusicSourcePage:FrameLayout
    {
        public A31MusicSourcePage()
        {
            Tag = "Music";
        }
 
       
        public void Show()
        {
            #region   界面布局------
            this.BackgroundColor = Color.ViewColor;
            var topView = new TopView();
            this.AddChidren(topView.TopFLayoutView());
            topView.topNameBtn.TextID = StringId.set;
            topView.clickBackBtn.MouseUpEventHandler += (sender, e) =>
            {
                this.RemoveFromParent();
            };
            var middViewLayout = new VerticalScrolViewLayout
            {
                Y = topView.fLayout.Bottom,
                Height = Application.GetRealHeight(H_W.H - H_W.T_Height),
            };
            this.AddChidren(middViewLayout);
 
            #region 基础信息( 播放器 蓝牙 区域)
            FrameLayout fL1 = new FrameLayout
            {
                Height = Application.GetRealHeight(202),
                Width = Application.GetRealWidth(375),
            };
            middViewLayout.AddChidren(fL1);
 
            View.MusicSourceView musicIfonView = new View.MusicSourceView();
            musicIfonView.fLayout.Height = Application.GetRealHeight(44);
            musicIfonView.textBtn.TextID = StringId.information;
            musicIfonView.textBtn.TextColor = Color.SelectedColor;
            musicIfonView.textBtn.TextSize = TextSize.Text16;
            musicIfonView.inputTextBtn.Visible = false;
            musicIfonView.nextLevelBtn.Visible = false;
            musicIfonView.FrameLayoutView(fL1, false);
 
            View.MusicSourceView playNameView = new View.MusicSourceView();
            playNameView.fLayout.Y = musicIfonView.fLayout.Bottom;
            playNameView.textBtn.TextID = StringId.playerName;
            playNameView.inputTextBtn.Text = A31MusicModel.Current.Name;
            playNameView.FrameLayoutView(fL1, false);
 
            View.MusicSourceView bluetoothNameView = new View.MusicSourceView();
            bluetoothNameView.fLayout.Y = playNameView.fLayout.Bottom;
            bluetoothNameView.textBtn.TextID = StringId.bluetoothName;
            bluetoothNameView.inputTextBtn.Text = A31MusicModel.Current.Name;
            bluetoothNameView.FrameLayoutView(fL1, false);
 
            View.MusicSourceView areaText = new View.MusicSourceView();
            areaText.fLayout.Y = bluetoothNameView.fLayout.Bottom;
            areaText.FrameLayoutView(fL1, false);
            areaText.nextLevelBtn.X = Application.GetRealWidth(339);
            areaText.nextLevelBtn.Y = Application.GetRealHeight(17);
            areaText.nextLevelBtn.Width = Application.GetMinRealAverage(16);
            areaText.nextLevelBtn.Height = Application.GetMinRealAverage(16);
            areaText.nextLevelBtn.UnSelectedImagePath = "MusicIcon/sourceNetx.png";
            areaText.lineBtn.BackgroundColor = Color.WhiteColor;
            areaText.textBtn.X = Application.GetRealWidth(16);
            areaText.textBtn.TextID = StringId.region;
            areaText.inputTextBtn.TextID = StringId.region;
 
            #endregion
 
 
            #region 歌单(我的最爱 我的列表)
            FrameLayout fL2 = new FrameLayout
            {
                Height = Application.GetRealHeight(152),
                Width = Application.GetRealWidth(375),
            };
            middViewLayout.AddChidren(fL2);
 
            View.MusicSourceView playListView = new View.MusicSourceView();
            playListView.fLayout.Height = Application.GetRealHeight(44);
            playListView.textBtn.TextID = StringId.playList;
            playListView.textBtn.TextColor = Color.SelectedColor;
            playListView.textBtn.TextSize = TextSize.Text16;
            playListView.inputTextBtn.Visible = false;
            playListView.nextLevelBtn.Visible = false;
            playListView.FrameLayoutView(fL2, false);
 
            View.MusicSourceView myLoveView = new View.MusicSourceView();
            myLoveView.fLayout.Y = playListView.fLayout.Bottom;
            myLoveView.iconBtn.UnSelectedImagePath = "MusicIcon/myLove.png";
            myLoveView.textBtn.TextID = StringId.myLove;
            myLoveView.FrameLayoutView(fL2);
 
            View.MusicSourceView myListView = new View.MusicSourceView();
            myListView.fLayout.Y = myLoveView.fLayout.Bottom;
            myListView.iconBtn.UnSelectedImagePath = "MusicIcon/myList.png";
            myListView.textBtn.TextID = StringId.myList;
            myListView.FrameLayoutView(fL2);
 
            #endregion
 
            #region 选择音源( 本地音乐,USB,在线电台,QQ音乐,蓝牙,线路输入)
            FrameLayout fL3 = new FrameLayout
            {
                Height = Application.GetRealHeight(352),
                Width = Application.GetRealWidth(375),
            };
            middViewLayout.AddChidren(fL3);
 
            View.MusicSourceView selectedSourceView = new View.MusicSourceView();
            selectedSourceView.fLayout.Height = Application.GetRealHeight(44);
            selectedSourceView.textBtn.TextID = StringId.selectedSource;
            selectedSourceView.textBtn.TextColor = Color.SelectedColor;
            selectedSourceView.textBtn.TextSize = TextSize.Text16;
            selectedSourceView.inputTextBtn.Visible = false;
            selectedSourceView.nextLevelBtn.Visible = false;
            selectedSourceView.FrameLayoutView(fL3, false);
 
            View.MusicSourceView localMusicSourceView = new View.MusicSourceView();
            localMusicSourceView.fLayout.Y = selectedSourceView.fLayout.Bottom;
            localMusicSourceView.iconBtn.UnSelectedImagePath = "MusicIcon/localMusic.png";
            localMusicSourceView.textBtn.TextID = StringId.localMusic;
            localMusicSourceView.FrameLayoutView(fL3);
 
            View.MusicSourceView usbSourceView = new View.MusicSourceView();
            usbSourceView.fLayout.Y = localMusicSourceView.fLayout.Bottom;
            usbSourceView.iconBtn.UnSelectedImagePath = "MusicIcon/usb.png";
            usbSourceView.textBtn.TextID = StringId.usb;
            usbSourceView.FrameLayoutView(fL3);
 
            View.MusicSourceView radioSourceView = new View.MusicSourceView();
            radioSourceView.fLayout.Y = usbSourceView.fLayout.Bottom;
            radioSourceView.iconBtn.UnSelectedImagePath = "MusicIcon/radio.png";
            radioSourceView.textBtn.TextID = StringId.radio;
            radioSourceView.FrameLayoutView(fL3);
 
            View.MusicSourceView qqMusicSourceView = new View.MusicSourceView();
            qqMusicSourceView.fLayout.Y = radioSourceView.fLayout.Bottom;
            qqMusicSourceView.iconBtn.UnSelectedImagePath = "MusicIcon/qqMusic.png";
            qqMusicSourceView.textBtn.TextID = StringId.qqMusic;
            qqMusicSourceView.FrameLayoutView(fL3);
 
            View.MusicSourceView bluetoothSourceView = new View.MusicSourceView();
            bluetoothSourceView.fLayout.Y = qqMusicSourceView.fLayout.Bottom;
            bluetoothSourceView.iconBtn.UnSelectedImagePath = "MusicIcon/bluetooth.png";
            bluetoothSourceView.textBtn.TextID = StringId.bluetooth;
            bluetoothSourceView.FrameLayoutView(fL3);
 
            View.MusicSourceView lineSourceView = new View.MusicSourceView();
            lineSourceView.fLayout.Y = bluetoothSourceView.fLayout.Bottom;
            lineSourceView.iconBtn.UnSelectedImagePath = "MusicIcon/line.png";
            lineSourceView.textBtn.TextID = StringId.line;
            lineSourceView.FrameLayoutView(fL3);
 
 
            #endregion
 
            #endregion
 
            #region  所有点击事件
            ///播放器修改名称事件
            playNameView.clickBtn.MouseUpEventHandler += (sender, e) =>
            {
                new View.TipView().InputBox(StringId.modifyName, A31MusicModel.Current.Name, StringId.nameNull, (playerName) =>
                {
 
                    playNameView.inputTextBtn.Text = playerName;
                    A31MusicModel.Current.Name = playerName;
                    string url = "http://" + A31MusicModel.Current.IPAddress + "/httpapi.asp?command=setDeviceName:" + A31MusicModel.Current.Name;
                    SendMethod.SendCommand(url);
                });
 
            };
            ///蓝牙修改名称事件
            bluetoothNameView.clickBtn.MouseUpEventHandler += (sender, e) =>
            {
                new View.TipView().InputBox(StringId.modifyName, A31MusicModel.Current.Name, StringId.nameNull, (bluetoothName) =>
                {
                    bluetoothNameView.inputTextBtn.Text = bluetoothName;
                    SendMethod.ModifyBluetoothName("MCU+PAS+BT" + bluetoothName.Trim() + "*&");
                });
 
            };
            ///我的喜爱事件
            myLoveView.clickBtn.MouseUpEventHandler += (sender, e) =>
            {
                A31LoveList a31LoveList = new A31LoveList();
                MainPage.BasePageView.AddChidren(a31LoveList);
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                a31LoveList.Show();
                a31LoveList.UpdateSelectedFile();
            };
            ///我的列表事件
            myListView.clickBtn.MouseUpEventHandler += (sender, e) =>
            {
                A31MyList a31MyList = new A31MyList();
                MainPage.BasePageView.AddChidren(a31MyList);
                a31MyList.Show();
                a31MyList.UpdateSelectedFile();
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
            };
            ///本地音乐事件
            localMusicSourceView.clickBtn.MouseUpEventHandler += (sender, e) =>
            {
                A31LocalMusicList a31LocalMusicList = new A31LocalMusicList();
                MainPage.BasePageView.AddChidren(a31LocalMusicList);
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                a31LocalMusicList.Show();
                a31LocalMusicList.UpdateSelectedMusic();
            };
            ///USB事件
            usbSourceView.clickBtn.MouseUpEventHandler += (sender, e) =>
            {
                A31USBMusicList usbMusic = new A31USBMusicList();
                MainPage.BasePageView.AddChidren(usbMusic);
                usbMusic.UIView();
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                Loading loading = new Loading();
                usbMusic.AddChidren(loading);
                loading.Start();
                System.Threading.Tasks.Task.Run(() =>
                {
                    try
                    {
                        if (A31MusicModel.Current.USBList.Count == 0)
                        {
                            //进来读一次(注意:播放地址可能会改变,导致播放不了音乐;解决:进来都去去读取最新数据)
                            var list = SendMethod.GetUsbList(A31MusicModel.Current);
                            A31MusicModel.Current.USBList.AddRange(list);
                        }
                    }
                    catch
                    {
                    }
                    finally
                    {
                        Application.RunOnMainThread(() =>
                        {
                            loading.Hide();
                            usbMusic.Show();
                            usbMusic.UpdateSelectedMusic();
                        });
                    }
                });
            };
            ///在线电台事件
            radioSourceView.clickBtn.MouseUpEventHandler += (sender, e) =>
            {
                Loading loading = new Loading();
                this.AddChidren(loading);
                loading.Start();
                System.Threading.Tasks.Task.Run(() =>
                {
                    var radioList = SendMethod.ReadRadioList("http://opml.radiotime.com/Browse.ashx?partnerId=yvcOjvJP");
                    Application.RunOnMainThread(() =>
                    {
                        loading.Hide();
                        A31Radio a31Radio = new A31Radio();
                        MainPage.BasePageView.AddChidren(a31Radio);
                        MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                        a31Radio.Show(radioList);
                    });
                });
            };
            ///QQ音乐事件
            qqMusicSourceView.clickBtn.MouseUpEventHandler += (sender, e) =>
            {
                string str = "com.tencent.qqmusic";
                if (Application.DeviceType == Device.Ios)
                {
                    str = "qqmusic:";
                }
                CommonClass.OpenApp(str);
            };
            ///蓝牙事件
            bluetoothSourceView.clickBtn.MouseUpEventHandler += (sender, e) =>
            {
                this.RemoveFromParent();
                string url = "http://" + A31MusicModel.Current.IPAddress + "/httpapi.asp?command=setPlayerCmd:switchmode:bluetooth";
                SendMethod.SendCommand(url);
            };
            ///线路输入事件
            lineSourceView.clickBtn.MouseUpEventHandler += (sender, e) =>
            {
                this.RemoveFromParent();
                string url = "http://" + A31MusicModel.Current.IPAddress + "/httpapi.asp?command=setPlayerCmd:switchmode:line-in";
                SendMethod.SendCommand(url);
            };
            #endregion
        }
    }
}