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
using Shared.SimpleControl.Phone;
using System;
using System.Collections.Generic;
using System.Text;
namespace Shared.SimpleControl.Pad
{
    public class UserTVCustomChannel : FrameLayout
    {
        FrameLayout LongPressFrameLayout = new FrameLayout ();
 
        public void Show (InfraredMode infraredTV)
        {
            #region bodyView
            FrameLayout BodyView = new FrameLayout () { 
                
            };
            this.AddChidren (BodyView);
 
            VerticalScrolViewLayout tvBodyView = new VerticalScrolViewLayout ();
            BodyView.AddChidren (tvBodyView);
 
            FrameLayout tvRowView = null;
            if (infraredTV.InfraredCustomChannel == null) {
                infraredTV.InfraredCustomChannel = new List<InfraredCustomChannel> ();
            }
            for (int index = 0; index <= infraredTV.InfraredCustomChannel.Count; index++) {
                if (index % 3 == 0) {
                    tvRowView = new FrameLayout () {
                        Height = Application.GetRealHeight (250),
                    };
                    tvBodyView.AddChidren (tvRowView);
                }
 
                var tvView = new FrameLayout () {
                    X = Application.GetRealWidth(40),
                    Y = Application.GetRealHeight(30),
                    Width = Application.GetRealWidth (300),
                    Height = Application.GetRealHeight(220),
                    Alpha = 0.8f,
                };
                tvRowView.AddChidren (tvView);
 
                if (index % 3 == 1) {
                    tvView.X = Application.GetRealWidth (350);
                } else if (index % 3 == 2) { 
                    tvView.X = Application.GetRealWidth (660);
                }
 
                if (index == infraredTV.InfraredCustomChannel.Count) {
                    tvView.BackgroundImagePath = "Item/SceneAdd.png";
                    tvView.MouseUpEventHandler += (sender, e) => {
                        var tv3 = new UserTVAddCustomChannel () {
                            BackgroundColor = 0xFF2f2f2f,
                            Width = Application.GetRealWidth (840),
                            Height = Application.GetRealHeight (1100),
                        };
                        tv3.Show ();
                        tv3.Show (infraredTV, MyRefresh);
                    };
                } 
                else {
                    InfraredCustomChannel icc = infraredTV.InfraredCustomChannel [index];
                    var btnBGC = new Button () {
                        UnSelectedImagePath = icc.ChannelIconPath,
                        TextAlignment = TextAlignment.BottomCenter,
                        Text = icc.ChannelName,
                        TextColor = SkinStyle.Current.TextColor1,
                        TextSize = 15,
                        Tag = index,
                    };
                    tvView.AddChidren (btnBGC);
                    btnBGC.MouseUpEventHandler += (sender, e) => {
                        infraredTV.InfraredCustomChannel [int.Parse (btnBGC.Tag.ToString ())].Send ();
                    };
 
                    btnBGC.MouseLongEventHandler += (sender, e) => {
                        Alert alert = new Alert (Language.StringByID (R.MyInternationalizationString.Tip),
                                                 Language.StringByID (R.MyInternationalizationString.SureDelete),
                                                 Language.StringByID (R.MyInternationalizationString.Cancel),
                                                 Language.StringByID (R.MyInternationalizationString.Confrim));
                        alert.Show ();
                        alert.ResultEventHandler += (sender2, e2) => {
                            if (e2) {
                                infraredTV.InfraredCustomChannel.Remove (icc);
                                IO.FileUtils.SaveEquipmentMessage (infraredTV, infraredTV.LoopID.ToString ());
                                MyRefresh (infraredTV);
                            }
                        };
                    };
                }
            }
            #endregion 
            //MyRefresh (infraredTV);
        }
 
        public void MyRefresh (InfraredMode infraredTV )
        {
            this.RemoveAll ();
            Show (infraredTV);
        }
    }
}