JLChen
2020-06-04 6d55af8792cf8fbef0055e677b900fc352dba9a2
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
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Text;
using Shared;
using Shared.SimpleControl;
using Shared.SimpleControl.Phone.Music;
using Shared.SimpleControl.R;
using SmartHome.UI.SimpleControl.Phone.Music;
 
namespace SmartHome
{
    public class SetUpPage : FrameLayout
    {
        A31MusicModel a31;
        public void Show (A31MusicModel a31)
        {
            this.a31 = a31;
            AddChidren (new Button {
                Height = Application.GetRealHeight (36),
                BackgroundColor=SkinStyle.Current.MusicTopFrameLayout,
            });
 
            var topFrameLayout = new FrameLayout {
                Height = Application.GetRealHeight (100),
                Y = Application.GetRealHeight (36),
                BackgroundColor = SkinStyle.Current.MusicTopFrameLayout,
 
            };
 
            AddChidren (topFrameLayout);
 
            var btnTitle = new Button {
                TextID = MyInternationalizationString.Musicset,
                TextColor = SkinStyle.Current.MusicTextColor,
            };
            topFrameLayout.AddChidren (btnTitle);
 
            var back = new Button {
                Width = Application.GetRealWidth (82),
                Height = Application.GetRealHeight (89),
                X = Application.GetRealWidth (10),
                Gravity = Gravity.CenterVertical,
                UnSelectedImagePath = "MusicIcon/HomepageBack.png",
            };
            topFrameLayout.AddChidren (back);
            back.MouseDownEventHandler += (sender, e) => {
                RemoveFromParent ();
            };
 
            var hdl = new Button {
                Width = Application.GetRealWidth (154),
                Height = Application.GetRealHeight (90),
                X = Application.GetRealWidth (486),
                Gravity = Gravity.CenterVertical,
                UnSelectedImagePath = MainPage.LogoString,
            };
            topFrameLayout.AddChidren (hdl);
 
            var tempFrameLayout = new FrameLayout {
                Y = topFrameLayout.Bottom,
                Height = Application.GetRealHeight (Application.DesignHeight - 136),
                BackgroundColor = SkinStyle.Current.MusicVerticalScrolViewLayout,
            };
            AddChidren (tempFrameLayout);
 
            VerticalScrolViewLayout middle = new VerticalScrolViewLayout ();
            tempFrameLayout.AddChidren (middle);
 
            #region   播放器名称....
            var muiscnameLayout = new RowLayout {
                Height = Application.GetRealHeight (100),
                LineColor = SkinStyle.Current.MusicRowLayoutLineColor,
            };
            middle.AddChidren (muiscnameLayout);
 
            var btnmusicname = new Button {
                Height = Application.GetRealHeight (100),
                X = Application.GetRealWidth (30),
                TextAlignment = TextAlignment.CenterLeft,
                Text = Language.StringByID (MyInternationalizationString.Playername) + ":",
                Width = Application.GetRealWidth (250),
                TextColor = SkinStyle.Current.MusicTextColor,
                //Text = "播放器名称",
            };
            muiscnameLayout.AddChidren (btnmusicname);
 
            var btnpalyername = new Button {
                Height = Application.GetRealHeight (100),
                X = Application.GetRealWidth (350),
                TextAlignment = TextAlignment.CenterLeft,
                //Text =a31.Name==null?"UnKown":a31.Name,
                Text = a31.Name,
                Width = Application.GetRealWidth (250),
                TextColor = SkinStyle.Current.MusicTextColor,
            };
            muiscnameLayout.AddChidren (btnpalyername);
 
            var nextmusic = new Button {
                Width = Application.GetRealWidth (87),
                Height = Application.GetRealHeight (100),
                UnSelectedImagePath = "MusicIcon/Next.png",
                SelectedImagePath = "MusicIcon/NextSelecte.png",
                X = Application.GetRealWidth (550),
            };
            muiscnameLayout.AddChidren (nextmusic);
 
            EventHandler<MouseEventArgs> musicnameclick = (sender, e) => {
                MainPage.Loading.Start (Language.StringByID (MyInternationalizationString.load));
                System.Threading.Tasks.Task.Run (() => {
                    Application.RunOnMainThread (() => {
                        MainPage.Loading.Hide ();
                        A31Rename rename = new A31Rename ();
                        MainPage.MainFrameLayout.AddChidren (rename);
                        rename.show (a31);
                    });
                });
            };
            btnmusicname.MouseUpEventHandler += musicnameclick;
            muiscnameLayout.MouseUpEventHandler += musicnameclick;
            nextmusic.MouseUpEventHandler += musicnameclick;
            btnpalyername.MouseUpEventHandler += musicnameclick;
            #endregion
 
            #region   蓝牙....
            var bluetoothlayout = new RowLayout {
                Height = Application.GetRealHeight (100),
                LineColor = SkinStyle.Current.MusicRowLayoutLineColor,
            };
            if (a31.A31DeviceType == 918||a31.A31DeviceType == 919|| a31.A31DeviceType == 920) {
                middle.AddChidren (bluetoothlayout);
            }
 
            var btnbluetoothname = new Button {
                Height = Application.GetRealHeight (100),
                X = Application.GetRealWidth (30),
                TextAlignment = TextAlignment.CenterLeft,
                TextID = MyInternationalizationString.Musicbluetooth,
                Width = Application.GetRealWidth (200),
                TextColor = SkinStyle.Current.MusicTextColor,
                //Text = "蓝牙",
            };
            bluetoothlayout.AddChidren (btnbluetoothname);
 
            var nextbluetooth = new Button {
                Width = Application.GetRealWidth (87),
                Height = Application.GetRealHeight (100),
                UnSelectedImagePath = "MusicIcon/Next.png",
                SelectedImagePath = "MusicIcon/NextSelecte.png",
                X = Application.GetRealWidth (550),
            };
            bluetoothlayout.AddChidren (nextbluetooth);
 
            EventHandler<MouseEventArgs> btnbluetoothnameclick = (sender, e) => {
 
                Dialog window = new Dialog ();
                window.Show ();
 
                var frameLayout = new FrameLayout {
                    Width = Application.GetRealWidth (580),
                    Height = Application.GetRealHeight (300),
                    X = Application.GetRealWidth (30),
                    Y = Application.GetRealHeight (330),
                    BackgroundColor = 0xffffffff,
                };
                window.AddChidren (frameLayout);
 
                var Modifyname = new Button {
                    Width = Application.GetRealWidth (580),
                    Height = Application.GetRealHeight (80),
                    TextID = MyInternationalizationString.newbluetoothname,
                    //Text = "请输入新蓝牙名称",
                    Y = Application.GetRealHeight (10),
                    // TextColor = 0xff000000,
                    TextSize = 16,
                    TextColor = SkinStyle.Current.MusicTipTextColor,
                };
                frameLayout.AddChidren (Modifyname);
 
                var bluetoothname = new EditText {
                    Width = Application.GetRealWidth (540),
                    Height = Application.GetRealHeight (80),
                    Y = Application.GetRealHeight (80),
                    X = Application.GetRealWidth (20),
                    Gravity = Gravity.CenterVertical,
                    BackgroundColor = SkinStyle.Current.MusicTipBackgroundColor,
                    //TextColor = 0xff000000,
                    Radius = 1,
                    BorderWidth = 1,
                    BorderColor = SkinStyle.Current.MusicEditBorderColor,
                    TextColor = SkinStyle.Current.MusicTextColor,
                };
                frameLayout.AddChidren (bluetoothname);
 
                var ther1 = new Button {
                    Height = Application.GetRealHeight (2),
                    Y = Application.GetRealHeight (218),
                    BackgroundColor = 0xff666666,
                };
                frameLayout.AddChidren (ther1);
 
                var cancelrow = new RowLayout {
                    Y = Application.GetRealHeight (220),
                    Height = Application.GetRealHeight (80),
                    Width = Application.GetRealWidth (289),
                    BackgroundColor = 0xffcccccc,
                };
                frameLayout.AddChidren (cancelrow);
 
                var cancel = new Button {
                    TextID = MyInternationalizationString.cancel,
                   //TextColor = 0xff000000,
                    TextSize = 18,
                    TextColor = SkinStyle.Current.MusicTextColor,
                };
                cancelrow.AddChidren (cancel);
                cancel.MouseUpEventHandler += (sender1, e1) => {
                    window.Close ();
                };
 
                var ther = new Button {
                    Y = Application.GetRealHeight (220),
                    Height = Application.GetRealHeight (80),
                    Width = Application.GetRealWidth (2),
                    X = Application.GetRealHeight (289),
                    BackgroundColor = 0xff666666,
                };
                frameLayout.AddChidren (ther);
 
                var confirmrow = new RowLayout {
                    Y = Application.GetRealHeight (220),
                    X = Application.GetRealWidth (291),
                    Height = Application.GetRealHeight (80),
                    Width = Application.GetRealWidth (289),
                    BackgroundColor = 0xffcccccc,
                };
                frameLayout.AddChidren (confirmrow);
 
                var confirm = new Button {
                    TextID = MyInternationalizationString.confirm,
                    //TextColor = 0xff000000,
                    TextSize = 18,
                    TextColor = SkinStyle.Current.MusicTextColor,
                };
                confirmrow.AddChidren (confirm);
 
                confirm.MouseUpEventHandler += (sender1, e1) => {
                    if (bluetoothname.Text.Trim () == "") {
                        new Alert (Language.StringByID (MyInternationalizationString.Tip),
                                   Language.StringByID (MyInternationalizationString.nameisempty),
                                  Language.StringByID (MyInternationalizationString.Close)).Show ();
                        return;
                    }
                    send (a31.IPAddress, "MCU+PAS+BT" + bluetoothname.Text.Trim () + "*&");
                    window.Close ();
                };
            };
            bluetoothlayout.MouseUpEventHandler += btnbluetoothnameclick;
            btnbluetoothname.MouseUpEventHandler += btnbluetoothnameclick;
            nextbluetooth.MouseUpEventHandler += btnbluetoothnameclick;
            #endregion
 
            #region   均衡器....
            var eqthlayout = new RowLayout {
                Height = Application.GetRealHeight (100),
                LineColor = SkinStyle.Current.MusicRowLayoutLineColor,
            };
            if (a31.A31DeviceType == 918 || a31.A31DeviceType == 919 || a31.A31DeviceType == 920)
            {
                middle.AddChidren(eqthlayout);
            }
            var btneq = new Button {
                Height = Application.GetRealHeight (100),
                X = Application.GetRealWidth (30),
                TextAlignment = TextAlignment.CenterLeft,
                TextID = MyInternationalizationString.equalizer,
                Width = Application.GetRealWidth (200),
                TextColor = SkinStyle.Current.MusicTextColor,
                //Text = "均衡器",
            };
            eqthlayout.AddChidren (btneq);
 
            var nexteq = new Button {
                Width = Application.GetRealWidth (87),
                Height = Application.GetRealHeight (100),
                UnSelectedImagePath = "MusicIcon/Next.png",
                SelectedImagePath = "MusicIcon/NextSelecte.png",
                X = Application.GetRealWidth (550),
            };
            eqthlayout.AddChidren (nexteq);
 
            EventHandler<MouseEventArgs> btneqnameclick = (sender, e) => {
 
                var dialog = new Dialog () {
                    BackgroundColor =SkinStyle.Current.MusicDialogBackgroundColor, //0xFF484848,
                    Width = Application.GetRealWidth (600),
                    Height = Application.GetRealHeight (400),
                };
                dialog.Show ();
 
                var titleFrameLayout = new FrameLayout {
                    Width = dialog.Width,
                    BackgroundColor =SkinStyle.Current.MusicTopFrameLayout, //0xFF121212,
                    Height = Application.GetRealHeight (100),
                };
                dialog.AddChidren (titleFrameLayout);
 
                var btneqtitle = new Button {
                    TextID = MyInternationalizationString.EqualizerSettings,
                    //Text = "均衡器设置",
                    TextColor = SkinStyle.Current.MusicTextColor,
                };
                titleFrameLayout.AddChidren (btneqtitle);
 
                var btneqback = new Button {
                    Width = Application.GetRealWidth (82),
                    Height = Application.GetRealHeight (89),
                    X = Application.GetRealWidth (10),
                    Gravity = Gravity.CenterVertical,
                    UnSelectedImagePath = "MusicIcon/HomepageBack.png",
                };
                titleFrameLayout.AddChidren (btneqback);
                btneqback.MouseDownEventHandler += (sender1, e1) => {
                    dialog.Close ();
                };
 
                var trebleFrameLayout = new FrameLayout {
                    Y = Application.GetRealHeight (130),
                    Width = Application.GetRealWidth (600),
                    Height = Application.GetRealHeight (100),
                };
                dialog.AddChidren (trebleFrameLayout);
 
               var btntreblemax = new Button {
                    Width = Application.GetRealWidth (100),
                    Height = Application.GetRealHeight (100),
                    X = Application.GetRealWidth (20),
                    Gravity = Gravity.CenterVertical,
                    TextAlignment = TextAlignment.CenterLeft,
                    //Text = "高音:",
                    TextID = MyInternationalizationString.treble,
                    TextColor = SkinStyle.Current.MusicTextColor,
                };
                trebleFrameLayout.AddChidren (btntreblemax);
 
                var btnCurrentTreble = new Button {
                    Width = Application.GetRealWidth (90),
                    Height = Application.GetRealHeight (100),
                    X = Application.GetRealWidth (510),
                    Gravity = Gravity.CenterVertical,
                    TextAlignment = TextAlignment.CenterLeft,
                    TextColor = SkinStyle.Current.MusicTextColor,
                    Text = "0db",
                };
                trebleFrameLayout.AddChidren (btnCurrentTreble);
 
 
                var treblehorizontalSeekBarvol = new HorizontalSeekBar {
                    Width = Application.GetRealWidth (350),//400
                    //Height = Application.GetRealHeight (100),
                    Radius = (uint)Application.GetRealHeight (25),
                    X = Application.GetRealWidth (120),
                    ProgressColor = 0xffFE5E00,
                    ThumbRadius = 11,
                    ThumbColor = SkinStyle.Current.HorizontalSeekBarThumbColor,
                };
                trebleFrameLayout.AddChidren (treblehorizontalSeekBarvol);
                int n1 = 5,db1=0;
                treblehorizontalSeekBarvol.ProgressChanged += (sender2, e2) => {
                    if (0 <= e2 && e2 <= 8) {
                        n1 = 0;
                        db1 = -5;
                    } else if (8 < e2 && e2 <= 17) {
                        n1 = 1;
                        db1 = -4;
                    } else if (17 < e2 && e2 <= 26) {
                        n1 = 2;
                        db1 = -3;
                    } else if (26 < e2 && e2 <= 35) {
                        n1 = 3;
                        db1 = -2;
                    } else if (35 < e2 && e2 <= 44) {
                        n1 = 4;
                        db1 = -1;
                    } else if (44 < e2 && e2 <= 53) {
                        n1 = 5;
                        db1 = 0;
                    } else if (53 < e2 && e2 <= 62) {
                        n1 = 6;
                        db1 = 1;
                    } else if (62 < e2 && e2 <= 71) {
                        n1 = 7;
                        db1 = 2;
                    } else if (71 < e2 && e2 <= 80) {
                        n1 = 8;
                        db1 = 3;
                    } else if (80 < e2 && e2 <= 89) {
                        n1 = 9;
                        db1 = 4;
                    } else if (89 < e2 && e2 <= 100) {
                        n1 = 10;
                        db1 = 5;
                    }
                    if (-5 <= db1 && db1 <= -1) {
                        btnCurrentTreble.Text = db1 + "db";
                    } else if (1 <= db1 && db1<= 5) {
                        btnCurrentTreble.Text = "+" + db1 + "db";
                    } else {
                        btnCurrentTreble.Text = "0db";
                    }
                    send (a31.IPAddress, $"MCU+PAS+EQSet:treble:{n1}&");
                    //init (e2, "treble");
 
                };
 
                var bassFrameLayout = new FrameLayout {
                    Y = Application.GetRealHeight (270),
                    Width = Application.GetRealWidth (600),
                    Height = Application.GetRealHeight (100),
                };
                dialog.AddChidren (bassFrameLayout);
 
                var btnbass = new Button {
                    Width = Application.GetRealWidth (100),
                    Height = Application.GetRealHeight (100),
                    X = Application.GetRealWidth (20),
                    Gravity = Gravity.CenterVertical,
                    TextAlignment = TextAlignment.CenterLeft,
                    //Text = "低音:",
                    TextID = MyInternationalizationString.bass,
                    TextColor = SkinStyle.Current.MusicTextColor,
                };
                bassFrameLayout.AddChidren (btnbass);
 
                var btnCurrentbass = new Button {
                    Width = Application.GetRealWidth (90),
                    Height = Application.GetRealHeight (100),
                    X = Application.GetRealWidth (510),
                    Gravity = Gravity.CenterVertical,
                    TextAlignment = TextAlignment.CenterLeft,
                    TextColor = SkinStyle.Current.MusicTextColor,
                    Text = "0db",
                };
                bassFrameLayout.AddChidren (btnCurrentbass);
 
 
                var basshorizontalSeekBarvol = new HorizontalSeekBar {
                    Width = Application.GetRealWidth (350),
                    //Height = Application.GetRealHeight (100),
                    Radius = (uint)Application.GetRealHeight (25),
                    X = Application.GetRealWidth (120),
                    ProgressColor = 0xffFE5E00,
                    ThumbRadius = 11,
                    ThumbColor = SkinStyle.Current.HorizontalSeekBarThumbColor,
                };
                bassFrameLayout.AddChidren (basshorizontalSeekBarvol);
                int n2 = 5, db2 = 0;
                basshorizontalSeekBarvol.ProgressChanged += (sender2, e2) => {
                    if (0 <= e2 && e2 <= 8) {
                        n2 = 0;
                        db2 = -5;
                    } else if (8 < e2 && e2 <= 17) {
                        n2 = 1;
                        db2 = -4;
                    } else if (17 < e2 && e2 <= 26) {
                        n2 = 2;
                        db2 = -3;
                    } else if (26 < e2 && e2 <= 35) {
                        n2 = 3;
                        db2 = -2;
                    } else if (35 < e2 && e2 <= 44) {
                        n2 = 4;
                        db2 = -1;
                    } else if (44 < e2 && e2 <= 53) {
                        n2 = 5;
                        db2 = 0;
                    } else if (53 < e2 && e2 <= 62) {
                        n2 = 6;
                        db2 = 1;
                    } else if (62 < e2 && e2 <= 71) {
                        n2 = 7;
                        db2 = 2;
                    } else if (71 < e2 && e2 <= 80) {
                        n2 = 8;
                        db2 = 3;
                    } else if (80 < e2 && e2 <= 89) {
                        n2 = 9;
                        db2 = 4;
                    } else if (89 < e2 && e2 <= 100) {
                        n2 = 10;
                        db2 = 5;
                    }
                    if (-5 <= db2 && db2 <= -1) {
                        btnCurrentbass.Text = db2 + "db";
                    } else if (1 <= db2 && db2 <= 5) {
                        btnCurrentbass.Text = "+" + db2 + "db";
                    } else {
                        btnCurrentbass.Text = "0db";
                    }
                    send (a31.IPAddress, $"MCU+PAS+EQSet:bass:{n2}&");
                    //init (e2, "bass");
                   
                };
                var str = EqGetSend (a31.IPAddress, "MCU+PAS+EQGet&");
                if (str != null) {
                    try {
                        string [] array = str.Split ('&');
                        int treblevalue = int.Parse (array [0].Replace ("MCU+PAS+EQ:treble:", ""));
                        var treblval = equpdate (treblevalue);
                        if (treblval != null) {
                            string [] value1 = treblval.Split ('_');
                            if (value1!=null) {
                                int treblecurrentvol = int.Parse (value1 [0]);
                                int treblecurrentdb = int.Parse (value1 [1]);
                                if (-5<= treblecurrentdb && treblecurrentdb <= -1) {
                                    btnCurrentTreble.Text =treblecurrentdb + "db";
                                } else if (1 < treblecurrentdb && treblecurrentdb <= 5) {
                                    btnCurrentTreble.Text = "+" + treblecurrentdb + "db";
                                } else {
                                    btnCurrentTreble.Text = "0db";
                                }
                                treblehorizontalSeekBarvol.Progress =treblecurrentvol;
                            }
                        }
                        int bassvalue = int.Parse (array [1].Replace ("MCU+PAS+EQ:bass:", ""));
                        var bassval = equpdate (bassvalue);
                        if (bassval != null) {
                            string [] value2 = bassval.Split ('_');
                            if (value2 != null) {
                                int basscurrentvol = int.Parse (value2 [0]);
                                int basscurrentdb = int.Parse (value2 [1]);
                                if (-5 <= basscurrentdb && basscurrentdb <= -1) {
                                    btnCurrentbass.Text = basscurrentdb + "db";
                                } else if (1 <= basscurrentdb && basscurrentdb <= 5) {
                                    btnCurrentbass.Text = "+" + basscurrentdb + "db";
                                } else {
                                    btnCurrentbass.Text = "0db";
                                }
                                basshorizontalSeekBarvol.Progress = basscurrentvol;
                            }
                        }
                    } catch { }
                }
            };
            eqthlayout.MouseUpEventHandler += btneqnameclick;
            btneq.MouseUpEventHandler += btneqnameclick;
            nexteq.MouseUpEventHandler += btneqnameclick;
            #endregion
 
            #region   设备信息....
            var devicelayout = new RowLayout {
                Height = Application.GetRealHeight (100),
                LineColor = SkinStyle.Current.MusicRowLayoutLineColor,
            };
            middle.AddChidren (devicelayout);
            var btndevice = new Button {
                Height = Application.GetRealHeight (100),
                X = Application.GetRealWidth (30),
                TextAlignment = TextAlignment.CenterLeft,
                TextID = MyInternationalizationString.speakerinfo,
                Width = Application.GetRealWidth (350),
                TextColor = SkinStyle.Current.MusicTextColor,
                //Text = "设备信息",
            };
            devicelayout.AddChidren (btndevice);
 
            var nextdevice = new Button {
                Width = Application.GetRealWidth (87),
                Height = Application.GetRealHeight (100),
                UnSelectedImagePath = "MusicIcon/Next.png",
                SelectedImagePath = "MusicIcon/NextSelecte.png",
                X = Application.GetRealWidth (550),
            };
            devicelayout.AddChidren (nextdevice);
            EventHandler<MouseEventArgs> deviceclick = (sender, e) => {
               
 
                MainPage.Loading.Start (Language.StringByID (MyInternationalizationString.load));
                System.Threading.Tasks.Task.Run (() => {
                    Application.RunOnMainThread (() => {
                        MainPage.Loading.Hide ();
                        var a31DeviceArgument = new A31DeviceArgument ();
                        MainPage.MainFrameLayout.AddChidren (a31DeviceArgument);
                        a31DeviceArgument.Show (a31);
                    });
                });
            };
            devicelayout.MouseUpEventHandler += deviceclick;
            btndevice.MouseUpEventHandler += deviceclick;
            nextdevice.MouseUpEventHandler += deviceclick;
 
            #endregion
 
            #region   IP....
            var IPLayout = new RowLayout {
                Height = Application.GetRealHeight (100),
                LineColor = SkinStyle.Current.MusicRowLayoutLineColor,
            };
            //middle.AddChidren (IPLayout);
 
            var ip1 = new Button {
                Height = Application.GetRealHeight (100),
                X = Application.GetRealWidth (30),
                TextAlignment = TextAlignment.CenterLeft,
                //TextID = MyInternationalizationString.custom,
                Width=Application.GetRealWidth(200),
                Text = "IP :",
                TextColor = SkinStyle.Current.MusicTextColor,
            };
            IPLayout.AddChidren (ip1);
 
            var ip = new Button {
                Height = Application.GetRealHeight (100),
                X = Application.GetRealWidth (130),
                TextAlignment = TextAlignment.CenterLeft,
                Text = a31.IPAddress,
                TextColor = SkinStyle.Current.MusicTextColor,
            };
            IPLayout.AddChidren (ip);
            #endregion
        }
        System.Threading.Thread thread;
        void send (string ip, string message)
        {
           // System.Console.WriteLine ("发送高低音" + message);
            if (thread != null) {
                thread.Abort ();
            }
            thread=new  System.Threading.Thread(() => {
                var tcpClient = new TcpClient () { ReceiveTimeout = 1000 };
               try { 
                    //进行连接
                    tcpClient.Connect (new IPEndPoint (IPAddress.Parse (ip), 8899));
                    var buffter = Encoding.UTF8.GetBytes (message);
                    var sendByes = new byte [20 + buffter.Length];
                    sendByes [0] = 0x18;
                    sendByes [1] = 0x96;
                    sendByes [2] = 0x18;
                    sendByes [3] = 0x20;
 
                    sendByes [4] = (byte)((buffter.Length & 0x000000FF) >> 0);
                    sendByes [5] = (byte)((buffter.Length & 0x0000FF00) >> 8);
                    sendByes [6] = (byte)((buffter.Length & 0x00FF0000) >> 16);
                    sendByes [7] = (byte)((buffter.Length & 0xFF000000) >> 24);
 
                    var checkSum = getCheckSum (buffter);
                    sendByes [8] = (byte)((checkSum & 0x000000FF) >> 0);
                    sendByes [9] = (byte)((checkSum & 0x0000FF00) >> 8);
                    sendByes [10] = (byte)((checkSum & 0x00FF0000) >> 16);
                    sendByes [11] = (byte)((checkSum & 0xFF000000) >> 24);
 
                    sendByes [16] = 0x08;
 
                    Array.Copy (buffter, 0, sendByes, 20, buffter.Length);
                    tcpClient.GetStream ().Write (sendByes, 0, sendByes.Length);
                    tcpClient.GetStream ().Flush ();
 
                    thread = null;
                } catch { }
                finally{
                    tcpClient.Close ();
                }
            });
            thread.Start ();
        }
 
