黄学彪
2019-12-30 3dcbd186c42c598c0c08d1cd37034cf2baa09e54
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
using System;
using Shared.Common;
using Shared.Phone.Device.CommonForm;
using Shared.Phone.Device.DeviceLogic;
using Shared.Phone.UserView;
using ZigBee.Device;
 
namespace Shared.Phone.Device.Curtain
{
    public class RollerShadeControl:FrameLayout,ZigBee.Common.IStatus
    {
        #region ◆ 变量__________________________
        /// <summary>
        /// The action.
        /// </summary>
        public Action action;
 
        /// <summary>
        /// 收藏按钮
        /// </summary>
        private Button collectionBtn;
        /// <summary>
        /// 传过来的设备
        /// </summary>
        private DeviceUI device;
        /// <summary>
        /// 传过来的房间
        /// </summary>
        private Shared.Common.Room room;
 
        /// <summary>
        /// 房间
        /// </summary>
        private Button roomBtn;
        /// <summary>
        /// 房间名
        /// </summary>
        private Button roomName;
        /// <summary>
        /// 网关
        /// </summary>
        private ZbGateway zbGateway = null;
        /// <summary>
        /// 是否发送控制命令成功了
        /// </summary>
        private bool sendedControlCommand = false;
 
        /// <summary>
        /// bodyFrameLayout
        /// </summary>
        private FrameLayout bodyFrameLayout;
        /// <summary>
        /// StatuBtn
        /// </summary>
        private Button StatuBtn;
 
        /// <summary>
        /// OpenOrUpBtn
        /// </summary>
        public Button OpenOrUpBtn;
        /// <summary>
        /// OpenOrUpBtn
        /// </summary>
        public Button CloseOrDownBtn;
        /// <summary>
        /// StopBtn
        /// </summary>
        public Button StopBtn;
        /// <summary>
        /// 开合帘
        /// </summary>
        private CurtainSeekBar curtainSeekBar = new CurtainSeekBar { };
        /// <summary>
        /// 卷帘
        /// </summary>
        private CurtainRollSeekBar curtainRollSeekBar = new CurtainRollSeekBar { };
 
        /// <summary>
        /// IsDrawerLockMode
        /// </summary>
        public bool IsDrawerLockMode;
 
        /// <summary>
        /// ProgressBtn
        /// </summary>
        Button ProgressBtn;
        /// <summary>
        /// ProgressBtnY
        /// </summary>
        int ProgressBtnY;
 
        #endregion
 
