wxr
2024-07-16 cbc156bc38d8b8eae7aef60cb186ab2b52fa701f
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
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
using Shared;
using System;
using System.Collections.Generic;
using HDL_ON.Entity;
using HDL_ON.UI.Music;
using HDL_ON.UI.UI2.FuntionControlView.VideoDoorLock;
using HDL_ON.UI.UI2.FuntionControlView.Aks.CommonView;
 
namespace HDL_ON.UI.UI2.FuntionControlView.HisenseTV
{
    /// <summary>
    /// 海信电视界面
    /// </summary>
    public class HisenseTvPage : BaseFramLayout
    {
 
 
        #region   -------变量声明---------  
        /// <summary>
        /// 设备
        /// </summary>
        private Function device;
        /// <summary>
        /// 上一级界面的设备名字控件
        /// </summary>
        private Button btnDeviceName;
        /// <summary>
        /// 上一级界面的房间名字控件
        /// </summary>
        private Button btnRoomName;
        /// <summary>
        /// 上一级界面的收藏控件
        /// </summary>
        private Button btnCollectionIcon;
        /// <summary>
        /// 头部布局
        /// </summary>
        private TopView topView;
        /// <summary>
        ///中部布局
        /// </summary>
        VerticalScrolViewLayout vv;
        /// <summary>
        /// 当前设备名称
        /// </summary>
        private Button btnOpenCurrDeviceName;
        /// <summary>
        /// 区域
        /// </summary>
        private Button btnOpenCurrDeviceRoom;
        /// <summary>
        ///收藏图标
        /// </summary>
        private Button btnOpenCollectIcon;
        CustomFrameLayout shouyeFL;
        CustomFrameLayout kaijiFL;
        CustomFrameLayout guanFL;
        Button btn_jia;
        Button btn_jian;
        CustomButton caidanBtn;
        CustomButton bofangBtn;
        CustomButton zantingBtn;
        CustomButton kuaijinBtn;
        CustomButton kauituiBtn;
        CustomButton jingyinBtn;
        CustomButton shezhiBtn;
        CustomButton jiechujingyinBtn;
        CustomButton fanhuiBtn;
        MenuFramLayout muenFrameLayout;
        SourceFrameLayout sourceFrameLayout;
 
        /// <summary>
        /// 表示来自那个界面
        /// </summary>
        private CommonMethod.Comerom comerom;
        /// <summary>
        /// 删除设备后需要更新界面的回调
        /// </summary>
        public Action action;
        #endregion
 
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="function">设备</param>
        /// <param name="btnDeviceName">上一级界面的设备名字控件(注:不能传null,没有可以传new Button())</param>
        /// <param name="btnRoomName">上一级界面的房间名字控件(注:不能传null,没有可以传new Button())</param>
        /// <param name="btnCollectionIcon">上一级界面的房间名字控件(注:不能传null,没有可以传new Button())</param> 
        public HisenseTvPage(Function function, Button btnDeviceName, Button btnRoomName, Button btnCollectionIcon, CommonMethod.Comerom comerom, Action action)
        {
            this.device = function;
            this.btnDeviceName = btnDeviceName;
            this.btnRoomName = btnRoomName;
            this.btnCollectionIcon = btnCollectionIcon;
            this.comerom = comerom;
            this.action = action;
 
        }
 
        public void Show()
        {
            //初始化UI
            this.InitTopUI();
            this.InitOpenUI();
            //初始化事件
            this.EventListener();
            //读取数据
            this.ReadData();
 
        }
 
