JLChen
2020-05-28 04bd96cbf5d12a4e4b116d2b05fd0d05ea81ee23
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
using System;
 
namespace Shared.SimpleControl.Pad
{
    public class UserDeviceToTV : Dialog
    {
 
        VerticalScrolViewLayout RoomListScrolView;
        /// <summary>
        /// 当前界面
        /// </summary>
        public static UserDeviceToTV curView;
        FrameLayout ControlBodyView;
        public UserTVNumberView ControlNumberView;
        public UserTVFrameLayout ControlTVView;
        /// <summary>
        /// 构造函数
        /// </summary>
        public UserDeviceToTV ()
        {
            curView = this;
            showAllRoomTV ();
        }
 
        /// <summary>
        /// 显示房间的所有电视
        /// </summary>
        void showAllRoomTV ()
        {
            FrameLayout topBackView = new FrameLayout () {
                Height = Application.GetRealHeight (150),
                BackgroundColor = 0xFF2f2f2f
            };
            AddChidren (topBackView);
            #region 标题
            var topView = new FrameLayout () {
                Y = Application.GetRealHeight (36),
                Height = Application.GetRealHeight (90),
            };
            AddChidren (topView);
 
            var title = new Button () {
                TextAlignment = TextAlignment.Center,
                Text = Language.StringByID (R.MyInternationalizationString.TV),
                TextSize = 19,
            };
            topView.AddChidren (title);
 
            var logo = new Button () {
                Width = Application.GetRealWidth (154),
                Height = Application.GetRealHeight (90),
                X = Application.GetRealWidth (486),
                UnSelectedImagePath = MainPage.LogoString,
            };
            topView.AddChidren (logo);
            var back = new Button () {
                Height = Application.GetRealHeight (100),
                Width = Application.GetRealWidth (85),
                UnSelectedImagePath = "Item/Back.png",
                SelectedImagePath = "Item/BackSelected.png",
                Gravity = Gravity.CenterVertical,
            };
            topView.AddChidren (back);
            back.MouseUpEventHandler += (sender, e) => {
                Close ();
                curView = null;
            };
 
            var btnl = new Button () {
                Height = 1,
                BackgroundColor = 0xFF2f2f2f,
                Y = topView.Height - 1
            };
            topView.AddChidren (btnl);
            #endregion
 
            FrameLayout bordorView = new FrameLayout () {
                Width = Application.GetRealWidth (480),
                Height = Application.GetRealHeight (Application.DesignHeight - 150),
                Y = Application.GetRealHeight (150),
                BackgroundColor = 0xFF2f2f2f
            };
            AddChidren (bordorView);
 
            #region powerView
            var powerView = new FrameLayout () {
                Height = Application.GetRealHeight (110),
                BackgroundColor = SkinStyle.Current.MainColor,
            };
            bordorView.AddChidren (powerView);
 
            var showAllroom = new Button () {
                Height = Application.GetRealHeight (108),
                TextAlignment = TextAlignment.Center,
                Text = "  " + Language.StringByID (R.MyInternationalizationString.AllRoom),
            };
            powerView.AddChidren (showAllroom);
            var btnLine1 = new Button () {
                Height = 1,
                Y = powerView.Height - 1,
                BackgroundColor = 0xFF2f2f2f,
            };
            powerView.AddChidren (btnLine1);
            var btnLine = new Button () {
                Width = 1,
                X = powerView.Width - 1,
                BackgroundColor = 0xFF2f2f2f,
            };
            powerView.AddChidren (btnLine);
            #endregion
 
            RoomListScrolView = new VerticalScrolViewLayout () {
                Width = LayoutParams.MatchParent,
                Height = Application.GetRealHeight (1136 - 126 - 110),
                Y = powerView.Bottom
            };
            bordorView.AddChidren (RoomListScrolView);
            ControlBodyView = new FrameLayout () {
                Width = Application.GetRealWidth (Application.DesignWidth) - bordorView.Width,
                Height = Application.GetRealHeight (Application.DesignHeight - 150),
                X = bordorView.Right,
                Y = bordorView.Y,
                BackgroundColor = SkinStyle.Current.MainColor
            };
            AddChidren (ControlBodyView);
 
            //显示有多少个房间
            int devcieCount = 0;
            foreach (var room in Room.Lists) {
                if (room.Name == "") {
                    continue;
                }
                var infraredList = room.DeviceList.FindAll ((obj) => { return obj.Type == DeviceType.InfraredMode; });
                var tvList = infraredList.FindAll ((obj) => { return ((InfraredMode)obj).InfraredType == InfraredType.TV; });
                foreach (var tempTV in tvList) {
                    EventHandler<MouseEventArgs> openTVControlPageEvent = (button, mouseEventArgs) => {
                        for (int i = 0; i < RoomListScrolView.ChildrenCount; i++) {
                            var view = RoomListScrolView.GetChildren (i);
                            if (view.Tag == tempTV) {
                                for (int j = 0; j < (view as FrameLayout).ChildrenCount; j++) {
                                    var btn = (view as FrameLayout).GetChildren (j);
                                    (btn as Button).IsSelected = true;
                                }
                            } else {
                                for (int j = 0; j < (view as FrameLayout).ChildrenCount; j++) {
                                    var btn = (view as FrameLayout).GetChildren (j);
                                    (btn as Button).IsSelected = false;
                                }
                            }
                        }
                        ControlBodyView.RemoveAll ();
                        ControlNumberView = new UserTVNumberView () {
                            Width = Application.GetRealWidth (1000),
                        };
                        ControlBodyView.AddChidren (ControlNumberView);
                        ControlNumberView.Show (room, (InfraredMode)tempTV);
 
                        ControlTVView = new UserTVFrameLayout ((InfraredMode)tempTV) {
                            X = Application.GetRealWidth (1000),
                            Width = Application.GetRealWidth (Application.DesignWidth - 480 - 1000)
                        };
                        ControlBodyView.AddChidren (ControlTVView);
                        ControlTVView.ShowUserTV (tempTV as InfraredMode);
                    };
                    FrameLayout roomView = new FrameLayout () {
                        Height = Application.GetRealHeight (140),
                        BackgroundColor = 0xFF2f2f2f,
                        Tag = room.Name + "-" + tempTV.Name,
                    };
                    RoomListScrolView.AddChidren (roomView);
                    roomView.Tag = tempTV;
                    Button btnRoomName = new Button () {
                        Text = room.Name + "-" + tempTV.Name,
                        Padding = new Padding (0, 35, 0, 0),
                        TextAlignment = TextAlignment.CenterLeft,
                        SelectedTextColor = SkinStyle.Current.SelectedColor,
                        TextColor = SkinStyle.Current.TextColor1,
                        BackgroundColor = SkinStyle.Current.Transparent,
                        SelectedBackgroundColor = SkinStyle.Current.MainColor
                    };
                    roomView.AddChidren (btnRoomName);
                    var btnPoint = new Button () {
                        Width = Application.GetRealWidth (15),
                        Height = Application.GetRealHeight (15),
                        X = Application.GetRealWidth (45),
                        Gravity = Gravity.CenterVertical,
                        UnSelectedImagePath = "Item/Point.png",
                        SelectedImagePath = "Item/PointSelected.png",
                    };
                    roomView.AddChidren (btnPoint);
 
                    Button btnNull = new Button () {
                        Height = Application.GetRealHeight (5),
                        Y = Application.GetRealHeight (138),
                        BackgroundColor = SkinStyle.Current.MainColor,
                    };
                    roomView.AddChidren (btnNull);
                    Button btnNull2 = new Button () {
                        Width = 1,
                        X = roomView.Width - 1,
                        BackgroundColor = 0xFF2f2f2f,
                    };
                    roomView.AddChidren (btnNull2);
                    Button btnSelected = new Button () {
                        X = roomView.Width - 5,
                        Width = 5,
                        SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
                        BackgroundColor = SkinStyle.Current.Transparent,
                    };
                    roomView.AddChidren (btnSelected);
                    btnRoomName.MouseUpEventHandler += openTVControlPageEvent;
 
                    if (devcieCount == 0) {
                        ControlNumberView = new UserTVNumberView () {
                            Width = Application.GetRealWidth (1000),
                            BackgroundColor = 0xFF333333
                        };
                        ControlBodyView.AddChidren (ControlNumberView);
                        ControlNumberView.Show (room, (InfraredMode)tempTV);
 
                        ControlTVView = new UserTVFrameLayout ((InfraredMode)tempTV) {
                            X = Application.GetRealWidth (1020),
                            Width = Application.GetRealWidth (Application.DesignWidth - 480 - 1000 - 20),
                            BackgroundColor = 0xFF333333
                        };
                        ControlBodyView.AddChidren (ControlTVView);
                        ControlTVView.ShowUserTV (tempTV as InfraredMode);
 
                        btnRoomName.IsSelected = true;
                        btnPoint.IsSelected = true;
                        btnSelected.IsSelected = true;
                    }
                    devcieCount++;
 
                }
            }
        }
    }
}