        #region ◆ 接口___________________________
        /// <summary>
        /// 处理变化事件 --将弃用 改用DeviceInfoChange()
        /// </summary>
        /// <returns>The changed.</returns>
        /// <param name="common">Common.</param>
        public void Changed(CommonDevice common)
        {
 
        }
        /// <summary>
        /// 设备状态更新接口
        /// <para>type:如果为 DeviceInComingRespon:设备新上报</para>
        /// <para>type:如果为 IASInfoReport:RemoveDeviceRespon</para>
        /// <para>type:如果为 DeviceStatusReport:设备上报</para>
        /// <para>type:如果为 IASInfoReport:IAS安防信息上报</para>
        /// <para>type:如果为 OnlineStatusChange: 设备在线状态更新</para>
        /// </summary>
        /// <param name="common">Common.</param>
        /// <param name="typeTag">Type tag.</param>
        public void DeviceInfoChange(CommonDevice common, string typeTag)
        {
            if (typeTag == "DeviceStatusReport")
            {
                Application.RunOnMainThread(() =>
                {
                    try
                    {
                        var deviceUI = this.device;
                        //设备为空
                        if (deviceUI.CommonDevice == null)
                        {
                            return;
                        }
                        //是否为当前设备
                        if (deviceUI.CommonDevice.DeviceEpoint != common.DeviceEpoint || deviceUI.CommonDevice.DeviceAddr != common.DeviceAddr)
                        {
                            return;
                        }
                        if (common.DeviceStatusReport.CluterID == 258)
                        {
                            if (common.DeviceStatusReport.AttriBute[0].AttributeId == 8)
                            {
                                //窗帘百分比
                                var rollerShade = deviceUI.CommonDevice as Rollershade;
                                rollerShade.DeviceStatusReport = common.DeviceStatusReport;
                                rollerShade.WcdCurrentPositionLiftPercentage = common.DeviceStatusReport.AttriBute[0].AttriButeData;
                                StatuBtn.Text = $"{Language.StringByID(R.MyInternationalizationString.Current)} { deviceUI.GetDeviceStatu()}";
                                if(rollerShade.WcdType==0)
                                {
                                    curtainRollSeekBar.Progress = rollerShade.WcdCurrentPositionLiftPercentage;
                                }
                                else if(rollerShade.WcdType==4)
                                {
                                    curtainSeekBar.Progress = rollerShade.WcdCurrentPositionLiftPercentage;
                                }
                                rollerShade.LastDateTime = DateTime.Now;
                            }
                            else if (common.DeviceStatusReport.AttriBute[0].AttributeId == 0)
                            {
                                ////窗帘类型
                                var rollerShade = device.CommonDevice as Rollershade;
                                rollerShade.DeviceStatusReport = common.DeviceStatusReport;
                                rollerShade.WcdType = common.DeviceStatusReport.AttriBute[0].AttriButeData;
                                rollerShade.LastDateTime = DateTime.Now;
                            }
                        }
                        //***新改***设备状态上报中,当CluterID=3,证明设备在线,直接标记
                        else if (common.DeviceStatusReport.CluterID == 3)
                        {
                            //var rollerShade = deviceUI.CommonDevice as Rollershade;
                            //rollerShade.IsOnline = 1;
                            //rollerShadeIMG.IsSelected = rollerShade.IsOnline == 1;
                            //rollerShade.LastDateTime = DateTime.Now;
                        }
                    }
                    catch (Exception ex)
                    {
                        System.Console.WriteLine($"Error:{ex.Message}");
                    }
                });
            }
            else if (typeTag == "OnlineStatusChange")
            {
                Application.RunOnMainThread(() =>
                {
                    try
                    {
                        //var deviceUI = SeekBar.Tag as DeviceUI;
                        ////设备为空
                        //if (deviceUI.CommonDevice == null)
                        //{
                        //    return;
                        //}
                        ////是否为当前设备
                        //if (deviceUI.CommonDevice.DeviceEpoint != common.DeviceEpoint || deviceUI.CommonDevice.DeviceAddr != common.DeviceAddr)
                        //{
                        //    return;
                        //}
                        //var rollerShade = deviceUI.CommonDevice as Rollershade;
                        //rollerShade.IsOnline = (common as Rollershade).IsOnline;
                        //rollerShadeIMG.IsSelected = rollerShade.IsOnline == 1;
                        //rollerShade.LastDateTime = DateTime.Now;
                    }
                    catch (Exception ex)
                    {
                        System.Console.WriteLine($"Error:{ex.Message}");
                    }
                });
            }
        }
        /// <summary>
        /// Changeds the IL ogic status.
        /// </summary>
        /// <param name="logic">Logic.</param>
        public void ChangedILogicStatus(ZigBee.Device.Logic logic)
        {
            //throw new NotImplementedException();
        }
        /// <summary>
        /// Changeds the IS cene status.
        /// </summary>
        /// <param name="scene">Scene.</param>
        public void ChangedISceneStatus(Scene scene)
        {
            //throw new NotImplementedException();
        }
        #endregion
 
        #region ◆ 构造方法________________________
 
        /// <summary>
        /// 构造方法
        /// </summary>
        public RollerShadeControl()
        {
            BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor;
            ZigBee.Device.ZbGateway.StatusList.Add(this);
        }
 
        #endregion
 
        #region ◆ 重写移除方法____________________
 
        /// <summary>
        /// Removes from parent.
        /// </summary>
        public override void RemoveFromParent()
        {
            UserView.HomePage.Instance.ScrollEnabled = true;
            ZigBee.Device.ZbGateway.StatusList.Remove(this);
            //action();
            //action = null;
            RemoveUpdateControlDeviceStatuAction();
            if (IsDrawerLockMode)
            {
                CommonPage.Instance.IsDrawerLockMode = false;
            }
            base.RemoveFromParent();
        }
 
        #endregion
 
        #region ◆ 显示界面________________________
 
