wxr
2022-09-21 8d5792379f08075ed65fcadc2eeecc55467e341f
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
using System;
using System.Collections.Generic;
using HDL_ON.Entity;
using Shared;
 
namespace HDL_ON.UI
{
 
 
    /// <summary>
    /// 绿建科技系统
    /// 总控主页
    /// </summary>
    public class AcstParentPage : FrameLayout
    {
        static AcstParentPage basePage;
 
        VerticalScrolViewLayout bodyView;
 
        #region 天气控件
        Button btnOutdoorTemp;
        Button btnWeather;
        TextButton btnHumidityValues;
        TextButton btnPm25Values;
        #endregion
 
        #region 传感器、耗电量组件
        SensorDiyView sensorDiyView_Temp;
        SensorDiyView sensorDiyView_Humi;
        SensorDiyView sensorDiyView_Pm25;
        SensorDiyView sensorDiyView_Co2;
        SensorDiyView sensorDiyView_Tvoc;
        SensorDiyView sensorDiyView_EleDay;
        SensorDiyView sensorDiyView_EleMonth;
        SensorDiyView sensorDiyView_EleTotal;
        #endregion
        /// <summary>
        /// 子控区域列表
        /// </summary>
        Dictionary<string, AcstSubControlView> subViewList;
 
 
        public override void RemoveFromParent()
        {
            base.RemoveFromParent();
            basePage = null;
        }
 
        Function function;
        /// <summary>
        /// 当前时段颜色
        /// </summary>
        uint curColor = CSS.CSS_Color.MainColor;
 
        string imageFolder = "blue";
 