        /// <summary>
        /// 注册事件
        /// </summary>
        private void EventListener()
        {
            //返回
            this.topView.clickBackBtn.MouseUpEventHandler += (sender, e) =>
            {
                this.RemoveFromParent();
            };
            //设置
            this.topView.clickSetBtn.MouseUpEventHandler += (sender, e) =>
            {
                CommonMethod.Current.MainThread(() =>
                {
                    //调用秀绕的界面
                    var infoView = new UI.FunctionBaseInfoSetPage(this.device, () =>
                    {
                        if (this.btnDeviceName == null || this.btnRoomName == null || this.device == null)
                        {
                            return;
                        }
                        ////刷新显示
                        this.btnDeviceName.Text = this.device.name;
                        this.btnRoomName.Text = this.device.GetRoomListName();
                        //
                        this.btnOpenCurrDeviceName.Text = this.device.name;
                        this.btnOpenCurrDeviceRoom.Text = this.device.GetRoomListName();
                        this.CalculatedPosition();//重新计算宽度
 
                    });
                    infoView.actionDel += () =>
                    {
                        //解绑设备后
                        this.RemoveFromParent();
                        this.action?.Invoke();
 
                    };
                    MainPage.BasePageView.AddChidren(infoView);
                    infoView.LoadPage();
                    MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                });
            };
            //收藏
            this.btnOpenCollectIcon.MouseUpEventHandler += (sender, e) =>
            {
                btnOpenCollectIcon.IsSelected = this.device.collect = !btnOpenCollectIcon.IsSelected;
                this.device.CollectFunction();
                this.btnCollectionIcon.IsSelected = btnOpenCollectIcon.IsSelected;
            };
 
            //首页
            shouyeFL.SetClickListener((fl, btnImage, btnText) =>
            {
                ControlCommand(HisenseTVFunctionalAttributeConstant.home_page, "");
            });
            //开机
            kaijiFL.SetClickListener((fl, btnImage, btnText) =>
            {
                ControlCommand(HisenseTVFunctionalAttributeConstant.wol, "on");
 
            });
            //关机
            guanFL.SetClickListener((fl, btnImage, btnText) =>
            {
                ControlCommand(HisenseTVFunctionalAttributeConstant.on_off, "off");
 
            });
            //音量+
            btn_jia.MouseUpEventHandler += (sender, e) =>
            {
                ControlCommand(HisenseTVFunctionalAttributeConstant.volume_add, "");
                this.SetButtonIsSelected(btn_jia);
 
            };
            //音量-
            btn_jian.MouseUpEventHandler += (sender, e) =>
            {
                ControlCommand(HisenseTVFunctionalAttributeConstant.volume_subtract, "");
                this.SetButtonIsSelected(btn_jian);
            };
            //菜单
            caidanBtn.SetClickListener((btn) =>
             {
                 ControlCommand(HisenseTVFunctionalAttributeConstant.operation, "11");
 
             });
            //播放
            bofangBtn.SetClickListener((btn) =>
            {
                ControlCommand(HisenseTVFunctionalAttributeConstant.media_play, "");
 
            });
            //暂停
            zantingBtn.SetClickListener((btn) =>
            {
                ControlCommand(HisenseTVFunctionalAttributeConstant.media_pause, "");
            });
            //快进
            kuaijinBtn.SetClickListener((btn) =>
            {
                ControlCommand(HisenseTVFunctionalAttributeConstant.fast_forward, "");
            });
            //快退
            kauituiBtn.SetClickListener((btn) =>
            {
                ControlCommand(HisenseTVFunctionalAttributeConstant.fast_back, "");
            });
            //静音
            jingyinBtn.SetClickListener((btn) =>
            {
                ControlCommand(HisenseTVFunctionalAttributeConstant.mute, "1");
            });
            //设置
            shezhiBtn.SetClickListener((btn) =>
            {
                ControlCommand(HisenseTVFunctionalAttributeConstant.system_setting, "");
            });
            //解除静音
            jiechujingyinBtn.SetClickListener((btn) =>
            {
                ControlCommand(HisenseTVFunctionalAttributeConstant.mute, "0");
            });
            //返回
            fanhuiBtn.SetClickListener((btn) =>
            {
                ControlCommand(HisenseTVFunctionalAttributeConstant.operation, "5");
            });
            //上
            muenFrameLayout.SetTopClickListener((muen) =>
            {
 
                ControlCommand(HisenseTVFunctionalAttributeConstant.operation, "0");
 
            });
            //下
            muenFrameLayout.SetBottomClickListener((muen) =>
            {
 
                ControlCommand(HisenseTVFunctionalAttributeConstant.operation, "1");
 
            });
            //左
            muenFrameLayout.SetLeftClickListener((muen) =>
            {
 
                ControlCommand(HisenseTVFunctionalAttributeConstant.operation, "2");
 
            });
            //右
            muenFrameLayout.SetRightClickListener((muen) =>
            {
 
                ControlCommand(HisenseTVFunctionalAttributeConstant.operation, "3");
 
            });
            //OK
            muenFrameLayout.SetOkClickListener((muen) =>
            {
 
                ControlCommand(HisenseTVFunctionalAttributeConstant.operation, "4");
 
            });
            //信号源
            sourceFrameLayout.selectAction += (key) =>
            {
                var p = new UI2.Intelligence.Automation.PublicInterface();
                var dic = p.GetHisenseSignalSourceDic();
                string value = p.GetValue(dic, key);
                ControlCommand(HisenseTVFunctionalAttributeConstant.signal, value);
            };
 
        }
        /// <summary>
        /// 发送控制属性指令
        /// </summary>
        /// <param name="key">功能属性(语雀上定义的)</param>
        /// <param name="value">值</param>
        /// <param name="action">结果回调(默认不回调)</param>
        private void ControlCommand(string key, string value, Action<bool> action = null)
        {
            try
            {
                if (this.device == null)
                {
                    //设备不在线控制失败
                    Application.RunOnMainThread(() =>
                    {
                        CommonMethod.Current.ShowTip(Language.StringByID(StringId.shebeibuzaixian), 3);
                    });
                    return;
                }
 
                if (!this.device.online && key != HisenseTVFunctionalAttributeConstant.wol)
                {
                    //设备不在线控制失败
                    Application.RunOnMainThread(() =>
                    {
                        CommonMethod.Current.ShowTip(Language.StringByID(StringId.shebeibuzaixian), 3);
                    });
                    return;
                }
 
                Dictionary<string, string> dic = new Dictionary<string, string>();
                dic.Add(key, value);
                Send.Current.SendControlCommand(this.device, dic, action);
            }
            catch { }
        }
        /// <summary>
        /// 初始化数据
        /// </summary>
        private void ReadData()
        {
            if (this.device == null)
            {
                return;
            }
            CommonMethod.Current.Loading.Start();
            CommonMethod.Current.SunThread(() =>
            {
                try
                {
 
                    var isRefreshDeviceStatus = Send.Current.RefreshDeviceStatus(new List<string> { this.device.deviceId });
                    if (isRefreshDeviceStatus)
                    {
                        var fun = Send.Current.GetDeviceInfo(this.device.deviceId);
                        if (fun != null)
                        {
                            //更新真实在线状态
                            this.device.online = fun.online;
                        }
 
                    }
                }
                catch { }
                finally
                {
                    Application.RunOnMainThread(() =>
                    {
                        CommonMethod.Current.Loading.Hide();
                    });
                }
            });
        }
 
