陈嘉乐
2021-03-22 551e82d33c9c23442e0ecd320bcfc752f300d9ef
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
using System;
using System.Collections.Generic;
using HDL_ON.DriverLayer;
using HDL_ON.Entity;
using HDL_ON.UI.CSS;
using Shared;
 
namespace HDL_ON.UI
{
    public class EnvironmentalPage : FrameLayout
    {
 
        #region 控件集合
        static EnvironmentalPage bodyView;
        /// <summary>
        /// 楼层显示
        /// </summary>
        Button btnRoom;
        /// <summary>
        /// 房间选择下拉图标
        /// </summary>
        Button btnFoorDownIcon;
        /// <summary>
        /// 房间选择触发区域
        /// </summary>
        Button btnRoomClickRow;
        /// <summary>
        /// 传感器列表区域
        /// </summary>
        FrameLayout sensorListView;
 
        /// <summary>
        /// 天气名称文本
        /// </summary>
        Button btnWatherText;
        /// <summary>
        /// 湿度数据文本
        /// </summary>
        Button btnHumidityText;
        /// <summary>
        /// pm25数据文本
        /// </summary>
        Button btnPm25Values;
        /// <summary>
        /// 风速数据文本
        /// </summary>
        Button btnFanSpeedValues;
 
        #endregion
        #region 区域变量
        Room room;
 
        Sensor sensorTemp = new Sensor();
        #endregion
 
 
        public EnvironmentalPage()
        {
            bodyView = this;
        }
 
        /// <summary>
        /// 加载界面
        /// </summary>
        /// <param name="btnCollectionIcon">收藏按钮</param>
        /// <param name="btnFunctionName">功能名称信息按钮</param>
        /// <param name="btnFromFloor">功能楼层信息按钮</param>
        public void LoadPage()
        {
            bodyView.BackgroundColor = CSS_Color.BackgroundColor;
 
            #region 顶部天气部分
            var topWeatherView = new FrameLayout()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealHeight(73),
                Width = Application.GetRealWidth(361),
                Height = Application.GetRealWidth(166),
                BackgroundImagePath = "FunctionIcon/EnvirSensor/0.png",
            };
            bodyView.AddChidren(topWeatherView);
            LoadEvent_ChangeWeatherIcon(topWeatherView);
 
            var btnLocationText = new Button()
            {
                X = Application.GetRealWidth(27),
                Width = Application.GetRealWidth(74),
                Height = Application.GetRealWidth(44),
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
                TextColor = CSS_Color.FirstLevelTitleColor,
                Text = MainPage.cityInfo.location,
            };
            topWeatherView.AddChidren(btnLocationText);
 
 
            var btnTemp = new Button()
            {
                X = Application.GetRealWidth(21),
                Y = Application.GetRealWidth(53),
                Width = Application.GetRealWidth(78),
                Height = Application.GetRealWidth(68),
                TextSize = 60,
                IsBold = true,
                TextAlignment = TextAlignment.CenterLeft,
                TextColor = CSS_Color.FirstLevelTitleColor,
                Text = MainPage.cityInfo.temperature,
            };
            topWeatherView.AddChidren(btnTemp);
 
            var btnTempUint = new Button()
            {
                X = Application.GetRealWidth(109),
                Y = Application.GetRealWidth(60),
                Width = Application.GetRealWidth(20),
                Height = Application.GetRealWidth(20),
                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                TextColor = CSS_Color.TextualColor,
                Text = "°C",
            };
            topWeatherView.AddChidren(btnTempUint);
 
 
            btnWatherText = new Button()
            {
                X = Application.GetRealWidth(109),
                Y = Application.GetRealWidth(82),
                Width = Application.GetRealWidth(200),
                Height = Application.GetRealWidth(20),
                TextColor = CSS_Color.TextualColor,
                TextSize = CSS_FontSize.TextFontSize,
                TextAlignment = TextAlignment.CenterLeft,
                Text = MainPage.cityInfo.weather
            };
            topWeatherView.AddChidren(btnWatherText);
 