        string EqGetSend (string ip, string message)
        {
            //System.Console.WriteLine ("读取高低音" + message);
            var tcpClient = new TcpClient () { ReceiveTimeout = 1000 };
            List<byte> list = null;
            try {
                //进行连接
                tcpClient.Connect (new IPEndPoint (IPAddress.Parse (ip), 8899));
 
                var buffter = Encoding.UTF8.GetBytes (message);
                var sendByes = new byte [20 + buffter.Length];
                sendByes [0] = 0x18;
                sendByes [1] = 0x96;
                sendByes [2] = 0x18;
                sendByes [3] = 0x20;
 
                sendByes [4] = (byte)((buffter.Length & 0x000000FF) >> 0);
                sendByes [5] = (byte)((buffter.Length & 0x0000FF00) >> 8);
                sendByes [6] = (byte)((buffter.Length & 0x00FF0000) >> 16);
                sendByes [7] = (byte)((buffter.Length & 0xFF000000) >> 24);
 
                var checkSum = getCheckSum (buffter);
                sendByes [8] = (byte)((checkSum & 0x000000FF) >> 0);
                sendByes [9] = (byte)((checkSum & 0x0000FF00) >> 8);
                sendByes [10] = (byte)((checkSum & 0x00FF0000) >> 16);
                sendByes [11] = (byte)((checkSum & 0xFF000000) >> 24);
 
                sendByes [16] = 0x08;
 
                Array.Copy (buffter, 0, sendByes, 20, buffter.Length);
                tcpClient.GetStream ().Write (sendByes, 0, sendByes.Length);
                tcpClient.GetStream ().Flush ();
 
                var len = 0;
                var bytes = new byte [100];
                while (0 < (len = tcpClient.GetStream ().Read (bytes, 0, bytes.Length))) {
                    if (list == null) {
                        list = new List<byte> ();
                    }
                    for (int i = 20; i < len; i++) {
                        list.Add (bytes [i]);
                    }
                }
                return Encoding.UTF8.GetString (list.ToArray ());
            } catch {
                if (list == null) {
                    return null;
                } else {
                    return Encoding.UTF8.GetString (list.ToArray ()).TrimEnd ('&');
                }
            } finally {
                try {
                    tcpClient.Close ();
                } catch { }
            }
        }
 
