wei
2021-03-19 c7c61c603b16c0bf2582d81561bdfbe48ab9440c
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
using System;
using Shared;
using HDL_ON.UI.CSS;
using HDL_ON.Entity;
using System.Collections.Generic;
using HDL_ON.DriverLayer;
 
namespace HDL_ON.UI
{
    public partial class TVPage : FrameLayout
    {
        #region 控件集合
        TVPage bodyView;
        /// <summary>
        /// 功能名称按钮
        /// </summary>
        Button btnFunctionName;
        /// <summary>
        /// 房间楼层信息按钮
        /// </summary>
        Button btnFromFoorAndRoom;
        /// <summary>
        /// 收藏按钮
        /// </summary>
        Button btnCollection;
 
        Button btnChangeTVAV;
        FrameLayout topMenuView;
        Button btnTopMenuUp;
        Button btnTopMenuLeft;
        Button btnTopMenuRight;
        Button btnTopMenuDown;
        Button btnOk;
        FrameLayout channleView;
        Button btnChlReduce;
        Button btnChlPlus;
        FrameLayout volView;
        Button btnVolReduce;
        Button btnVolPlus;
        Button btnBack;
        Button btnMenu;
        Button btn123;
        Button btnMute;
        Button btnPower;
 
        #endregion
 
        #region 区域变量
        TV tvTemp = new TV();
        Function function;
        Button btnCollection_Out;
        Button btnFunctionName_Out;
        Button btnFromFloor_Out;
        /// <summary>
        /// 刷新显示信息
        /// </summary>
        Action actionRefresh;
        #endregion
 
        public TVPage(Function func)
        {
            bodyView = this;
            function = func;
        }
 
 
        public void LoadPage(Button btnCollectionIcon, Button btnFunctionNameOut, Button btnFromFloorOut)
        {
            bodyView.BackgroundColor = CSS_Color.BackgroundColor;
            btnCollection_Out = btnCollectionIcon;
            btnFunctionName_Out = btnFunctionNameOut;
            btnFromFloor_Out = btnFromFloorOut;
 
            FrameLayout controlView = new FrameLayout()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealHeight(88),
                Width = Application.GetRealWidth(327),
                Height = Application.GetRealHeight(526),
                BackgroundImagePath = "Public/Fragmentbg.png",
            };
            bodyView.AddChidren(controlView);
 
            btnFunctionName = new Button()
            {
                X = Application.GetRealWidth(16),
                Y = Application.GetRealHeight(14),
                Width = Application.GetRealWidth(270),
                Height = Application.GetRealHeight(37),
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = CSS_FontSize.EmphasisFontSize_FirstLevel,
                Text = function.name,
            };
            controlView.AddChidren(btnFunctionName);
 
            btnFromFoorAndRoom = new Button()
            {
                X = Application.GetRealWidth(16),
                Y = btnFunctionName.Bottom,
                Width = Application.GetRealWidth(270),
                Height = Application.GetRealHeight(21),
                TextColor = CSS_Color.PromptingColor1,
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                Text = function.GetRoomListName()
            };
            controlView.AddChidren(btnFromFoorAndRoom);
 
            btnCollection = new Button()
            {
                X = Application.GetRealWidth(273),
                Y = Application.GetRealHeight(14),
                Width = Application.GetMinRealAverage(40),
                Height = Application.GetMinRealAverage(40),
                SelectedImagePath = "Collection/CollectionIcon.png",
                UnSelectedImagePath = "Collection/CollectionGrayIcon.png",
                IsSelected = function.collect
            };
            //controlView.AddChidren(btnCollection);
            //2020-12-16 如果是成员隐藏收藏功能
            if (!DB_ResidenceData.Instance.CurrentRegion.IsOthreShare)
            {
                controlView.AddChidren(btnCollection);
            }
 
            btnChangeTVAV = new Button()
            {
                Y = Application.GetRealHeight(8),
                Gravity = Gravity.CenterHorizontal,
                Width = Application.GetRealWidth(90),
                Height = Application.GetRealHeight(49),
                Text = "TV/AV",
                TextAlignment = TextAlignment.Center,
                TextColor = CSS_Color.MainColor,
                TextSize = CSS_FontSize.EmphasisFontSize_FirstLevel,
            };
            controlView.AddChidren(btnChangeTVAV);
 
            #region 轮盘控制区域
            topMenuView = new FrameLayout()
            {
                Y = Application.GetRealHeight(88),
                Gravity = Gravity.CenterHorizontal,
                Width = Application.GetRealWidth(199),
                Height = Application.GetRealWidth(199),
                BackgroundImagePath = "FunctionIcon/Electrical/TV/TVOkIcon.png",
            };
            controlView.AddChidren(topMenuView);
 