        #region   -------界面布局---------
        /// <summary>
        /// 初始化【开机】界面
        /// </summary>
        private void InitOpenUI()
        {
            #region   ---界面布局---
            vv = new VerticalScrolViewLayout
            {
                Y = topView.fLayout.Bottom,
                Height = Application.GetRealHeight(H_W.H - H_W.T_Height),
            };
            this.AddChidren(vv);
            var baseOpenFL = new BaseFramLayout();
            vv.AddChidren(baseOpenFL);
            var backgroundOpenFl = new FrameLayout
            {
                Y = Application.GetRealHeight(24),
                X = Application.GetRealWidth(24),
                Height = Application.GetRealHeight(648-60),
                Width = Application.GetRealWidth(327),
                BackgroundImagePath = "HisenseTv/onbj.png",
            };
            baseOpenFL.AddChidren(backgroundOpenFl);
 
            baseOpenFL.AdjustRealHeight(16);
 
            btnOpenCollectIcon = new Button
            {
                X = Application.GetRealWidth(273),
                Y = Application.GetRealHeight(14),
                Width = Application.GetRealWidth(40),
                Height = Application.GetRealWidth(40),
                UnSelectedImagePath = "MusicIcon/collect.png",
                SelectedImagePath = "MusicIcon/collectSelected.png",
                IsSelected = this.device.collect,
            };
            backgroundOpenFl.AddChidren(btnOpenCollectIcon);
 
            btnOpenCurrDeviceName = new Button
            {
                TextSize = TextSize.Text24,
                TextColor = MusicColor.Text18Color,
                Width = Application.GetRealWidth(160),
                Height = Application.GetRealHeight(33),
                Y = Application.GetRealHeight(16),
                X = Application.GetRealWidth(16),
                Text = this.device.name,
                TextAlignment = TextAlignment.CenterLeft,
                IsBold = true
            };
            backgroundOpenFl.AddChidren(btnOpenCurrDeviceName);
 
 
            btnOpenCurrDeviceRoom = new Button
            {
                TextSize = TextSize.Text12,
                TextColor = MusicColor.MusicNoTxetColor,
                Width = Application.GetRealWidth(160),
                Height = Application.GetRealHeight(17),
                Y = btnOpenCurrDeviceName.Bottom + Application.GetRealHeight(4),
                X = Application.GetRealWidth(16),
                Text = this.device.GetRoomListName(),
                TextAlignment = TextAlignment.CenterLeft,
            };
            backgroundOpenFl.AddChidren(btnOpenCurrDeviceRoom);
     
            int yHeight = btnOpenCurrDeviceRoom.Bottom + Application.GetRealHeight(16);
            shouyeFL = new CustomFrameLayout();
            backgroundOpenFl.AddChidren(shouyeFL);
            shouyeFL.X = Application.GetRealWidth(24);
            shouyeFL.Y = yHeight;
            shouyeFL.AddImageView();
            shouyeFL.AddTextButtonView();
            shouyeFL.GetImageButton().UnSelectedImagePath = "HisenseTv/shouye.png";
            shouyeFL.GetImageButton().SelectedImagePath = "HisenseTv/shouyeSelected.png";
            shouyeFL.GetTextButton().TextID = StringId.shouye;
 
 
            kaijiFL = new CustomFrameLayout();
            backgroundOpenFl.AddChidren(kaijiFL);
            kaijiFL.X = shouyeFL.Right + Application.GetRealWidth(37);
            kaijiFL.Y = yHeight;
            kaijiFL.AddImageView();
            kaijiFL.AddTextButtonView();
            kaijiFL.GetImageButton().UnSelectedImagePath = "HisenseTv/kai.png";
            kaijiFL.GetImageButton().SelectedImagePath = "HisenseTv/kaiguanSelected.png";
            kaijiFL.GetTextButton().TextID = StringId.kaiji;
 
            guanFL = new CustomFrameLayout();
            backgroundOpenFl.AddChidren(guanFL);
            guanFL.X = kaijiFL.Right + Application.GetRealWidth(37);
            guanFL.Y = yHeight;
            guanFL.AddImageView();
            guanFL.AddTextButtonView();
            guanFL.GetImageButton().UnSelectedImagePath = "HisenseTv/guan.png";
            guanFL.GetImageButton().SelectedImagePath = "HisenseTv/kaiguanSelected.png";
            //guanFL.GetImageButton().UnSelectedImagePath = "HisenseTv/caidan.png";
            guanFL.GetTextButton().TextID = StringId.guanji;
 
            var yinliangFL = new FrameLayout();
            backgroundOpenFl.AddChidren(yinliangFL);
            yinliangFL.Height = Application.GetRealHeight(146-16);
            yinliangFL.Width = Application.GetRealWidth(68);
            yinliangFL.Y = Application.GetRealHeight(260-8-20);
            yinliangFL.X = shouyeFL.X;
            yinliangFL.BackgroundColor = 0xFFF2F3F7;
            yinliangFL.Radius = (uint)Application.GetRealWidth(34);
 
            btn_jia = new Button
            {
                Width = Application.GetRealWidth(32),
                Height = Application.GetRealWidth(32),
                UnSelectedImagePath = "HisenseTv/yingliangjia.png",
                SelectedImagePath = "HisenseTv/yingliangjiaSelected.png",
                Y = Application.GetRealHeight(16),
                Gravity = Gravity.CenterHorizontal,
 
            };
            yinliangFL.AddChidren(btn_jia);
            Button btnText = new Button
            {
                Y = Application.GetRealHeight(63-8),
                Height = Application.GetRealHeight(20),
                //Text = "音量",
                TextID = StringId.yinliang,
                TextColor = MusicColor.TextColor,
                TextSize = TextSize.Text14,
                Gravity = Gravity.CenterHorizontal,
 
            };
            yinliangFL.AddChidren(btnText);
            btn_jian = new Button
            {
                Y = Application.GetRealHeight(98-8),
                Width = Application.GetRealWidth(32),
                Height = Application.GetRealWidth(32),
                UnSelectedImagePath = "HisenseTv/yingliangjian.png",
                SelectedImagePath = "HisenseTv/yingliangjianSelected.png",
                Gravity = Gravity.CenterHorizontal,
 
            };
            yinliangFL.AddChidren(btn_jian);
 
            int bottomValue= 4;
            caidanBtn = new CustomButton();
            caidanBtn.TextID = StringId.caidan;
            caidanBtn.Y = shouyeFL.Bottom + Application.GetRealHeight(bottomValue);
            caidanBtn.X = shouyeFL.X;
            backgroundOpenFl.AddChidren(caidanBtn);
 
            bofangBtn = new CustomButton();
            bofangBtn.TextID = StringId.bofang;
            bofangBtn.Y = shouyeFL.Bottom + Application.GetRealHeight(bottomValue);
            bofangBtn.X = yinliangFL.Right + Application.GetRealWidth(37);
            backgroundOpenFl.AddChidren(bofangBtn);
 
      
            zantingBtn = new CustomButton();
            zantingBtn.TextID = StringId.zanting;
            zantingBtn.Y = shouyeFL.Bottom + Application.GetRealHeight(bottomValue);
            zantingBtn.X = bofangBtn.Right + Application.GetRealWidth(37);
            backgroundOpenFl.AddChidren(zantingBtn);
 
            int bottomValue1 = 8;
            kuaijinBtn = new CustomButton();
            kuaijinBtn.TextID = StringId.kuaijin;
            kuaijinBtn.Y = bofangBtn.Bottom + Application.GetRealHeight(bottomValue1);
            kuaijinBtn.X = yinliangFL.Right + Application.GetRealWidth(37);
            backgroundOpenFl.AddChidren(kuaijinBtn);
 
 
            kauituiBtn = new CustomButton();
            kauituiBtn.TextID = StringId.kuaitui;
            kauituiBtn.Y = bofangBtn.Bottom + Application.GetRealHeight(bottomValue1);
            kauituiBtn.X = kuaijinBtn.Right + Application.GetRealWidth(37);
            backgroundOpenFl.AddChidren(kauituiBtn);
 
 
 
 
            jingyinBtn = new CustomButton();
            jingyinBtn.TextID = StringId.jingyin;
            jingyinBtn.Y = kuaijinBtn.Bottom + Application.GetRealHeight(bottomValue1);
            jingyinBtn.X = yinliangFL.Right + Application.GetRealWidth(37);
            backgroundOpenFl.AddChidren(jingyinBtn);
 
 
            shezhiBtn = new CustomButton();
            shezhiBtn.TextID = StringId.shezhi;
            shezhiBtn.Y = kuaijinBtn.Bottom + Application.GetRealHeight(bottomValue1);
            shezhiBtn.X = jingyinBtn.Right + Application.GetRealWidth(37);
            backgroundOpenFl.AddChidren(shezhiBtn);
 
 
 
            jiechujingyinBtn = new CustomButton();
            jiechujingyinBtn.TextID = StringId.jiechujingyin;
            jiechujingyinBtn.Y = jingyinBtn.Bottom + Application.GetRealHeight(bottomValue1);
            jiechujingyinBtn.X = yinliangFL.Right + Application.GetRealWidth(37);
            backgroundOpenFl.AddChidren(jiechujingyinBtn);
 
 
            fanhuiBtn = new CustomButton();
            fanhuiBtn.TextID = StringId.fanhui;
            fanhuiBtn.Y = jingyinBtn.Bottom + Application.GetRealHeight(bottomValue1);
            fanhuiBtn.X = jiechujingyinBtn.Right + Application.GetRealWidth(37);
            backgroundOpenFl.AddChidren(fanhuiBtn);
 
 
            TypeFrameLayout typeFrameLayout = new TypeFrameLayout();
            typeFrameLayout.middLayout.Y = yinliangFL.Bottom + Application.GetRealHeight(16);
            typeFrameLayout.AddView(backgroundOpenFl);
 
            muenFrameLayout = new MenuFramLayout();
            muenFrameLayout.Y = Application.GetRealHeight(482-60);
            muenFrameLayout.AddView(backgroundOpenFl);
 
            sourceFrameLayout = new SourceFrameLayout();
            sourceFrameLayout.Y = Application.GetRealHeight(482-60);
            backgroundOpenFl.AddChidren(sourceFrameLayout);
            sourceFrameLayout.LoadSourcePage();
 
 
 
            muenFrameLayout.Visible = true;
            sourceFrameLayout.Visible = false;
            typeFrameLayout.SetLfteClickListener(() =>
            {
 
                muenFrameLayout.Visible = true;
                sourceFrameLayout.Visible = false;
            });
            typeFrameLayout.SetRightClickListener(() =>
            {
                muenFrameLayout.Visible = false;
                sourceFrameLayout.Visible = true;
 
            });
 
 
 
 
 
            #endregion
 
        }
 