        uint getCheckSum (byte [] buffer)
        {
            uint check_sum = 0;
 
            for (int i = 0; i < buffer.Length; i++) {
                check_sum += buffer [i];
            }
 
            return check_sum;
        }
 
        void init (int val, string str)
        {
            int n = 5;
            if (0 <= val && val <= 8) {
                n = 0;
            } else if (8 < val && val <= 17) {
                n = 1;
            } else if (17 < val && val <= 26) {
                n = 2;
            } else if (26 < val && val <= 35) {
                n = 3;
            } else if (35 < val && val <= 44) {
                n = 4;
            } else if (44 < val && val <= 53) {
                n = 5;
            } else if (53 < val && val <= 62) {
                n = 6;
            } else if (62 < val && val <= 71) {
                n = 7;
            } else if (71 < val && val <= 80) {
                n = 8;
            } else if (80 < val && val <= 89) {
                n = 9;
            } else if (89 < val && val <= 100) {
                n = 10;
            }
            send (a31.IPAddress, $"MCU+PAS+EQSet:{str}:{n}&");
        }
 
        string equpdate (int n)
        {
            int val = 50,db=0;
 
            if (n == 0) {
                val = 0;
                db = -5;
            } else if (n == 1) {
                val = 12;
                db = -4;
            } else if (n == 2) {
                val = 21;
                db = -3;
            } else if (n == 3) {
                val = 30;
                db = -2;
            } else if (n == 4) {
                val = 40;
                db = -1;
            } else if (n == 5) {
                val = 50;
                db = 0;
            } else if (n == 6) {
                val = 57;
                db = 1;
            } else if (n == 7) {
                val = 66;
                db = 2;
            } else if (n == 8) {
                val = 76;
                db = 3;
            } else if (n == 9) {
                val = 85;
                db = 4;
            } else if (n == 10) {
                val = 100;
                db = 5;
            }
            return val.ToString()+"_"+db;
        }
 
 
    }
}