            btnTopMenuUp = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Width = Application.GetRealWidth(80),
                Height = Application.GetRealWidth(50),
            };
            topMenuView.AddChidren(btnTopMenuUp);
 
            btnTopMenuLeft = new Button()
            {
                Gravity = Gravity.CenterVertical,
                Width = Application.GetRealWidth(50),
                Height = Application.GetRealWidth(80),
            };
            topMenuView.AddChidren(btnTopMenuLeft);
 
            btnTopMenuRight = new Button()
            {
                X = Application.GetRealWidth(150),
                Gravity = Gravity.CenterVertical,
                Width = Application.GetRealWidth(50),
                Height = Application.GetRealWidth(80),
            };
            topMenuView.AddChidren(btnTopMenuRight);
 
            btnTopMenuDown = new Button()
            {
                Y = Application.GetRealWidth(150),
                Gravity = Gravity.CenterHorizontal,
                Width = Application.GetRealWidth(80),
                Height = Application.GetRealWidth(50),
            };
            topMenuView.AddChidren(btnTopMenuDown);
 
            btnOk = new Button()
            {
                Gravity = Gravity.Center,
                Width = Application.GetRealWidth(100),
                Height = Application.GetRealWidth(100),
            };
            topMenuView.AddChidren(btnOk);
 
 
 
            #endregion
 
 
            #region 频道音量调节
            channleView = new FrameLayout()
            {
                X = Application.GetRealWidth(26),
                Y = Application.GetRealHeight(246),
                Width = Application.GetRealWidth(44),
                Height = Application.GetRealWidth(102),
                BackgroundImagePath = "FunctionIcon/Electrical/TV/MenuBgIcon.png",
            };
            controlView.AddChidren(channleView);
 