            var btnTempUpperLimit = new Button()
            {
                X = Application.GetRealWidth(107),
                Y = Application.GetRealWidth(101),
                Width = Application.GetRealWidth(16),
                Height = Application.GetRealWidth(16),
                UnSelectedImagePath = "FunctionIcon/EnvirSensor/UpperLimit.png",
            };
            topWeatherView.AddChidren(btnTempUpperLimit);
 
            var btnTempUpperLimitText = new Button()
            {
                X = btnTempUpperLimit.Right,
                Y = Application.GetRealWidth(101),
                Width = Application.GetRealWidth(42),
                Height = Application.GetRealWidth(20),
                TextColor = CSS_Color.TextualColor,
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                Text = "10°C",
            };
            topWeatherView.AddChidren(btnTempUpperLimitText);
 
            var btnTempLowerLimit = new Button()
            {
                X = Application.GetRealWidth(156),
                Y = Application.GetRealWidth(101),
                Width = Application.GetRealWidth(16),
                Height = Application.GetRealWidth(16),
                UnSelectedImagePath = "FunctionIcon/EnvirSensor/LowerLimit.png",
            };
            topWeatherView.AddChidren(btnTempLowerLimit);
 
            var btnTempLowerLimitText = new Button()
            {
                X = btnTempLowerLimit.Right,
                Y = Application.GetRealWidth(101),
                Width = Application.GetRealWidth(42),
                Height = Application.GetRealWidth(20),
                TextColor = CSS_Color.TextualColor,
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                Text = "2°C",
            };
            topWeatherView.AddChidren(btnTempLowerLimitText);
 
 
            var btnValue = new Button()
            {
                X = Application.GetRealWidth(27),
                Y = Application.GetRealWidth(119),
                Width = Application.GetRealWidth(300),
                Height = Application.GetRealWidth(34),
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
                TextColor = CSS_Color.TextualColor,
            };
            topWeatherView.AddChidren(btnValue);
            var valueText = Language.StringByID(StringId.EnvirSensorValueTip);
            btnValue.Text = valueText.Replace("{0}", $"{MainPage.cityInfo.humidity}").Replace("{1}", $"{MainPage.cityInfo.pm25}").Replace("{2}", $"{MainPage.cityInfo.windLevel}");
            #endregion
 
            #region contentView
            FrameLayout contentView = new FrameLayout()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealWidth(239),
                Height = Application.GetRealHeight(450),
            };
            bodyView.AddChidren(contentView);
 
            #region 房间顶部切换显示区域
            room = new Room() { roomName = Language.StringByID(StringId.All) };
            btnFoorDownIcon = new Button()
            {
                Width = Application.GetMinRealAverage(16),
                Height = Application.GetMinRealAverage(16),
                X = Application.GetRealWidth(16),
                Y = Application.GetRealHeight(18),
                UnSelectedImagePath = "Public/DownIcon.png",
            };
            contentView.AddChidren(btnFoorDownIcon);
 
            btnRoom = new Button()
            {
                X = btnFoorDownIcon.Right,
                Y = Application.GetRealHeight(18),
                Width = Application.GetRealWidth(200),
                Height = Application.GetMinRealAverage(16),
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                TextAlignment = TextAlignment.CenterLeft,
                Text = room.roomName,
            };
            contentView.AddChidren(btnRoom);
 
            btnRoomClickRow = new Button()
            {
                Height = Application.GetRealHeight(40),
            };
            contentView.AddChidren(btnRoomClickRow);
 
            #endregion
 