        /// <summary>
        /// 初始化头部
        /// </summary>
        private void InitTopUI()
        {
            this.BackgroundColor = MusicColor.ViewColor;
            this.topView = new TopView();
            this.topView.setBtn.Visible = true;
            this.topView.topNameBtn.TextID = StringId.dianshi;
            this.AddChidren(topView.TopFLayoutView());
        }
 
 
        /// <summary>
        /// 重新计算宽度(设备名称,房间控件)
        /// </summary>
        private void CalculatedPosition()
        {
            //开机状态
            this.btnOpenCurrDeviceName.Width = this.btnOpenCurrDeviceName.GetTextWidth();
            this.btnOpenCurrDeviceName.Width += 10;
            if (this.btnOpenCurrDeviceName.GetTextWidth() > this.btnOpenCollectIcon.X)
            {
                //重新计算宽度
                this.btnOpenCurrDeviceName.Width = this.btnOpenCollectIcon.X + Application.GetRealWidth(-10);
            }
            this.btnOpenCurrDeviceRoom.Width = this.btnOpenCurrDeviceRoom.GetTextWidth();
            this.btnOpenCurrDeviceRoom.Width += 10;
            if (this.btnOpenCurrDeviceRoom.GetTextWidth() > this.btnOpenCollectIcon.X)
            {
                //重新计算宽度
                this.btnOpenCurrDeviceRoom.Width = this.btnOpenCollectIcon.X + Application.GetRealWidth(-20 - 10);
            }
            //this.cellFrame.X = this.btnCurrDeviceRoom.Right + Application.GetRealWidth(20);
        }
 