        public AcstParentPage()
        {
            basePage = this;
            this.function = FunctionList.List.GetAcstParentList()[0];
            this.BackgroundColor = CSS.CSS_Color.BackgroundColor;
            bodyView = new VerticalScrolViewLayout();
            this.AddChidren(bodyView);
            subViewList = new Dictionary<string, AcstSubControlView>();
        }
        /// <summary>
        /// 更新天气信息
        /// </summary>
        public void InitGetWeatherAction()
        {
            MainPage.CityWeatherAction = () =>
            {
                Application.RunOnMainThread(() =>
                {
                    btnOutdoorTemp.Text = MainPage.cityInfo.temperature + "°";
                    btnWeather.Text = MainPage.cityInfo.weather;
                    btnHumidityValues.Text = MainPage.cityInfo.humidity + "%";
                    btnHumidityValues.Width = btnHumidityValues.GetTextWidth() + Application.GetRealWidth(10);
                    btnPm25Values.Text = MainPage.cityInfo.pm25;
                    btnPm25Values.Width = btnPm25Values.GetTextWidth() + Application.GetRealWidth(10);
                });
            };
        }
        /// <summary>
        /// 传感器、耗电量组件
        /// </summary>
        public static void UpdateAcstParentInfo(Function temp)
        {
            if (basePage == null)
            {
                return;
            }
            if (basePage.sensorDiyView_Temp != null)
                basePage.sensorDiyView_Temp.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.room_temp.ToString()).curValue.ToString());
            if (basePage.sensorDiyView_Humi != null)
                basePage.sensorDiyView_Humi.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.room_humidity.ToString()).curValue.ToString());
            if (basePage.sensorDiyView_Pm25 != null)
                basePage.sensorDiyView_Pm25.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.pm25.ToString()).curValue.ToString());
            if (basePage.sensorDiyView_Co2 != null)
                basePage.sensorDiyView_Co2.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.co2.ToString()).curValue.ToString());
            if (basePage.sensorDiyView_Tvoc != null)
                basePage.sensorDiyView_Tvoc.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.tvoc.ToString()).curValue.ToString());
            if (basePage.sensorDiyView_EleDay != null)
                basePage.sensorDiyView_EleDay.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.day_electricity.ToString()).curValue.ToString());
            if (basePage.sensorDiyView_EleMonth != null)
                basePage.sensorDiyView_EleMonth.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.month_electricity.ToString()).curValue.ToString());
            if (basePage.sensorDiyView_EleTotal != null)
                basePage.sensorDiyView_EleTotal.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.total_electricity.ToString()).curValue.ToString());
        }
 
        /// <summary>
        /// 更新子控信息
        /// </summary>
        /// <param name="temp"></param>
        public static void UpdateAcstSubInfo(Function temp)
        {
            if(basePage == null)
            {
                return;
            }
            Application.RunOnMainThread(() => {
                var view = basePage.subViewList[temp.sid];
                if(view!= null)
                {
                    view.btnSubHumidityValues.Text = temp.GetAttrState(AcstSub_AttrEnum.room_humidity.ToString()) + "%";
                    view.btnSubTempValues.Text = temp.GetAttrState(AcstSub_AttrEnum.room_humidity.ToString()) + "%";
                    view.btnSubPower.IsSelected = temp.GetAttrState(AcstSub_AttrEnum.on_off.ToString()) == "on";
                }
            });
        }
 
        public void LoadPage()
        {
            var curTime = DateTime.Now;
            string helloText = "上午好";
            if (curTime.Hour >= 8 && curTime.Hour < 12)
            {
                helloText = "上午好";
                curColor = CSS.CSS_Color.MainColor;
                imageFolder = "blue";
            }
            else if (curTime.Hour >= 12 && curTime.Hour < 18)
            {
                helloText = "下午好";
                curColor = 0xFFE7914F;
                imageFolder = "orange";
            }
            else
            {
                helloText = "晚上好";
                curColor = 0xFF9175F3;
                imageFolder = "purple";
            }
 
            #region 头部信息区域
            FrameLayout topView = new FrameLayout()
            {
                Height = Application.GetRealHeight(181),
                BackgroundColor = 0xFFb0eafa,
                BackgroundImagePath = $"FunctionIcon/Acst/{imageFolder}/TopViewBg.png",
            };
            bodyView.AddChidren(topView);
 
            var backView = new FrameLayout()
            {
                Y = Application.GetRealHeight(32),
                Width = Application.GetRealWidth(100),
                Height = Application.GetRealHeight(34),
            };
            topView.AddChidren(backView);
 
            Button btnBackIcon = new Button()
            {
                X = Application.GetRealWidth(16),
                Width = Application.GetRealWidth(40),
                Height = Application.GetRealWidth(28),
                UnSelectedImagePath = "Public/BackIcon.png",
            };
            backView.AddChidren(btnBackIcon);
 
            btnBackIcon.MouseUpEventHandler = (sender, e) => {
                this.RemoveFromParent();
            };
 
            var btnHelloText = new Button()
            {
                X = Application.GetRealWidth(25),
                Y = Application.GetRealHeight(55),
                Width = Application.GetRealWidth(200),
                Height = Application.GetRealHeight(38),
                TextSize = 20,
                Text = helloText,
                TextColor = 0xFFFFFFFF,
                TextAlignment = TextAlignment.CenterLeft,
            };
            topView.AddChidren(btnHelloText);
 
            
            btnOutdoorTemp = new Button()
            {
                X = Application.GetRealWidth(25),
                Y = Application.GetRealHeight(90),
                Width = Application.GetRealWidth(85),
                Height = Application.GetRealHeight(66),
                TextColor = 0xFFFFFFFF,
                TextSize = 50,
                TextAlignment = TextAlignment.TopLeft,
                Text = MainPage.cityInfo.temperature + "°"
            };
            topView.AddChidren(btnOutdoorTemp);
 
            btnWeather = new Button()
            {
                X = btnOutdoorTemp.Right,
                Y = Application.GetRealHeight(95),
                Width = Application.GetRealWidth(80),
                Height = Application.GetRealHeight(26),
                Text = MainPage.cityInfo.weather,
                TextColor = 0xFFFFFFFF,
                TextSize = 14,
                TextAlignment = TextAlignment.CenterLeft,
            };
            topView.AddChidren(btnWeather);
 
 
            var environmentalView = new FrameLayout()
            {
                Y = Application.GetRealHeight(150),
                Height = Application.GetRealHeight(32),
            };
            topView.AddChidren(environmentalView);
 
            var btnHumidityIcon = new Button()
            {
                X = Application.GetRealWidth(25),
                Gravity = Gravity.CenterVertical,
                Width = Application.GetMinRealAverage(16),
                Height = Application.GetMinRealAverage(16),
                UnSelectedImagePath = "Public/DeviceInfoIcon/HumidityIcon.png",
            };
            environmentalView.AddChidren(btnHumidityIcon);
 
            btnHumidityValues = new TextButton()
            {
                X = btnHumidityIcon.Right + Application.GetRealWidth(4),
                Gravity = Gravity.CenterVertical,
                TextColor = 0xFFFFFFFF,
                TextSize = 16,
                Text = MainPage.cityInfo.humidity + "%",
                TextAlignment = TextAlignment.CenterLeft,
            };
            btnHumidityValues.Width = btnHumidityValues.GetTextWidth();
            environmentalView.AddChidren(btnHumidityValues);
 
            var btnPm25Icon = new Button()
            {
                X = btnHumidityValues.Right + Application.GetRealWidth(14),
                Gravity = Gravity.CenterVertical,
                Width = Application.GetMinRealAverage(16),
                Height = Application.GetMinRealAverage(16),
                UnSelectedImagePath = "Public/DeviceInfoIcon/Pm25Icon.png",
            };
            environmentalView.AddChidren(btnPm25Icon);
 
            btnPm25Values = new TextButton()
            {
                X = btnPm25Icon.Right + Application.GetRealWidth(4),
                Gravity = Gravity.CenterVertical,
                TextColor = 0xFFFFFFFF,
                TextSize = 16,
                Text = MainPage.cityInfo.pm25,
                TextAlignment = TextAlignment.CenterLeft,
            };
            btnPm25Values.Width = btnPm25Values.GetTextWidth();
            environmentalView.AddChidren(btnPm25Values);
 
 
            #endregion
 
            bodyView.AddChidren(new Button
            {
                Height = Application.GetRealHeight(8),
            });
 
            #region 数据
            var infoView = new FrameLayout()
            {
                Y = topView.Bottom,
                Height = Application.GetRealHeight(104),
                BackgroundColor = CSS.CSS_Color.MainBackgroundColor,
            };
            bodyView.AddChidren(infoView);
 
            var infoContentView = new FrameLayout()
            {
                Gravity = Gravity.Center,
                Width = Application.GetRealWidth(343),
                Height = Application.GetRealHeight(72),
                BackgroundImagePath = $"FunctionIcon/Acst/{imageFolder}/MsgViewBg.png",
            };
            infoView.AddChidren(infoContentView);
 
            #region 传感器数据
            int sensorCount = 0;
            var tempObj = function.GetAttribute(AcstParent_AttrEnum.room_temp.ToString());
            if(tempObj!= null)
            {
                sensorCount++;
            }
            var humiObj = function.GetAttribute(AcstParent_AttrEnum.room_humidity.ToString());
            if(humiObj != null)
            {
                sensorCount++;
            }
            var pm25Obj = function.GetAttribute(AcstParent_AttrEnum.pm25.ToString());
            if (pm25Obj != null)
            {
                sensorCount++;
            }
            var co2Obj = function.GetAttribute(AcstParent_AttrEnum.co2.ToString());
            if (co2Obj != null)
            {
                sensorCount++;
            }
            var tvocObj = function.GetAttribute(AcstParent_AttrEnum.tvoc.ToString());
            if (tvocObj != null)
            {
                sensorCount++;
            }
 
            var sensorListView = new HorizontalScrolViewLayout()
            {
                Width = Application.GetRealWidth(60 * sensorCount),
                Gravity = Gravity.Center,
            };
            infoContentView.AddChidren(sensorListView);
 
 
            if (tempObj != null)
            {
                sensorDiyView_Temp = new SensorDiyView(sensorListView, curColor, tempObj.curValue.ToString() + "°", "温度");
            }
            if (humiObj != null)
            {
                sensorDiyView_Humi = new SensorDiyView(sensorListView, curColor, humiObj.curValue.ToString() + "%", "湿度");
            }
            if (pm25Obj != null)
            {
                sensorDiyView_Pm25 = new SensorDiyView(sensorListView, curColor, pm25Obj.curValue.ToString(), "PM2.5");
            }
            if (co2Obj != null)
            {
                sensorDiyView_Co2 = new SensorDiyView(sensorListView, curColor, co2Obj.curValue.ToString(), "CO2");
            }
            if (tvocObj != null)
            {
                sensorDiyView_Tvoc = new SensorDiyView(sensorListView, curColor, tvocObj.curValue.ToString(), "TVOC");
            }
            #endregion
 
            #region 能耗数据
            int energyCount = 0;
            var dayObj = function.GetAttribute(AcstParent_AttrEnum.day_electricity.ToString());
            if (dayObj != null)
            {
                energyCount++;
            }
            var monthObj = function.GetAttribute(AcstParent_AttrEnum.month_electricity.ToString());
            if (monthObj != null)
            {
                energyCount++;
            }
            var totalObj = function.GetAttribute(AcstParent_AttrEnum.total_electricity.ToString());
            if (totalObj != null)
            {
                energyCount++;
            }
 
            var energyListView = new HorizontalScrolViewLayout()
            {
                Width = Application.GetRealWidth(60 * energyCount),
                Gravity = Gravity.Center,
                Visible = false,
            };
            infoContentView.AddChidren(energyListView);
            if (dayObj != null)
            {
                sensorDiyView_EleDay = new SensorDiyView(energyListView, curColor, dayObj.curValue.ToString(), "今日耗电");
            }
            if (monthObj != null)
            {
                sensorDiyView_EleMonth = new SensorDiyView(energyListView, curColor, monthObj.curValue.ToString(), "本月耗电");
            }
            if (totalObj != null)
            {
                sensorDiyView_EleTotal = new SensorDiyView(energyListView, curColor, totalObj.curValue.ToString(), "总耗电量");
            }
 
            var btnChangeClick = new Button();
            infoView.AddChidren(btnChangeClick);
 
            bool showSensor = true;
            EventHandler<MouseEventArgs> changeInfoEvent = (sender, e) => {
                if (showSensor)
                {
                    sensorListView.Visible = false;
                    showSensor = false;
                    energyListView.Visible = true;
                }
                else
                {
                    sensorListView.Visible = true;
                    showSensor = true;
                    energyListView.Visible = false;
                }
            };
            btnChangeClick.MouseUpEventHandler = changeInfoEvent;
 
 
            #endregion
 
            #endregion
 
            #region 子控列表
 
            var subTitleView = new FrameLayout()
            {
                Height = Application.GetRealHeight(54-11),
            };
            bodyView.AddChidren(subTitleView);
 
            var btnCollection = new Button()
            {
                X = Application.GetRealWidth(6),
                Y = Application.GetRealHeight(10),
                Width = Application.GetRealWidth(39),
                Height = Application.GetRealWidth(39),
                IsSelected = function.collect,
                UnSelectedImagePath = "FunctionIcon/Acst/grey/CollectionIcon.png",
                SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/CollectionIcon.png",
            };
            subTitleView.AddChidren(btnCollection);
 
            var btnTitleText = new Button()
            {
                X = btnCollection.Right,
                Text = "我的家庭",
                TextSize = 16,
                TextColor = 0xFF242424,
                TextAlignment = TextAlignment.CenterLeft,
                IsBold = true,
                Height = Application.GetRealHeight(54),
            };
            subTitleView.AddChidren(btnTitleText);
 
            int subFunctionCount = 0;
 
            var subFunctionListView = new HorizontalScrolViewLayout()
            {
                Height = Application.GetRealHeight(88),
            };
            bodyView.AddChidren(subFunctionListView);
 
 
            subFunctionListView.AddChidren(new Button { Width = Application.GetRealWidth(9) });
            foreach (var sub in FunctionList.List.GetAcstSubList())
            {
                if (subViewList.ContainsKey(sub.sid))
                {
                    continue;
                }
 
                if (subFunctionCount > 0 && subFunctionCount % 2 == 0)
                {
                    subFunctionListView = new HorizontalScrolViewLayout()
                    {
                        Height = Application.GetRealHeight(93),
                    };
                    bodyView.AddChidren(subFunctionListView);
                    subFunctionListView.AddChidren(new Button { Width = Application.GetRealWidth(9) });
                }
 
                AcstSubControlView subFunctionView = new AcstSubControlView(sub, subFunctionListView,imageFolder);
 
                subViewList.Add(sub.sid, subFunctionView);
 
 
 
                subFunctionCount++;
            }
 
            #endregion
 
            bodyView.AddChidren(new Button()
            {
                Height = Application.GetRealHeight(72),
            });
 
            #region 底部控制栏
            var bottomView = new FrameLayout()
            {
                Y = Application.GetRealHeight(667 - 56),
                Height = Application.GetRealHeight(56),
                BackgroundColor = CSS.CSS_Color.MainBackgroundColor,
            };
            this.AddChidren(bottomView);
 
            var btnModeControl = new Button()
            {
                X = Application.GetRealWidth(89),
                Gravity = Gravity.CenterVertical,
                Width = Application.GetRealWidth(38),
                Height = Application.GetRealWidth(38),
                UnSelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/ModeCoolIcon2.png",
                SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/ModeCoolIcon2.png",
                TextAlignment = TextAlignment.Center,
            };
            bottomView.AddChidren(btnModeControl);
            btnModeControl.MouseUpEventHandler = (sender, e) =>
            {
                Dialog dialog = new Dialog();
 
                var dialogView = new FrameLayout();
                dialog.AddChidren(dialogView);
                dialogView.MouseUpEventHandler = (sender, e) => {
                    dialog.Close();
                };
 
                var dialogContentView = new FrameLayout() {
                    X = Application.GetRealWidth(34),
                    Y = Application.GetRealHeight(291),
                    Width = Application.GetRealWidth(144),
                    Height = Application.GetRealHeight(291),
                    BackgroundImagePath = "FunctionIcon/Acst/BgChooseMode.png",
                };
                dialogView.AddChidren(dialogContentView);
 
                var titleView = new FrameLayout() {
                    X = Application.GetRealWidth(2),
                    Y = Application.GetRealHeight(3),
                    Width = Application.GetRealWidth(144),
                    Height = Application.GetRealHeight(44),
                };
                dialogContentView.AddChidren(titleView);
                var btnTitleText = new Button()
                {
                    X = Application.GetRealWidth(16),
                    Width = Application.GetRealWidth(100),
                    Text = "选择模式",
                    TextSize = 16,
                    TextColor = CSS.CSS_Color.FirstLevelTitleColor,
                    IsBold = true,
                    TextAlignment = TextAlignment.CenterLeft,
                };
                titleView.AddChidren(btnTitleText);
 
 
 
 
 
                dialog.Show();
            };
 
            var btnPowerControl = new Button()
            {
                Gravity = Gravity.Center,
                Width = Application.GetRealWidth(38),
                Height = Application.GetRealWidth(38),
                UnSelectedImagePath = "FunctionIcon/Acst/grey/PowerOffIcon.png",
                SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/PowerOnIcon.png",
                TextAlignment = TextAlignment.Center,
            };
            bottomView.AddChidren(btnPowerControl);
 
 
            var btnWorkSceneControl = new Button()
            {
                Gravity = Gravity.CenterVertical,
                X = Application.GetRealWidth(249),
                Width = Application.GetRealWidth(38),
                Height = Application.GetRealWidth(38),
                UnSelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/SceneSleepIcon2.png",
                SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/SceneSleepIcon2.png",
                TextAlignment = TextAlignment.Center,
            };
            bottomView.AddChidren(btnWorkSceneControl);
 
 
 
 
            #endregion
 
 
 
 
 
 
 
            InitGetWeatherAction();
 
        }
 
 
 
    }
 
    /// <summary>
    /// 传感器数据组件
    /// </summary>
    public class SensorDiyView
    {
        private FrameLayout contentView;
        private Button btnValue;
        private Button btnText;
        public string Tag;
 
        public SensorDiyView(HorizontalScrolViewLayout view,uint color,string value,string text)
        {
            ///默认Tag 为传进来的Text
            Tag = text;
 
            contentView = new FrameLayout()
            {
                Width = Application.GetRealWidth(60),
                Height = Application.GetRealHeight(72),
            };
            view.AddChidren(contentView);
 
            btnValue = new Button()
            {
                Y = Application.GetRealHeight(10),
                Height = Application.GetRealHeight(72 - 37),
                TextAlignment = TextAlignment.Center,
                TextColor = color,
                TextSize = 20,
                Text = value,
            };
            contentView.AddChidren(btnValue);
 
            btnText = new Button()
            {
                Y = Application.GetRealHeight(72 - 37),
                Height = Application.GetRealHeight(37),
                TextAlignment = TextAlignment.Center,
                TextColor = 0xFF949AA5,
                TextSize = 12,
                Text = text,
            };
            contentView.AddChidren(btnText);
        }
 
        public void UpdateValue(string value)
        {
            btnText.Text = value;
        }
    }
 
    /// <summary>
    /// 子控卡片组件
    /// </summary>
    public class AcstSubControlView
    {
        public TextButton btnSubTempValues;
        public TextButton btnSubHumidityValues;
        public Button btnSubPower;
 
        public AcstSubControlView(Function sub, HorizontalScrolViewLayout subFunctionListView,string imageFolder)
        {
            var subFunctionView = new FrameLayout()
            {
                Width = Application.GetRealWidth(177),
                Height = Application.GetRealHeight(93),
                BackgroundImagePath = "FunctionIcon/Acst/grey/BgSubControlView.png",
            };
            subFunctionListView.AddChidren(subFunctionView);
 
            var btnRoomInfo = new Button()
            {
                X = Application.GetRealWidth(18 + 7),
                Y = Application.GetRealHeight(11),
                Height = Application.GetRealHeight(40),
                TextAlignment = TextAlignment.CenterLeft,
                TextColor = 0xFF1b3053,
                TextSize = 13,
                Text = sub.GetRoomListName(),
            };
            subFunctionView.AddChidren(btnRoomInfo);
 
            var btnSubTempIcon = new Button()
            {
                X = Application.GetRealWidth(16 + 7),
                Y = Application.GetRealHeight(47 + 11),
                Width = Application.GetMinRealAverage(11),
                Height = Application.GetMinRealAverage(11),
                UnSelectedImagePath = "FunctionIcon/CAC/HvacCacTempIcon.png",
            };
            subFunctionView.AddChidren(btnSubTempIcon);
 
            btnSubTempValues = new TextButton()
            {
                X = btnSubTempIcon.Right,
                Y = Application.GetRealHeight(45 + 11),
                Height = Application.GetRealHeight(14),
                Width = Application.GetRealWidth(22),
                TextColor = 0xFF1b3035,
                TextSize = 10,
                Text = sub.GetAttrState(AcstSub_AttrEnum.room_temp.ToString()) + "°C",
                TextAlignment = TextAlignment.CenterLeft,
            };
            subFunctionView.AddChidren(btnSubTempValues);
 
            Button btnSubHumidityIcon = new Button()
            {
                X = btnSubTempValues.Right + Application.GetRealWidth(5),
                Y = Application.GetRealHeight(47 + 11),
                Width = Application.GetMinRealAverage(11),
                Height = Application.GetMinRealAverage(11),
                UnSelectedImagePath = "FunctionIcon/CAC/HvacCacHumidityIcon.png",
            };
            subFunctionView.AddChidren(btnSubHumidityIcon);
 
            btnSubHumidityValues = new TextButton()
            {
                X = btnSubHumidityIcon.Right,
                Y = Application.GetRealHeight(45 + 11),
                Height = Application.GetRealHeight(14),
                Width = Application.GetRealWidth(22),
                TextColor = 0xFF1b3053,
                TextSize = 10,
                Text = sub.GetAttrState(AcstSub_AttrEnum.room_humidity.ToString()) + "%",
                TextAlignment = TextAlignment.CenterLeft,
            };
            subFunctionView.AddChidren(btnSubHumidityValues);
 
            btnSubPower = new Button()
            {
                X = Application.GetRealWidth(121 + 7),
                Gravity = Gravity.CenterVertical,
                Width = Application.GetRealWidth(28),
                Height = Application.GetRealWidth(28),
                UnSelectedImagePath = "FunctionIcon/Acst/grey/PowerOffIcon.png",
                SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/PowerIcon.png",
                TextAlignment = TextAlignment.Center,
            };
            subFunctionView.AddChidren(btnSubPower);
 
        }
    }
 
 
    public class IconButton : FrameLayout
    {
        FrameLayout view;
 
        public Button btnIcon;
 
        public Button btnText;
 
        public IconButton(string iconPath,string iconPath2,string text,uint color,bool isSelect)
        {
            view = this;
            view.Width = Application.GetRealWidth(144);
            view.Height = Application.GetRealHeight(44);
 
            btnIcon = new Button()
            {
                X = Application.GetRealWidth(16),
                Gravity = Gravity.CenterHorizontal,
                Width = Application.GetRealWidth(24),
                Height = Application.GetRealWidth(24),
                UnSelectedImagePath = iconPath,
                SelectedImagePath = iconPath2,
                IsSelected = isSelect,
            };
            view.AddChidren(btnIcon);
 
            btnText = new Button()
            {
                X = btnIcon.Right + Application.GetRealWidth(12),
                Width = Application.GetRealWidth(90),
                TextAlignment = TextAlignment.CenterLeft,
                Text = text,
                TextSize = 14,
                TextColor = CSS.CSS_Color.FirstLevelTitleColor,
                SelectedTextColor = color,
                IsSelected = isSelect,
            };
            view.AddChidren(btnText);
 
            
        }
    }
}