            sensorListView = new FrameLayout()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealHeight(50),
                Height = Application.GetRealHeight(456),
                Radius = (uint)Application.GetRealWidth(12),
                BorderColor = 0x00000000,
                BorderWidth = 0,
            };
            contentView.AddChidren(sensorListView);
 
            LoadSenesorList();
 
 
 
            #endregion
 
            //LoadEventList();
            LoadDialog_ChangeRoom();
 
            new TopViewDiv(bodyView, Language.StringByID(StringId.EnvironmentalScience)).LoadTopView();
 
        }
 
        /// <summary>
        /// 加载传感器列表
        /// </summary>
        void LoadSenesorList()
        {
            sensorListView.RemoveAll();
            int index = 0;
            foreach (var sensor in FunctionList.List.GetEnvirSensorsList())
            {
                LoadSensorDiv(sensor, index);
                index++;
            }
        }
 
        /// <summary>
        /// 加载传感器列表
        /// </summary>
        void LoadSensorDiv(Function sensor, int index)
        {
            var levelColorList = sensorTemp.GetLevelColorList(sensor.spk);
            var levelTextList = sensorTemp.GetLevelTextList(sensor.spk);
 
            if (room.roomId == "" || sensor.roomIds.Contains(room.roomId))
            {
                var sensorTag = sensor.sid;
                FrameLayout sensorView = new FrameLayout()
                {
                    X = Application.GetRealWidth(7),
                    Width = Application.GetRealWidth(182),
                    Height = Application.GetRealWidth(124),
                    Y = Application.GetRealWidth(124 * (index / 2)),
                    Tag = sensorTag
                };
 
                var imagePath = "";
                var iconPath = "";
                switch (sensor.spk)
                {
                    case SPK.SensorCO2:
                        imagePath = "FunctionIcon/EnvirSensor/Co2Bg.png";
                        iconPath = "FunctionIcon/EnvirSensor/Co2Icon.png";
                        break;
                    case SPK.SensorPm25:
                        imagePath = "FunctionIcon/EnvirSensor/Pm25Bg.png";
                        iconPath = "FunctionIcon/EnvirSensor/Pm25Icon.png";
                        break;
                    case SPK.SensorTVOC:
                        imagePath = "FunctionIcon/EnvirSensor/TvocBg.png";
                        iconPath = "FunctionIcon/EnvirSensor/TvocIcon.png";
                        break;
                    case SPK.SensorHumidity:
                        imagePath = "FunctionIcon/EnvirSensor/HumidityBg.png";
                        iconPath = "FunctionIcon/EnvirSensor/HumidityIcon.png";
                        break;
                    case SPK.SensorTemperature:
                        imagePath = "FunctionIcon/EnvirSensor/TempBg.png";
                        iconPath = "FunctionIcon/EnvirSensor/TempIcon.png";
                        break;
                }
                sensorView.BackgroundImagePath = imagePath;
 
                if (index % 2 != 0)
                {
                    sensorView.X = Application.GetRealWidth(189);
                }
                sensorListView.AddChidren(sensorView);
 
                var btnIcon = new Button()
                {
                    X = Application.GetRealWidth(23),
                    Y = Application.GetRealHeight(17),
                    Width = Application.GetRealWidth(32),
                    Height = Application.GetRealWidth(32),
                    UnSelectedImagePath = iconPath
                };
                sensorView.AddChidren(btnIcon);
 
                btnIcon.MouseUpEventHandler = (sender, e) =>
                {
                    #region 
                    var esp = new EnvironmentalSensorPage(sensor);
                    MainPage.BasePageView.AddChidren(esp);
                    esp.LoadPage();
                    MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                    #endregion
                };
 
                var btnInfoIcon = new Button()
                {
                    X = Application.GetRealWidth(139),
                    Y = Application.GetRealHeight(21),
                    Width = Application.GetRealWidth(24),
                    Height = Application.GetRealWidth(24),
                    UnSelectedImagePath = "FunctionIcon/EnvirSensor/InfoIcon.png",
                };
                sensorView.AddChidren(btnInfoIcon);
                btnInfoIcon.MouseUpEventHandler = (sender, e) =>
                {
                    LoadInfo(sensor);
                };
 
                var btnLevel = new Button()
                {
                    X = Application.GetRealWidth(25),
                    Y = Application.GetRealWidth(59),
                    Width = Application.GetRealWidth(100),
                    Height = Application.GetRealWidth(32),
                    TextAlignment = TextAlignment.CenterLeft,
                    TextColor = CSS_Color.FirstLevelTitleColor,//levelColorList[sensorTemp.GetCurLevel(sensor) - 1],
                    TextSize = CSS_FontSize.SubheadingFontSize,
                    TextID = levelTextList[sensorTemp.GetCurLevel(sensor) - 1],
                    Tag = "SensorLevel",
                };
                sensorView.AddChidren(btnLevel);
                btnLevel.MouseUpEventHandler = (sender, e) =>
                {
                    #region 
                    var esp = new EnvironmentalSensorPage(sensor);
                    MainPage.BasePageView.AddChidren(esp);
                    esp.LoadPage();
                    MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                    #endregion
                };
 
 
                var btnSensorValues = new Button()
                {
                    X = Application.GetRealWidth(25),
                    Y = Application.GetRealWidth(83),
                    Width = Application.GetRealWidth(100),
                    Height = Application.GetRealWidth(27),
                    TextAlignment = TextAlignment.CenterLeft,
                    TextColor = CSS_Color.PromptingColor1,
                    TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                    IsBold = true,
                    Text = sensor.GetAttrState(FunctionAttributeKey.Value),
                    Tag = "SensorValues"
                };
                sensorView.AddChidren(btnSensorValues);
                btnSensorValues.MouseUpEventHandler = (sender, e) =>
                {
                    #region 
                    var esp = new EnvironmentalSensorPage(sensor);
                    MainPage.BasePageView.AddChidren(esp);
                    esp.LoadPage();
                    MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                    #endregion
                };
                //btnLevel.MouseUpEventHandler = (sender, e) =>
                //{
                //    LoadInfo(sensor);
                //};
 
 
 
                new System.Threading.Thread(() =>
                {
                    Control.Ins.SendReadCommand(sensor);
                })
                { IsBackground = true }.Start();
            }
        }
 
        /// <summary>
        /// 加载传感器等级相关信息
        /// </summary>
        void LoadInfo(Function sensor)
        {
            var levelColorList = sensorTemp.GetLevelColorList(sensor.spk);
            var levelTextList = sensorTemp.GetLevelTextList(sensor.spk);
            Dialog dialog = new Dialog();
 
            FrameLayout dialogBodyView = new FrameLayout();
            dialog.AddChidren(dialogBodyView);
            dialogBodyView.MouseUpEventHandler = (sender, e) =>
            {
                dialog.Close();
            };
            VerticalScrolViewLayout infoView = new VerticalScrolViewLayout()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealHeight(667 - 94 - (levelColorList.Count * 44) - 20),
                Width = Application.GetRealWidth(343),
                Height = Application.GetRealHeight(94 + (levelColorList.Count * 44) + levelColorList.Count),
                Radius = (uint)Application.GetRealWidth(12),
                BackgroundColor = CSS_Color.MainBackgroundColor,
                Animate = Animate.DownToUp,
                ScrollEnabled = false,
                AnimateSpeed = 0.3f,
            };
            dialogBodyView.AddChidren(infoView);
 
            Button btnTitle = new Button()
            {
                Height = Application.GetRealHeight(50),
                TextColor = CSS_Color.FirstLevelTitleColor,
                IsBold = true,
                TextSize = CSS_FontSize.SubheadingFontSize,
                TextAlignment = TextAlignment.Center,
            };
            infoView.AddChidren(btnTitle);
 
            switch (sensor.spk)
            {
                case SPK.SensorPm25:
                    btnTitle.Text = "PM2.5(ug/m²)";
                    break;
                case SPK.SensorTemperature:
                    btnTitle.Text = Language.StringByID(StringId.Temp) + "(°C)";
                    break;
                case SPK.SensorTVOC:
                    btnTitle.Text = "TVOC(PPM)";
                    break;
                case SPK.SensorCO2:
                    btnTitle.Text = "CO2(PPM)";
                    break;
                case SPK.SensorHumidity:
                    btnTitle.Text = Language.StringByID(StringId.Humidity) + "(%)";
                    break;
            }
 
            FrameLayout subTitleView = new FrameLayout()
            {
                Height = Application.GetRealHeight(44),
            };
            infoView.AddChidren(subTitleView);
 
            subTitleView.AddChidren(new Button()
            {
                X = Application.GetRealWidth(20),
                Width = Application.GetRealWidth(100),
                TextAlignment = TextAlignment.CenterLeft,
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextSize = CSS_FontSize.TextFontSize,
                IsBold = true,
                TextID = StringId.IntervalValue,
            });
 
            subTitleView.AddChidren(new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Width = Application.GetRealWidth(100),
                TextAlignment = TextAlignment.Center,
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextSize = CSS_FontSize.TextFontSize,
                IsBold = true,
                TextID = StringId.LevelSensor,
            });
 
            subTitleView.AddChidren(new Button()
            {
                X = Application.GetRealWidth(223),
                Width = Application.GetRealWidth(100),
                TextAlignment = TextAlignment.CenterRight,
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextSize = CSS_FontSize.TextFontSize,
                IsBold = true,
                TextID = StringId.ColorValue,
            });
            for (int index = 0; index < levelTextList.Count; index++)
            {
                infoView.AddChidren(new Button()
                {
                    Gravity = Gravity.CenterHorizontal,
                    Width = Application.GetRealWidth(303),
                    Height = Application.GetRealWidth(1),
                    BackgroundColor = CSS_Color.DividingLineColor,
                });
 
                FrameLayout subInfoView = new FrameLayout()
                {
                    Height = Application.GetRealHeight(44),
                };
                infoView.AddChidren(subInfoView);
 
                subInfoView.AddChidren(new Button()
                {
                    X = Application.GetRealWidth(20),
                    Width = Application.GetRealWidth(100),
                    TextAlignment = TextAlignment.CenterLeft,
                    TextColor = CSS_Color.FirstLevelTitleColor,
                    TextSize = CSS_FontSize.TextFontSize,
                    IsBold = true,
                    Text = sensorTemp.GetIntervalValue(sensor.spk)[index]
                });
 
                subInfoView.AddChidren(new Button()
                {
                    Gravity = Gravity.CenterHorizontal,
                    Width = Application.GetRealWidth(100),
                    TextAlignment = TextAlignment.Center,
                    TextColor = CSS_Color.FirstLevelTitleColor,
                    TextSize = CSS_FontSize.TextFontSize,
                    IsBold = true,
                    TextID = levelTextList[index]
                });
 
                subInfoView.AddChidren(new Button()
                {
                    X = Application.GetRealWidth(285),
                    Gravity = Gravity.CenterVertical,
                    Width = Application.GetRealWidth(38),
                    Height = Application.GetRealHeight(18),
                    Radius = (uint)Application.GetRealWidth(4),
                    BackgroundColor = levelColorList[index]
                });
            }
 
 
 
 
            dialog.Show();
        }
 
        /// <summary>
        /// 房间列表点击事件
        /// </summary>
        void LoadDialog_ChangeRoom()
        {
            EventHandler<MouseEventArgs> eventHandler = (sender, e) =>
            {
                var dialog = new Dialog();
                var dialogBody = new FrameLayout();
                dialog.AddChidren(dialogBody);
                dialogBody.MouseUpEventHandler += (sender1, e1) =>
                {
                    dialog.Close();
                };
 
                var dispalyView = new FrameLayout()
                {
                    X = Application.GetRealWidth(10),
                    Y = Application.GetRealHeight(266),
                    Width = Application.GetRealWidth(160),
                    Height = Application.GetRealHeight(110),
                    BackgroundImagePath = "PersonalCenter/HomeList1bg.png",
                };
                dialogBody.AddChidren(dispalyView);
 
                var contentView = new VerticalScrolViewLayout()
                {
                    X = Application.GetRealWidth(8),
                    Y = Application.GetRealHeight(15),
                    Width = Application.GetRealWidth(150),
                    Height = Application.GetRealHeight(45 * 2),
                    ScrollEnabled = false
                };
                dispalyView.AddChidren(contentView);
 
                if (SpatialInfo.CurrentSpatial.RoomList.Count < 2)
                {
                }
                else if (SpatialInfo.CurrentSpatial.RoomList.Count < 3)
                {
                    dispalyView = new FrameLayout()
                    {
                        X = Application.GetRealWidth(10),
                        Y = Application.GetRealHeight(266),
                        Width = Application.GetRealWidth(160),
                        Height = Application.GetRealHeight(155),
                        BackgroundImagePath = "PersonalCenter/HomeList2bg.png",
                    };
                    dialogBody.AddChidren(dispalyView);
 
                    contentView.Height = Application.GetRealHeight(45 * 3);
                    dispalyView.AddChidren(contentView);
                }
                else if (SpatialInfo.CurrentSpatial.RoomList.Count < 4)
                {
                    dispalyView = new FrameLayout()
                    {
                        X = Application.GetRealWidth(10),
                        Y = Application.GetRealHeight(266),
                        Width = Application.GetRealWidth(160),
                        Height = Application.GetRealHeight(200),
                        BackgroundImagePath = "PersonalCenter/HomeList3bg.png",
                    };
                    dialogBody.AddChidren(dispalyView);
 
                    contentView.Height = Application.GetRealHeight(45 * 4);
                    dispalyView.AddChidren(contentView);
                }
                else
                {
                    dispalyView = new FrameLayout()
                    {
                        X = Application.GetRealWidth(10),
                        Y = Application.GetRealHeight(266),
                        Width = Application.GetRealWidth(160),
                        Height = Application.GetRealHeight(245),
                        BackgroundImagePath = "PersonalCenter/HomeList4bg.png",
                    };
                    dialogBody.AddChidren(dispalyView);
 
                    contentView.Height = Application.GetRealHeight(45 * 5);
                    contentView.ScrollEnabled = true;
                    dispalyView.AddChidren(contentView);
                }
 
 
                var showListRoom = new List<Room>();
                showListRoom.Add(new Room() { roomName = Language.StringByID(StringId.All) });
                showListRoom.AddRange(SpatialInfo.CurrentSpatial.RoomList);
 
                foreach (var roomTemp in showListRoom)
                {
                    string roomName = roomTemp.roomName;
                    var btnRoomName = new Button()
                    {
                        Gravity = Gravity.CenterHorizontal,
                        Width = Application.GetRealWidth(112),
                        Height = Application.GetRealHeight(44),
                        TextAlignment = TextAlignment.CenterLeft,
                        TextColor = CSS_Color.FirstLevelTitleColor,
                        SelectedTextColor = CSS_Color.MainColor,
                        Text = roomName,
                        TextSize = CSS_FontSize.SubheadingFontSize,
                        IsSelected = btnRoom.Text == roomName,
                        IsMoreLines = true,
                        Tag = roomName
                    };
                    contentView.AddChidren(btnRoomName);
 
                    btnRoomName.MouseUpEventHandler += (senderH, en) =>
                    {
                        dialog.Close();
                        btnRoom.Text = roomName;
                        room = roomTemp;
                        LoadSenesorList();
                    };
                }
 
                dialog.Show();
            };
 
            btnRoomClickRow.MouseUpEventHandler = eventHandler;
            //btnFoorDownIcon.MouseUpEventHandler = eventHandler;
        }
 
 
 
 
 
        #region event
 
        public static void LoadEvent_UpdataStatus(Function updateTemp)
        {
            Application.RunOnMainThread(() =>
            {
                if (bodyView != null)
                {
                    for (int i = 0; i < bodyView.sensorListView.ChildrenCount; i++)
                    {
                        var sensorTag = updateTemp.sid;
                        var view = bodyView.sensorListView.GetChildren(i);
                        if (view.GetType() == typeof(FrameLayout))
                        {
                            if (view.Tag.ToString() != sensorTag)
                            {
                                continue;
                            }
                            for (int j = 0; j < (view as FrameLayout).ChildrenCount; j++)
                            {
                                var btn = (view as FrameLayout).GetChildren(j);
                                if (btn.GetType() == typeof(Button))
                                {
                                    if (btn.Tag != null)
                                    {
                                        var tag = btn.Tag.ToString();
                                        if (tag == "SensorValues")
                                        {
                                            (btn as Button).Text = updateTemp.GetAttrState(FunctionAttributeKey.Value);
                                        }
                                        else if (tag == "SensorLevel")
                                        {
                                            (btn as Button).TextID = bodyView.sensorTemp.GetLevelTextList(updateTemp.spk)[bodyView.sensorTemp.GetCurLevel(updateTemp) - 1];
                                            (btn as Button).TextColor = bodyView.sensorTemp.GetLevelColorList(updateTemp.spk)[bodyView.sensorTemp.GetCurLevel(updateTemp) - 1];
                                        }
                                    }
                                }
                                else if (btn.GetType() == typeof(ArcSeekBar))
                                {
                                    (btn as ArcSeekBar).ProgressBarColor = bodyView.sensorTemp.GetLevelColorList(updateTemp.spk)[bodyView.sensorTemp.GetCurLevel(updateTemp) - 1];
 
                                    (btn as ArcSeekBar).Progress = (96 / bodyView.sensorTemp.GetLevelColorList(updateTemp.spk).Count) * bodyView.sensorTemp.GetCurLevel(updateTemp);
                                }
                            }
                        }
                    }
                }
            });
        }
 
        void LoadEvent_ChangeWeatherIcon(FrameLayout view)
        {
 
            switch (MainPage.cityInfo.weather)
            {
                case "晴":
                case "Sunny":
                case "晴天":
                case "天晴":
                case "Clear":
                case "大部晴朗":
                case "Mostly Sunny":
                case "晴時多雲":
                case "陽光充沛":
                case "Mostly Clear":
                    view.BackgroundImagePath = "FunctionIcon/EnvirSensor/0.png";
                    break;
                case "多云":
                case "Cloudy":
                case "多雲":
                case "少云":
                case "Partly Cloudy":
                case "少雲":
                    view.BackgroundImagePath = "FunctionIcon/EnvirSensor/1.png";
                    break;
                case "阴":
                case "Overcast":
                case "陰天":
                    view.BackgroundImagePath = "FunctionIcon/EnvirSensor/2.png";
                    break;
                case "阵雨":
                case "Showers":
                case "陣雨":
                case "驟雨":
                case "局部阵雨":
                case "Scattered Showers":
                case "局地陣雨":
                case "局部地區性驟雨":
                case "小阵雨":
                case "Light Showers":
                case "小陣雨":
                case "零散驟雨":
                case "强阵雨":
                case "Heavy Showers":
                case "強陣雨":
                case "間中有驟雨":
                    view.BackgroundImagePath = "FunctionIcon/EnvirSensor/3.png";
                    break;
                case "阵雪":
                case "Snow Showers":
                case "陣雪":
                case "驟雪":
                case "小阵雪":
                case "Light Snow Showers":
                case "小陣雪":
                case "零散驟雪":
                    view.BackgroundImagePath = "FunctionIcon/EnvirSensor/13.png";
                    break;
                case "雾":
                case "Fog":
                case "霧":
                case "薄霧":
                case "冻雾":
                case "Freezing Fog":
                case "凍霧":
                    view.BackgroundImagePath = "FunctionIcon/EnvirSensor/18.png";
                    break;
                case "沙尘暴":
                case "Sandstorm":
                case "沙塵暴":
                case "强沙尘暴":
                case "Heavy Sandstorm":
                case "強沙塵暴":
                    view.BackgroundImagePath = "FunctionIcon/EnvirSensor/20.png";
                    break;
                case "浮尘":
                case "Dust":
                case "浮塵":
                case "尘卷风":
                case "Dust Storm":
                case "塵捲風":
                case "扬沙":
                case "Sand":
                case "揚沙":
                    view.BackgroundImagePath = "FunctionIcon/EnvirSensor/29.png";
                    break;
                case "霾":
                case "Haze":
                case "煙霞":
                    view.BackgroundImagePath = "FunctionIcon/EnvirSensor/45.png";
                    break;
                case "雷阵雨":
                case "Thundershower":
                case "雷陣雨":
                case "雷雨":
                case "雷电":
                case "Lightning":
                case "雷電":
                case "雷暴":
                case "Thunderstorm":
                    view.BackgroundImagePath = "FunctionIcon/EnvirSensor/4.png";
                    break;
                case "雷阵雨伴有冰雹":
                case "Thundershower with Hail":
                case "雷陣雨伴有冰雹":
                case "雷雨伴有冰雹":
                case "冰雹":
                case "Hail":
                case "冰针":
                case "Needle Ice":
                case "冰針":
                case "冰粒":
                case "Icy":
                    view.BackgroundImagePath = "FunctionIcon/EnvirSensor/5.png";
                    break;
                case "雨夹雪":
                case "Sleet":
                case "雨夾雪":
                    view.BackgroundImagePath = "FunctionIcon/EnvirSensor/6.png";
                    break;
                case "小雨":
                case "Light Rain":
                    view.BackgroundImagePath = "FunctionIcon/EnvirSensor/3.png";
                    break;
                case "中雨":
                case "Rain":
                case "小到中雨":
                case "雨":
                    view.BackgroundImagePath = "FunctionIcon/EnvirSensor/3.png";
                    break;
                case "大雨":
                case "Heavy Rain":
                case "中到大雨":
                    view.BackgroundImagePath = "FunctionIcon/EnvirSensor/3.png";
                    break;
                case "暴雨":
                case "Rainstorm":
                case "豪雨":
                case "大暴雨":
                case "Heavy Rainstorm":
                case "大豪雨":
                case "特大暴雨":
                case "Extreme Rainstorm":
                case "超大豪雨":
                case "大到暴雨":
                    view.BackgroundImagePath = "FunctionIcon/EnvirSensor/3.png";
                    break;
                case "小雪":
                case "Light Snow":
                    view.BackgroundImagePath = "FunctionIcon/EnvirSensor/13.png";
                    break;
                case "雪":
                case "中雪":
                case "小到中雪":
                case "Snow":
                    view.BackgroundImagePath = "FunctionIcon/EnvirSensor/13.png";
                    break;
                case "大雪":
                case "Heavy Snow":
                    view.BackgroundImagePath = "FunctionIcon/EnvirSensor/13.png";
                    break;
                case "暴雪":
                case "Blizzard":
                    view.BackgroundImagePath = "FunctionIcon/EnvirSensor/13.png";
                    break;
                case "冻雨":
                case "Freezing Rain":
                case "凍雨":
                    view.BackgroundImagePath = "FunctionIcon/EnvirSensor/6.png";
                    break;
            }
        }
 
        #endregion
    }
}