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
using System;
using System.Collections.Generic;
using Shared.SimpleControl.Phone;
using System.Text;
namespace Shared.SimpleControl.Phone
{
    public class UserTVCustomChannel : FrameLayout
    {
        FrameLayout LongPressFrameLayout = new FrameLayout ();
 
        public void Show (InfraredMode infrared)
        {
            #region bodyView
            FrameLayout BodyView = new FrameLayout () {
                BackgroundColor = SkinStyle.Current.MainColor
            };
            this.AddChidren (BodyView);
 
            VerticalScrolViewLayout tvBodyView = new VerticalScrolViewLayout ();
            BodyView.AddChidren (tvBodyView);
 
            FrameLayout tvRowView = null;
            if (infrared.InfraredCustomChannel == null) {
                infrared.InfraredCustomChannel = new List<InfraredCustomChannel> ();
            }
            //infraredTV.InfraredCustomChannel.Add (new InfraredCustomChannel () { ChannelName = Language.StringByID(R.MyInternationalizationString.AddButton)});
            for (int index = 0; index <= infrared.InfraredCustomChannel.Count; index++) {
                if (index % 2 == 0) {
                    tvRowView = new FrameLayout () {
                        Height = Application.GetRealHeight (250),
                        Width = Application.GetRealWidth (640),
                    };
                    tvBodyView.AddChidren (tvRowView);
                }
 
                var tvView = new FrameLayout () {
                    Width = Application.GetRealWidth (320),
                };
                tvRowView.AddChidren (tvView);
 
                if (index % 2 == 1) {
                    tvView.X = Application.GetRealWidth (320);
                }
 
                if (index == infrared.InfraredCustomChannel.Count) {
                    tvView.BackgroundImagePath = "Item/SceneAdd.png";
                    tvView.MouseUpEventHandler += (sender, e) => {
                        var tv3 = new UserTVAddCustomChannel ();
                        tv3.Show ();
                        tv3.Show (infrared, MyRefresh);
                    };
                } else {
                    InfraredCustomChannel icc = infrared.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) => {
                        infrared.InfraredCustomChannel [int.Parse (btnBGC.Tag.ToString ())].Send (infrared.SubnetID, infrared.DeviceID, infrared.InfraredType, infrared.IsUniversalSwitch);
                    };
 
                    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) {
                                infrared.InfraredCustomChannel.Remove (icc);
                                IO.FileUtils.SaveEquipmentMessage (infrared, infrared.LoopID.ToString ());
                                MyRefresh (infrared);
                            }
                        };
                    };
                }
            }
            #endregion
 
 
            FrameLayout bottomNull = new FrameLayout () {
                BackgroundColor = SkinStyle.Current.MainColor,
                Height = Application.GetRealHeight (70),
                Y = Application.GetRealHeight (910),
            };
            AddChidren (bottomNull);
        }
 
        public void MyRefresh (InfraredMode infraredTV)
        {
            this.RemoveAll ();
            Show (infraredTV);
        }
    }
}