        #endregion
 
    }
    #region   -------自定义当前界面的容器---------
    /// <summary>
    /// 自定义(首页,关机,菜单)容器
    /// </summary>
    class CustomFrameLayout : BaseFramLayout
    {
        public const int widthFrameLayout = 68;
        public const int heightFrameLayout = 68 + 8 + 20;
        public const int interval = 37;//行中的列间隔值
 
        public CustomFrameLayout(int width = widthFrameLayout, int height = heightFrameLayout)
        {
            this.Width = Application.GetRealWidth(width);
            this.Height = Application.GetRealHeight(height);
        }
        Button btnImage = new Button
        {
            Width = Application.GetRealWidth(68),
            Height = Application.GetRealWidth(68),
            Gravity = Gravity.TopCenter,
            Name = "btnImage",
 
        };
        Button btnText = new Button
        {
            Width = Application.GetRealWidth(68),
            Height = Application.GetRealWidth(20),
            TextID = StringId.dangqianmenweiguan,
            TextSize = TextSize.Text14,
            TextColor = MusicColor.TextColor,
            SelectedTextColor = MusicColor.MusicTxet14SelectedColor,
            TextAlignment = TextAlignment.Center,
            Gravity = Gravity.CenterHorizontal,
            Name = "btnText",
            IsMoreLines = true,
        };
        public void AddImageView()
        {
            this.AddChidren(btnImage);
        }
        public void AddTextButtonView()
        {
            btnText.Y = Application.GetRealHeight(8) + btnImage.Bottom;
            this.AddChidren(btnText);
        }
        public Button GetImageButton()
        {
            return this.btnImage;
        }
        public Button GetTextButton()
        {
            return this.btnText;
        }
 
