HDL Home App 第二版本 旧平台金堂用 正在使用
黄学彪
2019-10-28 8b4d79ca03495e522a1953e04ca17527f33c853a
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
using System;
using System.Collections.Generic;
using System.Globalization;
using Shared.Common;
using Shared.Phone.Device.Category;
 
namespace Shared.Phone.Device.Room
{
    /// <summary>
    /// Add room scene.
    /// </summary>
    public class AddRoomScene:FrameLayout
    {
        public static Shared.Common.Room CurrentRoom;
        public static string SceneText;
        public static string ImagePath;
        /// <summary>
        /// 图片来源 0--本地图库 1--拍照 2--系统图库
        /// </summary>
        public int IconType = 0;
        ///添加目标后的展示列表
        public VerticalScrolViewLayout TargetListScrolView;
        /// <summary>
        /// The scene target devices list.
        /// </summary>
        public static List<SceneTargetDeviceUI> sceneTargetDevicesList = new List<SceneTargetDeviceUI> { };
        /// <summary>
        /// 添加的执行目标的行高
        /// </summary>
        private readonly int TargetListScrolView_RowHeight = 170;
        /// <summary>
        /// The confirm button.
        /// </summary>
        private CommonForm.CompleteButton confirmBtn;
        /// <summary>
        /// 确定按钮最开始的坐标
        /// </summary>
        private readonly int ConfirmButton_Y= CommonPage.AppRealHeight - 300;
        /// <summary>
        /// 确定按钮下移后的坐标
        /// </summary>
        private readonly int ConfirmButton_Change_Y = CommonPage.AppRealHeight - 130;
         /// <summary>
         ///刷新添加目标后的展示列表
         /// </summary>
        public void RefreshTargetListView()
        {
            TargetListScrolView.RemoveAll();
            if (sceneTargetDevicesList.Count >= 2)
            {
                TargetListScrolView.Height = Application.GetRealHeight(TargetListScrolView_RowHeight * 3);
                confirmBtn.Y = Application.GetRealHeight(ConfirmButton_Change_Y);
            }
            else
            {
                TargetListScrolView.Height = Application.GetRealHeight(TargetListScrolView_RowHeight * 2);
                confirmBtn.Y = Application.GetRealHeight(ConfirmButton_Y);
            }
 
            if (sceneTargetDevicesList.Count > 0)
            {
                foreach (var targetDevice in sceneTargetDevicesList)
                {
                    string devImgPath = string.Empty;
                    string devNameText = string.Empty;
                    if (targetDevice.Type == 0)
                    {
                        if (targetDevice.DeviceUI == null || targetDevice.DeviceUI.CommonDevice == null)
                        {
                            continue;
                        }
                        devImgPath = targetDevice.DeviceUI.IconPath;
                        devNameText = targetDevice.DeviceUI.CommonDevice.DeviceEpointName;
                    }
                    else if (targetDevice.Type == 1)
                    {
                        devImgPath = "Item/Timer.png";
                        devNameText = $"{targetDevice.DelayTime} {Language.StringByID(R.MyInternationalizationString.Second)}";
                    }
                    else if (targetDevice.Type == 2)
                    {
                        devImgPath = "Item/Scene.png";
                        devNameText = targetDevice.SceneName;
                    }
 
                    var targetRowLayout = new RowLayout()
                    {
                        LineColor = ZigbeeColor.Current.GXCLineColor,
                        Height = Application.GetRealHeight(170)
                    };
                    TargetListScrolView.AddChidren(targetRowLayout);
                    var devIMG = new Button()
                    {
                        X = Application.GetRealWidth(CommonPage.XLeft),
                        Width = Application.GetMinRealAverage(110),
                        Height = Application.GetMinRealAverage(110),
                        UnSelectedImagePath = devImgPath,
                        Gravity = Gravity.CenterVertical
                    };
                    targetRowLayout.AddChidren(devIMG);
                    var devName = new Button()
                    {
                        X = devIMG.Right,
                        Width = Application.GetRealWidth(500),
                        Height = Application.GetRealHeight(100),
                        Gravity = Gravity.CenterVertical,
                        Text = devNameText,
                        TextColor = ZigbeeColor.Current.GXCTextBlackColor,
                        TextAlignment = TextAlignment.CenterLeft
                    };
                    targetRowLayout.AddChidren(devName);
                    var devTimer = new Button()
                    {
                        X = targetRowLayout.Width - Application.GetRealWidth(150),
                        Width = Application.GetMinRealAverage(110),
                        Height = Application.GetMinRealAverage(110),
                        UnSelectedImagePath = "Item/Timer.png",
                        Gravity = Gravity.CenterVertical
                    };
                    //targetRowLayout.AddChidren(devTimer);
                    var devRight = new Button()
                    {
                        //UnSelectedImagePath = "Item/Delete.png",
                        BackgroundColor = ZigbeeColor.Current.GXCRedColor,
                        TextID = R.MyInternationalizationString.Delete,
                        TextColor = ZigbeeColor.Current.GXCTextWhiteColor
                    };
                    targetRowLayout.AddRightView(devRight);
 
                    devTimer.MouseUpEventHandler += (sender, e) =>
                    {
                        //计时
                        /////******暂时先不加延时,安卓控件有问题*******////
                        var tList = new List<string> { };
                        for (int i = 1; i <= 60; i++)
                        {
                            tList.Add($"{i} {Language.StringByID(R.MyInternationalizationString.Second)}");
                        }
                        //1-60秒
                        //PickerView.Show(tList, (obj) =>
                        //{
                            //targetDevice.DelayTime = int.Parse(obj.Split(' ')[0]);
                        //}, Language.StringByID(R.MyInternationalizationString.Confrim));
                    };
                    devRight.MouseUpEventHandler += (sender, e) =>
                    {
                        //删除设备
                        sceneTargetDevicesList.Remove(targetDevice);
                        RefreshTargetListView();
                    };
                    //设备详细设置界面
                    void detailMouseUpEventHandler(object sender, MouseEventArgs e)
                    {
                        //设备
                        if (targetDevice.Type == 0)
                        {
                            if (targetDevice.DeviceUI == null || targetDevice.DeviceUI.CommonDevice == null)
                            {
                                return;
                            }
                            if (targetDevice.DeviceUI.CommonDevice.Type == ZigBee.Device.DeviceType.OnOffOutput)
                            {
                                //开关灯
                                var taskList = targetDevice.TaskList;
                                if (taskList.Count == 0)
                                {
                                    return;
                                }
                                var detail = new CategorySceneSelectLightSetting();
                                UserView.HomePage.Instance.AddChidren(detail);
                                UserView.HomePage.Instance.PageIndex += 1;
                                detail.Show(targetDevice.DeviceUI, targetDevice.SceneTargetDeviceUIID, taskList[0].Data1,true);
                            }
                            else if (targetDevice.DeviceUI.CommonDevice.Type == ZigBee.Device.DeviceType.AirSwitch)
                            {
                                //空气开关
                                var taskList = targetDevice.TaskList;
                                if (taskList.Count == 0)
                                {
                                    return;
                                }
                                var detail = new CategorySceneSelectAirSwitchSetting();
                                UserView.HomePage.Instance.AddChidren(detail);
                                UserView.HomePage.Instance.PageIndex += 1;
                                detail.Show(targetDevice.DeviceUI, targetDevice.SceneTargetDeviceUIID, taskList[0].Data1, true);
                            }
                            else if (targetDevice.DeviceUI.CommonDevice.Type == ZigBee.Device.DeviceType.WindowCoveringDevice)
                            {
                                //卷帘
                                var taskList = targetDevice.TaskList;
                                if (taskList.Count == 0)
                                {
                                    return;
                                }
                                var detail = new CategorySceneSelectCurtainSetting();
                                UserView.HomePage.Instance.AddChidren(detail);
                                UserView.HomePage.Instance.PageIndex += 1;
                                UserView.HomePage.Instance.ScrollEnabled = false;
                                detail.Show(targetDevice.DeviceUI, targetDevice.SceneTargetDeviceUIID, taskList[0].Data1, taskList[0].Data2,true);
                            }
                        }
                        //时间间隔
                        else if (targetDevice.Type == 1)
                        {
                            var delayTimeView = new SelectDelayTime();
                            UserView.HomePage.Instance.AddChidren(delayTimeView);
                            UserView.HomePage.Instance.PageIndex += 1;
                            //delayTimeView.Show(1, targetDevice.SceneTargetDeviceUIID,-1,true);
                        }
                        //场景
                        else if (targetDevice.Type == 2)
                        {
                            var sceneView = new CategorySceneSelectedScene();
                            UserView.HomePage.Instance.AddChidren(sceneView);
                            UserView.HomePage.Instance.PageIndex += 1;
                            sceneView.Show(sceneTargetDevicesList, 1, targetDevice.SceneTargetDeviceUIID,true);
                        }
                    }
                    devIMG.MouseUpEventHandler += detailMouseUpEventHandler;
                    devName.MouseUpEventHandler += detailMouseUpEventHandler;
                    targetRowLayout.MouseUpEventHandler += detailMouseUpEventHandler;
                }
            }
        }
        public override void RemoveFromParent()
        {
            AddRoomContent.instance?.RefreshBodyView();
            base.RemoveFromParent();
        }
        public AddRoomScene()
        {
            BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor;
            Tag = "categoryAddScene";
        }
        public void Show(Shared.Common.Room room)
        {
            CurrentRoom = room;
            #region topview
            var topBGView = new FrameLayout()
            {
                Height = Application.GetRealHeight(CommonPage.Navigation_Height),
                BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor
            };
            AddChidren(topBGView);
            var topView = new FrameLayout()
            {
                Y = Application.GetRealHeight(CommonPage.NavigationTitle_Y),
                Height = Application.GetRealHeight(CommonPage.Navigation_Height - CommonPage.NavigationTitle_Y),
                BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor,
            };
            AddChidren(topView);
 
            var title = new Button()
            {
                TextAlignment = TextAlignment.Center,
                TextID = R.MyInternationalizationString.AddScence,
                TextSize = 20,
                TextColor = ZigbeeColor.Current.GXCTextBlackColor,
                Width = Application.GetRealWidth(CommonPage.AppRealWidth - 500),
                Gravity = Gravity.CenterHorizontal
            };
            topView.AddChidren(title);
 
            var back = new Button()
            {
                X = Application.GetRealWidth(CommonPage.Navigation_X),
                Height = Application.GetMinRealAverage(110),
                Width = Application.GetMinRealAverage(110),
                UnSelectedImagePath = "Item/Back.png",
                SelectedImagePath = "Item/BackSelected.png",
                Gravity = Gravity.CenterVertical
            };
            topView.AddChidren(back);
            back.MouseUpEventHandler += (sender, e) =>
            {
                this.RemoveFromParent();
            };
            #endregion
 
            #region midFL
            var midFL = new FrameLayout()
            {
                Height = Application.GetRealHeight(CommonPage.AppRealHeight - CommonPage.Navigation_Height),
                Y = topView.Bottom,
                BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
            };
            this.AddChidren(midFL);
            #endregion
 
            #region 背景图 名称 区域 执行目标
            var backGround = new Button()
            {
                Y = Application.GetRealHeight(50),
                Width = Application.GetMinRealAverage(CommonPage.AppRealWidth-CommonPage.XLeft*2),
                Height = Application.GetMinRealAverage(400),
                Gravity = Gravity.CenterHorizontal,
                Radius = CommonPage.BigFormRadius,
                UnSelectedImagePath = ImagePath
            };
            midFL.AddChidren(backGround);
 
            //设备名称--场景名
            var deviceNameFL = new FrameLayout()
            {
                Y = backGround.Bottom + Application.GetRealHeight(100),
                Height = Application.GetRealHeight(170),
            };
            midFL.AddChidren(deviceNameFL);
            var deviceNameTip = new Button()
            {
                X = Application.GetRealWidth(50),
                Height = Application.GetRealHeight(70),
                Width = Application.GetRealWidth(300),
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = 12,
                TextColor = ZigbeeColor.Current.GXCButtonTipColor,
                TextID = R.MyInternationalizationString.SceneName,
            };
            deviceNameFL.AddChidren(deviceNameTip);
            var sceneNameET = new EditText()
            {
                X = Application.GetRealWidth(50),
                Y = deviceNameTip.Bottom,
                Height = Application.GetRealHeight(100) - 1,
                Width = Application.GetRealWidth(700),
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = 20,
                PlaceholderText = Language.StringByID(R.MyInternationalizationString.PleaseInputSceneName),
                PlaceholderTextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor,
                TextColor = ZigbeeColor.Current.GXCTextBlackColor,
            };
            deviceNameFL.AddChidren(sceneNameET);
            var deviceNameLine = new Button()
            {
                Y = sceneNameET.Bottom,
                Height = 1,
                BackgroundColor = ZigbeeColor.Current.GXCLineColor
            };
            deviceNameFL.AddChidren(deviceNameLine);
 
            //zone
            var zoneFL = new FrameLayout()
            {
                Y = deviceNameFL.Bottom,
                Height = Application.GetRealHeight(170),
            };
            midFL.AddChidren(zoneFL);
            var zoneTip = new Button()
            {
                X = Application.GetRealWidth(50),
                Height = Application.GetRealHeight(70),
                Width = Application.GetRealWidth(300),
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = 12,
                TextColor = ZigbeeColor.Current.GXCButtonTipColor,
                TextID = R.MyInternationalizationString.BelongZone,
            };
            zoneFL.AddChidren(zoneTip);
            var zone = new Button()
            {
                X = Application.GetRealWidth(50),
                Y = deviceNameTip.Bottom,
                Height = Application.GetRealHeight(100) - 1,
                Width = Application.GetRealWidth(500),
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = 20,
                TextColor = ZigbeeColor.Current.GXCTextBlackColor,
                Text = room.Name,
            };
            zoneFL.AddChidren(zone);
            var zoneRight = new Button()
            {
                X = Application.GetRealWidth(CommonPage.AppRealWidth - 150),
                Width = Application.GetMinRealAverage(110),
                Height = Application.GetMinRealAverage(110),
                UnSelectedImagePath = "Item/Next.png",
                Gravity = Gravity.CenterVertical
            };
            //zoneFL.AddChidren(zoneRight);
            var zoneLine = new Button()
            {
                Y = zone.Bottom,
                Height = 1,
                BackgroundColor = ZigbeeColor.Current.GXCLineColor
            };
            zoneFL.AddChidren(zoneLine);
 
            //添加执行目标
            var targetFL = new FrameLayout()
            {
                Y = zoneFL.Bottom,
                Height = Application.GetRealHeight(170),
            };
 
            var targetAddFL = new FrameLayout()
            {
                Y = zoneFL.Bottom,
                Height = Application.GetRealHeight(170),
            };
            midFL.AddChidren(targetFL);
           
            var target = new Button()
            {
                X = Application.GetRealWidth(50),
                Height = Application.GetRealHeight(100) - 1,
                Width = Application.GetRealWidth(500),
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = 20,
                TextColor = ZigbeeColor.Current.GXCTextBlackColor,
                TextID=R.MyInternationalizationString.AddScentTargetAction,
                Gravity=Gravity.CenterVertical
            };
            targetAddFL.AddChidren(target);
            var targetAdd = new Device.CommonForm.SelectedStatuButton()
            {
                X = Application.GetRealWidth(CommonPage.AppRealWidth - 150),
                Width = Application.GetMinRealAverage(72),
                Height = Application.GetMinRealAverage(72),
                UnSelectedImagePath = "Item/Add.png",
                SelectedImagePath="Item/AddSelected.png",
                Gravity = Gravity.CenterVertical
            };
            targetFL.AddChidren(targetAdd);
 
            var targetLine = new Button()
            {
                Y = targetFL.Height-1,
                Height = 1,
                Width=Application.GetRealWidth(965),
                Gravity=Gravity.CenterHorizontal,
                BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor2
            };
            targetFL.AddChidren(targetLine);
 
            //添加目标后的展示列表
            TargetListScrolView = new VerticalScrolViewLayout()
            {
                Y = targetFL.Bottom,
                Height = Application.GetRealHeight(TargetListScrolView_RowHeight*2),
                BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
            };
            midFL.AddChidren(TargetListScrolView);
 
            confirmBtn = new CommonForm.CompleteButton(1,2,3)
            {
                TextID = R.MyInternationalizationString.ConfirmAdd,
            };
            AddChidren(confirmBtn);
 
            RefreshTargetListView();
            if (!string.IsNullOrEmpty(SceneText))
            {
                sceneNameET.Text = SceneText;
            }
            #endregion
 
            #region event
            //记录输入场景名
            sceneNameET.TextChangeEventHandler += (sender, e) =>
            {
                SceneText = sceneNameET.Text.Trim();
            };
 
            //选择背景图
            EventHandler<MouseEventArgs> backGroundIMGHander = (sender, e) =>
            {
                var localPic = new CategorySceneSelectImgByLocal();
                Shared.Phone.UserView.HomePage.Instance.AddChidren(localPic);
                Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                localPic.Show();
                localPic.action = (imgPath) =>
                {
                    backGround.UnSelectedImagePath = imgPath;
                    IconType = 0;
                };
 
                //var selectDialog = new Dialog()
                //{
                //};
                //selectDialog.Show();
 
                //var itemFL = new FrameLayout()
                //{
                //    Y = Application.GetRealHeight(1920 - 600),
                //    Width = Application.GetRealWidth(900),
                //    Height = Application.GetRealHeight(550),
                //    Radius = CommonPage.BigFormRadius,
                //    //BackgroundColor=ZigbeeColor.Current.GXCBackgroundColor,
                //    Gravity = Gravity.CenterHorizontal
                //};
                //selectDialog.AddChidren(itemFL);
 
                //var localPicBtn = new Button()
                //{
                //    Height = Application.GetRealHeight(130) - 1,
                //    TextID = R.MyInternationalizationString.LocalPic,
                //    TextColor = ZigbeeColor.Current.GXCTextBlackColor,
                //    TextAlignment = TextAlignment.Center,
                //    BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor
                //};
                //itemFL.AddChidren(localPicBtn);
                //var localPicLine = new Button()
                //{
                //    Y = localPicBtn.Bottom,
                //    Height = 1,
                //    BackgroundColor = ZigbeeColor.Current.GXCLineColor,
                //};
                //itemFL.AddChidren(localPicLine);
 
                //var takePhotoBtn = new Button()
                //{
                //    Y = localPicLine.Bottom,
                //    Height = Application.GetRealHeight(130) - 1,
                //    TextID = R.MyInternationalizationString.TakePhoto,
                //    TextColor = ZigbeeColor.Current.GXCTextBlackColor,
                //    TextAlignment = TextAlignment.Center,
                //    BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor
                //};
                //itemFL.AddChidren(takePhotoBtn);
                //var takePhotoLine = new Button()
                //{
                //    Y = takePhotoBtn.Bottom,
                //    Height = 1,
                //    BackgroundColor = ZigbeeColor.Current.GXCLineColor,
                //};
                //itemFL.AddChidren(takePhotoLine);
 
                //var systemPicBtn = new Button()
                //{
                //    Y = takePhotoLine.Bottom,
                //    Height = Application.GetRealHeight(130),
                //    TextID = R.MyInternationalizationString.SystemPic,
                //    TextColor = ZigbeeColor.Current.GXCTextBlackColor,
                //    TextAlignment = TextAlignment.Center,
                //    BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor
                //};
                //itemFL.AddChidren(systemPicBtn);
 
                //var cancelBtn = new Button()
                //{
                //    Y = systemPicBtn.Bottom + Application.GetRealHeight(30),
                //    Height = Application.GetRealHeight(150),
                //    TextID = R.MyInternationalizationString.Cancel,
                //    TextColor = ZigbeeColor.Current.GXCTextWhiteColor,
                //    BackgroundColor = ZigbeeColor.Current.GXCButtonBlueColor,
                //    TextAlignment = TextAlignment.Center,
                //};
                //itemFL.AddChidren(cancelBtn);
 
                ////本地图库
                //localPicBtn.MouseUpEventHandler += (send, ee) =>
                //{
                //    selectDialog.Close();
                //    var localPic = new CategorySceneSelectImgByLocal();
                //    Shared.Phone.UserView.HomePage.Instance.AddChidren(localPic);
                //    Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                //    localPic.Show();
                //    localPic.action = () =>
                //    {
                //        backGround.UnSelectedImagePath = ImagePath;
                //        IconType = 0;
                //    };
                //};
                ////拍照
                //takePhotoBtn.MouseUpEventHandler += (send, ee) =>
                //{
                //    var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo);
                //    selectDialog.Close();
                //    Camera.TakePicture((obj) =>
                //    {
                //        if (obj == null)
                //        {
                //            return;
                //        }
                //        backGround.UnSelectedImagePath = $"ScenePicture{tradeTime}.png";
                //        ImagePath = $"{Config.Instance.HomeId}/{backGround.UnSelectedImagePath}";
                //        IconType = 1;
                //    }, $"ScenePicture{tradeTime}.png");
                //};
                ////系统图库
                //systemPicBtn.MouseUpEventHandler += (send, ee) =>
                //{
                //    var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo);
                //    selectDialog.Close();
                //    Camera.SelectPicture((obj) =>
                //    {
                //        if (obj == null)
                //        {
                //            return;
                //        }
                //        backGround.UnSelectedImagePath = $"ScenePicture{tradeTime}.png";
                //        ImagePath = $"{Config.Instance.HomeId}/{backGround.UnSelectedImagePath}";
                //        IconType = 2;
                //    }, $"ScenePicture{tradeTime}.png");
                //};
                //cancelBtn.MouseUpEventHandler += (send, ee) =>
                //{
                //    selectDialog.Close();
                //};
            };
            backGround.MouseUpEventHandler += backGroundIMGHander;
            //区域
            EventHandler<MouseEventArgs> zoneHander = (sender, e) =>
            {
 
            };
            zoneRight.MouseUpEventHandler += zoneHander;
            zoneFL.MouseUpEventHandler += zoneHander;
            zone.MouseUpEventHandler += zoneHander;
            //执行目标
            EventHandler<MouseEventArgs> targetAddHander = (sender, e) =>
            {
                int selectRow_Height = 130;
                var selectFL = new FrameLayout()
                {
                    BackgroundColor = ZigbeeColor.Current.GXCDailogBackGroundColor
                };
                AddChidren(selectFL);
 
                var itemFL = new FrameLayout()
                {
                    Y =Application.GetRealHeight(CommonPage.AppRealHeight - selectRow_Height * 4-20),
                    Height = Application.GetRealHeight(selectRow_Height * 4 + 20)
                };
                selectFL.AddChidren(itemFL);
 
                var selectedFunctionBtn = new Device.CommonForm.SelectedStatuButton()
                {
                    Height = Application.GetRealHeight(selectRow_Height) - 1,
                    TextID = R.MyInternationalizationString.Function,
                    TextColor = ZigbeeColor.Current.GXCTextBlackColor,
                    BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor,
                    SelectedBackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor
                };
                itemFL.AddChidren(selectedFunctionBtn);
                var selectedFunctionLine = new Button()
                {
                    Y = selectedFunctionBtn.Bottom,
                    Height = 1,
                    BackgroundColor = ZigbeeColor.Current.GXCLineColor,
                };
                itemFL.AddChidren(selectedFunctionLine);
 
                var selectedSceneBtn = new Device.CommonForm.SelectedStatuButton()
                {
                    Y = selectedFunctionLine.Bottom,
                    Height = Application.GetRealHeight(selectRow_Height) - 1,
                    TextID = R.MyInternationalizationString.Scence,
                    TextColor = ZigbeeColor.Current.GXCTextBlackColor,
                    BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor,
                    SelectedBackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor
                };
                itemFL.AddChidren(selectedSceneBtn);
                var selectedSceneLine = new Button()
                {
                    Y = selectedSceneBtn.Bottom,
                    Height = 1,
                    BackgroundColor = ZigbeeColor.Current.GXCLineColor,
                };
                itemFL.AddChidren(selectedSceneLine);
 
                var selectedTimerBtn = new Device.CommonForm.SelectedStatuButton()
                {
                    Y = selectedSceneLine.Bottom,
                    Height = Application.GetRealHeight(selectRow_Height) -1,
                    TextID = R.MyInternationalizationString.TimeSpan,
                    TextColor = ZigbeeColor.Current.GXCTextBlackColor,
                    BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor,
                    SelectedBackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor
                };
                itemFL.AddChidren(selectedTimerBtn);
 
                var cancelBtn = new Device.CommonForm.SelectedStatuButton()
                {
                    Y = selectedTimerBtn.Bottom + Application.GetRealHeight(20),
                    Height = Application.GetRealHeight(selectRow_Height),
                    TextID = R.MyInternationalizationString.Cancel,
                    TextColor = ZigbeeColor.Current.GXCTextBlackColor,
                    BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor,
                    SelectedBackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor
                };
                itemFL.AddChidren(cancelBtn);
 
                itemFL.Animate = Animate.DownToUp;
                //添加功能
                selectedFunctionBtn.MouseUpEventHandler += (send, ee) =>
                {
                    selectFL.RemoveFromParent();
                    var deviceTypeList = new CategorySceneSelectDevice();
                    UserView.HomePage.Instance.AddChidren(deviceTypeList);
                    UserView.HomePage.Instance.PageIndex += 1;
                    deviceTypeList.Show(sceneTargetDevicesList,true);
                };
                //添加场景
                selectedSceneBtn.MouseUpEventHandler += (send, ee) =>
                {
                    selectFL.RemoveFromParent();
                    var sceneView = new CategorySceneSelectedScene();
                    UserView.HomePage.Instance.AddChidren(sceneView);
                    UserView.HomePage.Instance.PageIndex += 1;
                    sceneView.Show(sceneTargetDevicesList,-1,"",true);
                };
                //添加时间间隔
                selectedTimerBtn.MouseUpEventHandler += (send, ee) =>
                {
                    selectFL.RemoveFromParent();
                    var delayTimeView = new SelectDelayTime();
                    UserView.HomePage.Instance.AddChidren(delayTimeView);
                    UserView.HomePage.Instance.PageIndex += 1;
                    //delayTimeView.Show(-1,"",-1,true);
                };
                cancelBtn.MouseUpEventHandler += (send, ee) =>
                {
                    selectFL.RemoveFromParent();
                };
                selectFL.MouseUpEventHandler += (send, ee) =>
                {
                    selectFL.RemoveFromParent();
                };
            };
            targetAdd.MouseUpEventHandler += targetAddHander;
            targetFL.MouseUpEventHandler += targetAddHander;
            target.MouseUpEventHandler += targetAddHander;
            //确定添加目标
            confirmBtn.MouseUpEventHandler += async (sender, e) =>
            {
                if (string.IsNullOrEmpty(sceneNameET.Text))
                {
                    var alert = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.SceneNameCannotBeNull), Language.StringByID(R.MyInternationalizationString.Close));
                    alert.Show();
                    alert.ResultEventHandler += (sendAlert, eAlert) =>
                    {
                        return;
                    };
                }
                else
                {
                    try
                    {
                        CommonPage.Loading.Start();
                        var memberDataList = new List<ZigBee.Device.Scene.AddSceneMemberData>();
                        //累加延时
                        int AddedDelayTime = 0;
                        for (int i = 0; i < sceneTargetDevicesList.Count; i++)
                        {
                            var sceneTarget = sceneTargetDevicesList[i];
                            SceneTargetDeviceUI beforeSceneTarget = null;
                            if (i - 1 >= 0)
                            {
                                beforeSceneTarget = sceneTargetDevicesList[i - 1];
                            }
                            if (sceneTarget.Type == 0)
                            {
                                if (beforeSceneTarget != null && beforeSceneTarget.Type == 1)
                                {
                                    {
                                        for (int k = i - 1; k >= 0; k--)
                                        {
                                            if (sceneTargetDevicesList[k] == null || sceneTargetDevicesList[k].Type != 1)
                                            {
                                                break;
                                            }
                                            AddedDelayTime += sceneTargetDevicesList[k].DelayTime;
                                        }
                                    }
                                }
                                var memberData = new ZigBee.Device.Scene.AddSceneMemberData
                                {
                                    DeviceAddr = sceneTarget.DeviceUI.CommonDevice.DeviceAddr,
                                    Type = 0,
                                    ScenesId = 0,
                                    Epoint = sceneTarget.DeviceUI.CommonDevice.DeviceEpoint,
                                    TaskList = sceneTarget.TaskList,
                                    DelayTime = AddedDelayTime
                                };
                                memberDataList.Add(memberData);
                            }
                            else if (sceneTarget.Type == 2)
                            {
 
                                if (beforeSceneTarget != null && beforeSceneTarget.Type == 1)
                                {
                                    AddedDelayTime += beforeSceneTarget.DelayTime;
                                }
                                var memberData = new ZigBee.Device.Scene.AddSceneMemberData
                                {
                                    Type = 1,
                                    ScenesId = 0,
                                    ElseScenesId = sceneTarget.ElseScenesId,
                                    DelayTime = AddedDelayTime
                                };
                                memberDataList.Add(memberData);
                            }
                        }
 
                        var result = await room.AddScene(sceneNameET.Text, backGround.UnSelectedImagePath, memberDataList, IconType);
                        if (result == 1)
                        {
                            RemoveFromParent();
                        }
                        else if (result == 0)
                        {
                            //失败
                            CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.AddSceneFail);
                        }
                        else if (result == -1)
                        {
                            //已存在
                            CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.TheSceneHadExist);
                        }
                    }
                    catch (Exception ex)
                    {
                        System.Console.WriteLine($"房间添加场景出错{ex.Message}");
                    }
                    finally
                    {
                        CommonPage.Loading.Hide();
                    }
                }
            };
            #endregion
        }
    }
}