        /// <summary>
        /// 显示界面
        /// </summary>
        /// <param name="dev">Device.</param>
        /// <param name="room">Room.</param>
        public void Show(DeviceUI dev, Shared.Common.Room room)
        {
            device = dev;
            zbGateway = this.device.CommonDevice.Gateway;
            this.room = room;
 
            AddTop();
 
            AddBodyView(device);
 
 
            var rollerShade = device.CommonDevice as ZigBee.Device.Rollershade;
            //不上非远程
            if (rollerShade.Gateway == null)
            {
                return;
            }
            if (rollerShade.Gateway.IsVirtual)
            {
                UserHomeView.ReadStatus(rollerShade, () =>
                {
                    ReadDeviceAttributeLogic.Instance.SendCurtainStatuComand(device.CommonDevice);
                });
            }
            else
            {
                //防止短时间内多次读取
                if ((DateTime.Now - rollerShade.LastDateTime).TotalSeconds > CommonPage.ReadDeviceStatuSpan)
                {
                    ReadDeviceAttributeLogic.Instance.SendCurtainStatuComand(device.CommonDevice);
                }
            }
 
            var de = Shared.Common.Room.LoveRoomDeviceUIFilePathList.Find((obj) => obj == device.FileName);
            if (de == null)
            {
                collectionBtn.IsSelected = false;
            }
            else
            {
                collectionBtn.IsSelected = true;
            }
 
 
            BindEvent();
 
        }
 
        #endregion
 
        #region ◆ Add______________________________
 