        /// <summary>
        /// 事件监听方法
        /// </summary>
        /// <param name="action">回调(第一个是父类对象;第二个是图标对象;第三个是状态对象</param>
        /// <param name="button1">注意:在SetClickListener()前面调用AddImageView()才有效</param>
        /// <param name="button2">注意:在SetClickListener()前面调用AddImageView()才有效</param>
        public void SetClickListener(Action<FrameLayout, Button, Button> action)
        {
 
            EventHandler<MouseEventArgs> UpClick = (sender, e) =>
             {
                 action?.Invoke(this, btnImage, btnText);
                 SetButtonIsSelected(btnImage);
             };
            this.MouseUpEventHandler += UpClick;
            btnImage.MouseUpEventHandler += UpClick;
            btnText.MouseUpEventHandler += UpClick;
 
        }
 
    }
    /// <summary>
    /// 按键容器
    /// </summary>
    class CustomButton : Button
    {
 
        public CustomButton()
        {
 
            this.Width = Application.GetRealWidth(68);
            this.Height = Application.GetRealHeight(38);
            this.TextSize = 14;
            this.TextColor = MusicColor.TextColor;
            this.SelectedTextColor = MusicColor.MusicTxet14SelectedColor;
            this.TextAlignment = TextAlignment.Center;
            this.IsMoreLines = true;
            this.BackgroundColor = 0xFFF2F3F7;
            this.SelectedBackgroundColor = 0xffECEDEE;
            this.Radius = (uint)Application.GetRealHeight(19);
            this.Padding = new Padding(0, 0, 0, 0);
        }
 
 
        /// <summary>
        /// 事件监听方法
        /// </summary>
        /// <param name="action">回调(第一个是父类对象</param>
        public void SetClickListener(Action<Button> action)
        {
            EventHandler<MouseEventArgs> UpClick = (sender, e) =>
            {
                
                action?.Invoke(this);
                new BaseFramLayout().SetButtonIsSelected(this);
 
            };
            this.MouseUpEventHandler += UpClick;
 
        }
 
    }
    /// <summary>
    /// 类型(控制 信号源)容器
    /// </summary>
    class TypeFrameLayout
    {
        #region  ----控制 信号源----
        public FrameLayout middLayout = new FrameLayout
        {
            Height = Application.GetRealHeight(29),
            Y = Application.GetRealHeight(32),
        };
 
 
        FrameLayout leftLayout = new FrameLayout
        {
            X = Application.GetRealWidth(42),
            Height = Application.GetRealHeight(29),
            Width = Application.GetRealWidth(32),
 
        };
 
 
        Button leftBtnTitle = new Button
        {  
            Height = Application.GetRealHeight(23),
            TextAlignment = TextAlignment.CenterLeft,
            TextColor = MusicColor.TextColor,
            SelectedTextColor = MusicColor.MusicTxet14SelectedColor,
            TextSize = TextSize.Text16,
            TextID = StringId.kongzhi,
            Padding = new Padding(0, 0, 0, 0),
            IsBold = true,
        };
 
 
 