            btnChlPlus = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealHeight(10),
                Width = Application.GetRealWidth(24),
                Height = Application.GetRealWidth(24),
                UnSelectedImagePath = "FunctionIcon/Electrical/TV/PlusIcon.png"
            };
            channleView.AddChidren(btnChlPlus);
 
            Button btnChlText;
            btnChlText = new Button()
            {
                Gravity = Gravity.CenterVertical,
                Height = Application.GetRealWidth(23),
                TextAlignment = TextAlignment.Center,
                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextID = StringId.Chl,
            };
            channleView.AddChidren(btnChlText);
 
            btnChlReduce = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealWidth(66),
                Width = Application.GetRealWidth(24),
                Height = Application.GetRealWidth(24),
                UnSelectedImagePath = "FunctionIcon/Electrical/TV/ReduceIcon.png"
            };
            channleView.AddChidren(btnChlReduce);
 
            volView = new FrameLayout()
            {
                X = Application.GetRealWidth(257),
                Y = Application.GetRealHeight(246),
                Width = Application.GetRealWidth(44),
                Height = Application.GetRealWidth(102),
                BackgroundImagePath = "FunctionIcon/Electrical/TV/MenuBgIcon.png",
            };
            controlView.AddChidren(volView);
 
            btnVolPlus = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealHeight(10),
                Width = Application.GetRealWidth(24),
                Height = Application.GetRealWidth(24),
                UnSelectedImagePath = "FunctionIcon/Electrical/TV/PlusIcon.png"
            };
            volView.AddChidren(btnVolPlus);
 
            Button btnVolText;
            btnVolText = new Button()
            {
                Gravity = Gravity.CenterVertical,
                Height = Application.GetRealWidth(23),
                TextAlignment = TextAlignment.Center,
                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextID = StringId.Vol,
            };
            volView.AddChidren(btnVolText);
 
            btnVolReduce = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealWidth(66),
                Width = Application.GetRealWidth(24),
                Height = Application.GetRealWidth(24),
                UnSelectedImagePath = "FunctionIcon/Electrical/TV/ReduceIcon.png"
            };
            volView.AddChidren(btnVolReduce);
 
 
 
            #endregion
 
            #region 底部控制区域
            btnBack = new Button()
            {
                X = Application.GetRealWidth(30),
                Y = Application.GetRealHeight(386),
                Width = Application.GetRealWidth(40),
                Height = Application.GetRealWidth(40),
                UnSelectedImagePath = "FunctionIcon/Electrical/TV/TVBackIcon.png",
            };
            controlView.AddChidren(btnBack);
 
            btnMenu = new Button()
            {
                X = Application.GetRealWidth(106),
                Y = Application.GetRealHeight(386),
                Width = Application.GetRealWidth(40),
                Height = Application.GetRealWidth(40),
                UnSelectedImagePath = "FunctionIcon/Electrical/TV/TVMenuIcon.png",
            };
            controlView.AddChidren(btnMenu);
 
            btn123 = new Button()
            {
                X = Application.GetRealWidth(182),
                Y = Application.GetRealHeight(386),
                Width = Application.GetRealWidth(40),
                Height = Application.GetRealWidth(40),
                UnSelectedImagePath = "FunctionIcon/Electrical/TV/TV123Icon.png",
            };
            controlView.AddChidren(btn123);
 
            btnMute = new Button()
            {
                X = Application.GetRealWidth(258),
                Y = Application.GetRealHeight(386),
                Width = Application.GetRealWidth(40),
                Height = Application.GetRealWidth(40),
                UnSelectedImagePath = "FunctionIcon/Electrical/TV/TVMuteIcon.png",
            };
            controlView.AddChidren(btnMute);
 
            btnPower = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealHeight(462),
                Width = Application.GetRealWidth(40),
                Height = Application.GetRealWidth(40),
                UnSelectedImagePath = "FunctionIcon/Electrical/TV/TVPowerIcon.png",
            };
            controlView.AddChidren(btnPower);
 
            #endregion
 
            LoadEventList();
 
            new TopViewDiv(bodyView, Language.StringByID(StringId.TV)).LoadTopView_FunctionTop(function, actionRefresh);
            DriverLayer.Control.Ins.SendReadCommand(function);
 
        }
 
 
        void ShowNumberView()
        {
            Dialog dialog = new Dialog();
 
            FrameLayout dialogView = new FrameLayout()
            {
                AnimateSpeed = 0.3f,
                Animate = Animate.DownToUp,
            };
            dialog.AddChidren(dialogView);
 
            dialogView.MouseUpEventHandler = (sender, e) =>
            {
                dialog.Close();
            };
 
            FrameLayout numberView = new FrameLayout()
            {
                Y = Application.GetRealHeight(403),
                Height = Application.GetRealHeight(264),
                BackgroundColor = CSS_Color.MainBackgroundColor,
            };
            dialogView.AddChidren(numberView);
 
            for (int i = 0; i < 10; i++)
            {
                Button btn = new Button()
                {
                    Width = Application.GetRealWidth(98),
                    Height = Application.GetRealHeight(44),
                    Radius = (uint)Application.GetRealWidth(8),
                    BorderWidth = (uint)Application.GetRealWidth(1),
                    BorderColor = CSS_Color.PromptingColor1,
                    BackgroundColor  = CSS_Color.MainBackgroundColor,
                    SelectedBackgroundColor = CSS_Color.MainColor,
                    TextColor = CSS_Color.FirstLevelTitleColor,
                    SelectedTextColor = CSS_Color.MainBackgroundColor,
                    IsBold = true,
                    Text = i.ToString(),
                    TextAlignment = TextAlignment.Center,
                };
                if (i == 1 || i == 4 || i == 7)
                {
                    btn.X = Application.GetRealWidth(24);
 
                }
                else if (i == 2 || i == 5 || i == 8)
                {
                    btn.X = Application.GetRealWidth(138);
                }
                else if (i == 3 || i == 6 || i == 9)
                {
                    btn.X = Application.GetRealWidth(252);
                }
                else
                {
                    btn.X = Application.GetRealWidth(138);
                }
                if (i == 0)
                {
                    btn.Y = Application.GetRealHeight(204);
                }
                else if (i < 4)
                {
                    btn.Y = Application.GetRealHeight(24);
 
                }
                else if (i<7)
                {
                    btn.Y = Application.GetRealHeight(84);
                }
                else
                {
                    btn.Y = Application.GetRealHeight(144);
                }
                numberView.AddChidren(btn);
                btn.MouseUpEventHandler = (sender, e) => {
                    string index = (sender as  Button ).Text;
                    btn.IsSelected = false;
                    if (DB_ResidenceData.Instance.GatewayType == 1)
                    {
                        Dictionary<string, string> d = new Dictionary<string, string>();
                        d.Add($"number_{index}", "");
                        Control.Ins.SendWriteCommand(function, d);
                    }
                    else
                    {
                        tvTemp.ControlTV(i, function);
                    }
                };
                btn.MouseDownEventHandler = (sender, e) => {
                    btn.IsSelected = true;
                };
            }
 
 
 
            dialog.Show();
        }
 
    }
}