        /// <summary>
        /// AddTop
        /// </summary>
        public void AddTop()
        {
            var top = new TopFrameLayout();
            AddChidren(top);
            top.InitTopview();
            top.backButton.MouseUpEventHandler += (sender, e) =>
            {
                RemoveFromParent();
            };
 
 
            var moreBtn = new Button
            {
                X = Application.GetRealWidth(953),
                Width = Application.GetMinReal(69),
                Height = Application.GetMinReal(69),
                Gravity = Gravity.CenterVertical,
                UnSelectedImagePath = "Item/More.png"
            };
            top.topView.AddChidren(moreBtn);
 
            moreBtn.MouseUpEventHandler += More;
 
        }
        /// <summary>
        /// AddBodyView
        /// </summary>
        public void AddBodyView(DeviceUI device)
        {
            bodyFrameLayout = new FrameLayout()
            {
                Y = Application.GetRealHeight(184),
                Height = Application.GetRealHeight(1737),
                BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor,
            };
            AddChidren(bodyFrameLayout);
 
            var itemView = new FrameLayout()
            {
                Y = Application.GetRealHeight(115),
                Width = Application.GetRealWidth(965),
                Height = Application.GetRealHeight(1316),
                Radius = (uint)Application.GetRealHeight(CommonFormResouce.BigFormRadius),
                Gravity = Gravity.CenterHorizontal,
                BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
            };
            bodyFrameLayout.AddChidren(itemView);
 
            collectionBtn = new Button()
            {
                X = Application.GetRealWidth(850),
                Y = Application.GetRealHeight(46),
                Width = Application.GetMinReal(69),
                Height = Application.GetMinReal(69),
                UnSelectedImagePath = "Item/Collection.png",
                SelectedImagePath = "Item/CollectionSelected.png"
            };
            itemView.AddChidren(collectionBtn);
 
            var deviceNameBtn = new Button()
            {
                Y = Application.GetRealHeight(46),
                Width = Application.GetRealWidth(500),
                Height = Application.GetRealHeight(60),
                Gravity = Gravity.CenterHorizontal,
                Text = device.CommonDevice.DeviceEpointName,
                TextColor = ZigbeeColor.Current.GXCTextBlackColor,
                TextSize = 15
            };
            itemView.AddChidren(deviceNameBtn);
 
            StatuBtn = new Button
            {
                Y = Application.GetRealHeight(118),
                Width = Application.GetRealWidth(600),
                Height = Application.GetRealHeight(60),
                Gravity = Gravity.CenterHorizontal,
                TextColor = ZigbeeColor.Current.GXCTextGrayColor,
                Text = $"{Language.StringByID(R.MyInternationalizationString.Current)} {device.GetDeviceStatu()}"
            };
            itemView.AddChidren(StatuBtn);
 
 
            OpenOrUpBtn = new Button
            {
                X = Application.GetRealWidth(253),
                Y = Application.GetRealHeight(994),
                Width = Application.GetMinRealAverage(81),
                Height = Application.GetMinRealAverage(81)
            };
            itemView.AddChidren(OpenOrUpBtn);
            OpenOrUpBtn.MouseUpEventHandler += (sender, e) =>
            {
                (device.CommonDevice as Rollershade).CurtainUpDownStopControl(0);
            };
 
            StopBtn = new Button
            {
                X = Application.GetRealWidth(441),
                Y=Application.GetRealHeight(994),
                Width = Application.GetMinRealAverage(81),
                Height = Application.GetMinRealAverage(81),
                SelectedImagePath = "RollerShade/StopSelected.png",
                UnSelectedImagePath = "RollerShade/Stop.png",
            };
            itemView.AddChidren(StopBtn);
            StopBtn.MouseUpEventHandler += (sender, e) =>
            {
                (device.CommonDevice as Rollershade).CurtainUpDownStopControl(2);
            };
 
            CloseOrDownBtn = new Button
            {
                X = Application.GetRealWidth(631),
                Y = Application.GetRealHeight(994),
                Width = Application.GetMinRealAverage(81),
                Height = Application.GetMinRealAverage(81)
            };
            itemView.AddChidren(CloseOrDownBtn);
            CloseOrDownBtn.MouseUpEventHandler += (sender, e) =>
            {
                (device.CommonDevice as Rollershade).CurtainUpDownStopControl(1);
            };
 
            if ((device.CommonDevice as Rollershade).WcdType == -1)
            {
                CommonPage.Loading.Start();
                new System.Threading.Thread(() =>
                {
                    Rollershade.ReadWcdTypeAction(device.CommonDevice, () =>
                    {
                        Application.RunOnMainThread(() =>
                        {
                            SetRollerShadeIcon((device.CommonDevice as Rollershade).WcdType);
                            CommonPage.Loading.Hide();
                        });
                    });
                })
                { IsBackground = true }.Start();
            }
 
            SetCurtainType(itemView, (device.CommonDevice as Rollershade).WcdType);
            
            var roomBG = new Button
            {
                Y = Application.GetRealHeight(1178 - 50),
                Height = Application.GetRealHeight(138 + 50),
                BackgroundColor = ZigbeeColor.Current.GXCBlackBackgroundColor,
                Radius = (uint)Application.GetRealHeight(CommonFormResouce.BigFormRadius)
            };
            itemView.AddChidren(roomBG);
 
            var roomBG2 = new Button
            {
                Y = Application.GetRealHeight(1178 - 50),
                Height = Application.GetRealHeight(50),
                BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
            };
            itemView.AddChidren(roomBG2);
 
            roomBtn = new Button()
            {
                X = Application.GetRealWidth(CommonFormResouce.X_Left),
                Y = Application.GetRealHeight(1207),
                Width = Application.GetMinReal(80),
                Height = Application.GetMinReal(80),
                UnSelectedImagePath = "Item/Room.png"
            };
            itemView.AddChidren(roomBtn);
 
            roomName = new Button()
            {
                X = Application.GetRealWidth(150),
                Y = Application.GetRealHeight(1224),
                Width = Application.GetRealWidth(400),
                Height = Application.GetRealHeight(50),
                Text = room.Name,
                TextAlignment = TextAlignment.CenterLeft,
                TextColor = ZigbeeColor.Current.GXCTextWhiteColor
            };
            itemView.AddChidren(roomName);
        }
 
        #endregion
 
        #region ◆ 绑定事件________________________
 
        /// <summary>
        /// 绑定按钮的事件
        /// </summary>
        private void BindEvent()
        {
            //upBtn.MouseUpEventHandler += Up;
            //stopBtn.MouseUpEventHandler += Stop;
            //downBtn.MouseUpEventHandler += Down;
            collectionBtn.MouseUpEventHandler += Collection;
        }
 
        #endregion
 
        #region ◆ 控制__________________________
 
        /// <summary>
        /// 上、开
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="eventArgs">Event arguments.</param>
        private void Up(object sender, MouseEventArgs eventArgs)
        {
            sendedControlCommand = false;
            zbGateway.ReportAction += UpdateDeviceControllStatu;
            (device.CommonDevice as ZigBee.Device.Rollershade).CurtainUpDownStopControl(0);
            //控制延时回调
            DeviceUI.SendCommandDelayAction(device.CommonDevice, () =>
            {
                if (Parent == null)
                {
                    return;
                }
                RemoveUpdateControlDeviceStatuAction();
                if (sendedControlCommand == false)
                {
                    DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL);
                }
            });
        }
 