        Button leftBtnLine = new Button
        {
 
            Height = Application.GetRealHeight(2),
            BackgroundColor = MusicColor.TextColor,
            SelectedBackgroundColor = MusicColor.MusicTxet14SelectedColor,
            Gravity = Gravity.CenterHorizontal,
        };
 
        //频道点击控件
        FrameLayout clickLeftLayout = new FrameLayout
        {
 
        };
 
 
        FrameLayout rightLayout = new FrameLayout
        {
            Width = Application.GetRealWidth(48),
        };
        Button rightBtnTitle = new Button
        {
            Height = Application.GetRealHeight(23),
            Width = Application.GetRealWidth(48),
            TextAlignment = TextAlignment.CenterLeft,
            TextColor = MusicColor.TextColor,
            SelectedTextColor = MusicColor.MusicTxet14SelectedColor,
            TextSize = TextSize.Text16,
            TextID = StringId.xinhaoyuan,
            Padding = new Padding(0, 0, 0, 0),
            IsBold = true,
        };
 
        Button rightBtnLine = new Button
        {
            Height = Application.GetRealHeight(2),
            BackgroundColor = MusicColor.TextColor,
            SelectedBackgroundColor = MusicColor.MusicTxet14SelectedColor,
            Gravity = Gravity.CenterHorizontal,
        };
 
 
        //信号源点击控件
        FrameLayout clickRightLayout = new FrameLayout
        {
 
        };
 
        #endregion
 
 
 
 
 
 
        /// <summary>
        /// 
        /// </summary>
        /// <param name="layout"></param>
        public void AddView(FrameLayout layout)
        {
            layout.AddChidren(middLayout);
            middLayout.AddChidren(leftLayout);
 
            leftLayout.AddChidren(leftBtnTitle);
            leftLayout.AddChidren(leftBtnLine);
            leftLayout.AddChidren(clickLeftLayout);
            middLayout.AddChidren(rightLayout);
            rightLayout.AddChidren(rightBtnTitle);
            rightLayout.AddChidren(rightBtnLine);
            rightLayout.AddChidren(clickRightLayout);
 
            leftBtnTitle.Width = leftLayout.Width;
            leftBtnLine.Y = leftBtnTitle.Bottom + Application.GetRealHeight(0);
            if (leftBtnTitle.GetTextWidth() < leftBtnTitle.Width)
            {
                leftBtnTitle.Width = leftBtnTitle.GetTextWidth();
            }
            leftBtnLine.Width = leftBtnTitle.Width;
 
            clickLeftLayout.Height = leftLayout.Height;
            clickLeftLayout.Width = leftLayout.Width;
 
 
            rightLayout.X = leftLayout.Right + Application.GetRealWidth(171);
            rightLayout.Y = leftLayout.Y;
            rightLayout.Height = leftLayout.Height;
 
 
 
            rightBtnLine.Y = rightBtnTitle.Bottom + Application.GetRealHeight(0);
 
            if (rightBtnTitle.GetTextWidth() < rightBtnTitle.Width)
            {
                rightBtnTitle.Width = rightBtnTitle.GetTextWidth();
            }
            rightBtnLine.Width = rightBtnTitle.Width;
 
            clickRightLayout.Height = leftLayout.Height;
            clickRightLayout.Width = leftLayout.Width;
 
 
 
            //初始值
            leftBtnTitle.IsSelected = true;
            leftBtnLine.IsSelected = true;
            leftBtnLine.Visible = true;
            rightBtnTitle.IsSelected = false;
            rightBtnLine.IsSelected = false;
            rightBtnLine.Visible = false;
 
        }
        /// <summary>
        /// 控制监听方法
        /// </summary>
        public void SetLfteClickListener(Action action)
        {
            //点击事件
            clickLeftLayout.MouseDownEventHandler += (sen, e) =>
            {
                leftBtnTitle.IsSelected = true;
                leftBtnLine.IsSelected = true;
                leftBtnLine.Visible = true;
                rightBtnTitle.IsSelected = false;
                rightBtnLine.IsSelected = false;
                rightBtnLine.Visible = false;
                action?.Invoke();
            };
        }
        /// <summary>
        /// 信号源监听方法
        /// </summary>
        public void SetRightClickListener(Action action)
        {
 
            //点击事件
            clickRightLayout.MouseDownEventHandler += (sen, e) =>
            {
                leftBtnTitle.IsSelected = false;
                leftBtnLine.IsSelected = false;
                leftBtnLine.Visible = false;
                rightBtnTitle.IsSelected = true;
                rightBtnLine.IsSelected = true;
                rightBtnLine.Visible = true;
                action?.Invoke();
 
 
            };
 
        }
 
    }
    /// <summary>
    /// 信号源容器
    /// </summary>
    class SourceFrameLayout : FrameLayout
    {
        public const int widthFrameLayout = 375;
        public const int heightFrameLayout = 146;
        public const int interval = 37;//行中的列间隔值
 
        public Action<string> selectAction;
 
        public SourceFrameLayout(int width = widthFrameLayout, int height = heightFrameLayout)
        {
            this.Width = Application.GetRealWidth(width);
            this.Height = Application.GetRealHeight(height);
        }
 
        /// <summary>
        /// 动态加载图片界面
        /// </summary>
        public void LoadSourcePage()
        {
            var mList = GetList();
            int currnetheightValue = 0;
            int currnetWidthValue = 0;
            int heightMaxValue = 38;
            int widthMaxValue = 68;
            //获取相对一个纬度值
            int widthDimensionValue = this.Width - Application.GetRealWidth(24) - Application.GetRealWidth(24) - Application.GetRealHeight(widthMaxValue / 2);
            for (int i = 0; i < mList.Count; i++)
            {
                var source = mList[i];
                CustomButton button = new CustomButton();
                this.AddChidren(button);
                button.Tag = source;
                button.Y = Application.GetRealHeight(currnetheightValue);
                button.X = Application.GetRealWidth(24) + Application.GetRealWidth(currnetWidthValue);
                button.Text = source;
                currnetWidthValue += (widthMaxValue + 37);//37是隔间值
                if (widthDimensionValue < Application.GetRealWidth(currnetWidthValue))
                {
                    currnetheightValue += (heightMaxValue + 16);//16是隔间值
                    currnetWidthValue = 0;
                }
 
                button.SetClickListener((btn) =>
                {
                    // MovieLibrary movieLibrary = new MovieLibrary();
 
                    selectAction?.Invoke(button.Text);
                });
                //if (CurrnetSelectIndex != -1 && CurrnetSelectIndex == i)
                //{
                //    selectImageAction?.Invoke((int)imageFram.Tag);
                //}
            }
 
        }
        private List<string> GetList()
        {
            return new List<string>
            {
                "HDML 1",//" "
                "HDML 2",
                "HDML 3",
                "HDML 4",
                "Live TV",
                "PS",
                "AV",
            };
        }
 
 
    }
 
    #endregion
 
}