        /// <summary>
        /// 下、关
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="eventArgs">Event arguments.</param>
        private void Down(object sender, MouseEventArgs eventArgs)
        {
            sendedControlCommand = false;
            zbGateway.ReportAction += UpdateDeviceControllStatu;
            (device.CommonDevice as ZigBee.Device.Rollershade).CurtainUpDownStopControl(1);
            //控制延时回调
            DeviceUI.SendCommandDelayAction(device.CommonDevice, () =>
            {
                if (Parent == null)
                {
                    return;
                }
                RemoveUpdateControlDeviceStatuAction();
                if (sendedControlCommand == false)
                {
                    DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL);
                }
            });
        }
 
        /// <summary>
        /// 停
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="eventArgs">Event arguments.</param>
        private void Stop(object sender, MouseEventArgs eventArgs)
        {
            sendedControlCommand = false;
            zbGateway.ReportAction += UpdateDeviceControllStatu;
            (device.CommonDevice as ZigBee.Device.Rollershade).CurtainUpDownStopControl(2);
            //控制延时回调
            DeviceUI.SendCommandDelayAction(device.CommonDevice, () =>
            {
                if (Parent == null)
                {
                    return;
                }
                RemoveUpdateControlDeviceStatuAction();
                if (sendedControlCommand == false)
                {
                    DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL);
                }
            });
        }
 
        #endregion
 
        #region ◆ 控制反馈_________________________
 
        /// <summary>
        /// 显示设备控制状态
        /// </summary>
        /// <param name="command">Command.</param>
        /// <param name="objValue">Object value.</param>
        private void UpdateDeviceControllStatu(string command, object objValue)
        {
            if (command != "DeviceDefaultAck" || objValue == null)
            {
                return;
            }
            var tempDevice = (CommonDevice)objValue;
            if (tempDevice.DeviceEpoint != this.device.CommonDevice.DeviceEpoint || tempDevice.DeviceAddr != this.device.CommonDevice.DeviceAddr)
            {
                //不是当前设备的推送,则不处理
                return;
            }
            //标记已经发送控制命令到网关
            sendedControlCommand = true;
            //成功不提示
            //DeviceUI.ShowStatuTip(R.MyInternationalizationString.Success);
        }
 
        /// <summary>
        /// 移除更新控制设备的action
        /// </summary>
        private void RemoveUpdateControlDeviceStatuAction()
        {
            //移除action
            if (zbGateway != null)
            {
                zbGateway.ReportAction -= UpdateDeviceControllStatu;
            }
        }
 
        #endregion
 
        #region ◆ 更多设置________________________
 
        /// <summary>
        /// 更多设置
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        private void More(object sender, MouseEventArgs e)
        {
            var detailInfo = new Device.CommonForm.DeviceDetailInfo { };
            UserView.HomePage.Instance.AddChidren(detailInfo);
            UserView.HomePage.Instance.PageIndex += 1;
            detailInfo.Show(device, room);
            detailInfo.action = () =>
            {
                Show(device, room);
            };
        }
 
        /// <summary>
        /// SetCurtainType
        /// </summary>
        /// <param name="layout"></param>
        /// <param name="type"></param>
        private void SetCurtainType(FrameLayout layout, int type)
        {
            SetRollerShadeIcon(type);
            SetRollerSeekBar(layout, type);
        }
 
        /// <summary>
        /// WcdType=4:开合帘
        /// WcdType=0:卷帘
        /// </summary>
        /// <param name="type"></param>
        private void SetRollerShadeIcon(int type)
        {
            if (type == 0)
            {
                OpenOrUpBtn.UnSelectedImagePath = "RollerShade/Up.png";
                OpenOrUpBtn.SelectedImagePath = "RollerShade/UpSelected.png";
 
                CloseOrDownBtn.UnSelectedImagePath = "RollerShade/Down.png";
                CloseOrDownBtn.SelectedImagePath = "RollerShade/DownSelected.png";
            }
            else
            {
                OpenOrUpBtn.UnSelectedImagePath = "RollerShade/Open.png";
                OpenOrUpBtn.SelectedImagePath = "RollerShade/OpenSelected.png";
 
                CloseOrDownBtn.UnSelectedImagePath = "RollerShade/Close.png";
                CloseOrDownBtn.SelectedImagePath = "RollerShade/CloseSelected.png";
            }
        }
 
        /// <summary>
        /// SetRollerSeekBar
        /// </summary>
        /// <param name="layout"></param>
        /// <param name="type"></param>
        private void SetRollerSeekBar(FrameLayout layout,int type)
        {
            if(type == 0)
            {
                curtainRollSeekBar.Y = Application.GetRealHeight(300);
                curtainRollSeekBar.Width = Application.GetRealWidth(438);
                curtainRollSeekBar.Height = Application.GetRealHeight(576);
                curtainRollSeekBar.Gravity = Gravity.CenterHorizontal;
                curtainRollSeekBar.Progress = (device.CommonDevice as Rollershade).WcdCurrentPositionLiftPercentage;
                layout.AddChidren(curtainRollSeekBar);
                curtainRollSeekBar.IsProgressTextShow = false;
                curtainRollSeekBar.CurtainPaddingTop = Application.GetRealHeight(110);
                curtainRollSeekBar.OnStopTrackingTouchEvent += (sender, e) =>
                {
                    (device.CommonDevice as Rollershade).WcdGoToTiltValue(curtainRollSeekBar.Progress);
                };
 
                curtainRollSeekBar.OnStartTrackingTouchEvent += (sender, e) =>
                {
                    OnProgressButtonMove(curtainRollSeekBar.Progress);
                    ProgressBtn.Visible = true;
                };
 
                curtainRollSeekBar.OnStopTrackingTouchEvent += (sender, e) =>
                {
                    ProgressBtn.Visible = false;
                };
 
                curtainRollSeekBar.OnProgressChangedEvent += (send2, e2) =>
                {
 
                    OnProgressButtonMove(e2);
 
                    //判断是否300ms屏蔽
                    //if (curtainRollSeekBar.IsProgressChangeDelay()) return;
 
                    //(device.CommonDevice as Rollershade).WcdGoToTiltValue(curtainRollSeekBar.Progress);
                };
 
                InitProgressBtn(layout);
            }
            else
            {
                curtainSeekBar.Y = Application.GetRealHeight(334);
                curtainSeekBar.Width = Application.GetRealWidth(570);
                curtainSeekBar.Height = Application.GetRealHeight(513);
                curtainSeekBar.Gravity = Gravity.CenterHorizontal;
                curtainSeekBar.Progress = (device.CommonDevice as Rollershade).WcdCurrentPositionLiftPercentage;
                layout.AddChidren(curtainSeekBar);
 
                curtainSeekBar.OnStopTrackingTouchEvent += (sender, e) =>
                {
                    (device.CommonDevice as Rollershade).WcdGoToTiltValue(curtainSeekBar.Progress);
                };
            }
        }
 
        /// <summary>
        /// 添加进度按钮
        /// </summary>
        private void InitProgressBtn(FrameLayout layout)
        {
            ProgressBtnY = curtainRollSeekBar.Y - Application.GetMinReal(204);
            ProgressBtn = new Button()
            {
                Y = ProgressBtnY,
                Width = Application.GetMinReal(135),
                Height = Application.GetMinReal(104),
                UnSelectedImagePath = "Item/ProgressBubbles.png",
                Visible = false,
                Gravity = Gravity.CenterHorizontal
            };
            layout.AddChidren(ProgressBtn);
        }
 
        /// <summary>
        /// OnProgressButtonMove
        /// </summary>
        private void OnProgressButtonMove(int mProgress)
        {
            ProgressBtn.Y = ProgressBtnY + curtainRollSeekBar.NowProgressY;
            ProgressBtn.Text = mProgress + "%";
        }
 
        #endregion
 
        #region ◆ 收藏到主页_______________________
 
        /// <summary>
        /// 收藏到主页
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        private void Collection(object sender, MouseEventArgs e)
        {
            if (collectionBtn.IsSelected)
            {
                Common.Room.CurrentRoom.GetLoveRoom().DeleteDevice(device.FileName);
                collectionBtn.IsSelected = false;
            }
            else
            {
                Common.Room.CurrentRoom.GetLoveRoom().AddDevice(device.FileName);
                collectionBtn.IsSelected = true;
            }
        }
 
        #endregion
 
        #region ◆ 回到主页________________________
 
        /// <summary>
        /// 回到主页
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param>
        private void BackToRoomHandler(object sender, MouseEventArgs mouseEventArgs)
        {
            //backToRoom
 
        }
 
        #endregion
 
    }
}