黄学彪
2020-09-22 ade5917841b0fdcb1df7353ef7c56b1a1bdc9282
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
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using ZigBee.Device;
 
namespace Shared.Phone.UserCenter.DevicePirSensor
{
    /// <summary>
    /// PIR传感器绑定界面★
    /// </summary>
    public class PirSensorBindTargetSettionForm : EditorCommonForm
    {
        #region ■ 变量声明___________________________
 
        /// <summary>
        /// 传感器设备
        /// </summary>
        private IASZone deviceIASZone = null;
        /// <summary>
        /// 已经存在的绑定设备
        /// </summary>
        private List<string> listEsixtDevice = new List<string>();
        /// <summary>
        /// 需要保存的设备对象
        /// </summary>
        private List<string> listSaveDevice = null;
        /// <summary>
        /// PIR传感器光照等级总刻度
        /// </summary>
        private int lightLevelCount = -1;
        /// <summary>
        /// PIR传感器的Lux值
        /// </summary>
        private int pirLuxValue = -1;
        /// <summary>
        /// pir的配置信息
        /// </summary>
        private IASZone.ConfigureParamates pirConfigure = null;
        /// <summary>
        /// 数据是否改变
        /// </summary>
        private bool isDataChanged = false;
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        /// <param name="i_iasZone">传感器设备</param>
        public void ShowForm(IASZone i_iasZone)
        {
            this.ScrollEnabled = false;
            deviceIASZone = i_iasZone;
 
            //设置头部信息
            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uBindTargets));
 
            HdlThreadLogic.Current.RunThread(() =>
            {
                //初始化中部信息
                this.InitMiddleFrame();
            });
        }
 
        /// <summary>
        /// 初始化中部信息
        /// </summary>
        private async void InitMiddleFrame()
        {
            this.listEsixtDevice.Clear();
 
            var result = await this.GetDeviceAllDefultData();
            if (result == false)
            {
                return;
            }
 
            HdlThreadLogic.Current.RunMain(() =>
            {
                //初始化控件
                this.InitMiddleControl();
            });
        }
 
        /// <summary>
        /// 初始化控件
        /// </summary>
        private void InitMiddleControl()
        {
            //清空bodyFrame
            this.ClearBodyFrame();
 
            //当前亮度值
            string txtValue = Language.StringByID(R.MyInternationalizationString.uNowBrightnessValue);
            var frameNowLinght = new FrameRowControl();
            frameNowLinght.UseClickStatu = false;
            frameNowLinght.BackgroundColor = UserCenterColor.Current.White;
            bodyFrameLayout.AddChidren(frameNowLinght);
            var btnLux = frameNowLinght.AddLeftCaption(txtValue + ":" + pirLuxValue + "lux", 900);
            HdlThreadLogic.Current.RunThread(async () =>
            {
                while (this.Parent != null)
                {
                    //他们说这个东西要2秒刷新一次  获取PIR传感器的【lux值】
                    this.pirLuxValue = await HdlDevicePirSensorLogic.Current.GetPirSensorLux(deviceIASZone, ShowErrorMode.NO);
                    if (pirLuxValue != -1)
                    {
                        HdlThreadLogic.Current.RunMain(() =>
                        {
                            btnLux.Text = txtValue + ":" + pirLuxValue + "lux";
                        }, ShowErrorMode.NO);
                    }
                    await Task.Delay(2000);
                }
            }, ShowErrorMode.NO);
 
 
            var listView = new VerticalListControl(0);
            listView.Y = Application.GetRealHeight(150);
            listView.Height = Application.GetRealHeight(585);
            listView.BackgroundColor = UserCenterColor.Current.White;
            bodyFrameLayout.AddChidren(listView);
 
            //照明等级Frame(因展开折叠,优先声明)
            var frameLight = new FrameLayout();
            frameLight.Height = 0;
 
            //如果满足低亮度环境
            var frameIfRow = new FrameRowControl(listView.rowSpace / 2);
            frameIfRow.UseClickStatu = false;
            listView.AddChidren(frameIfRow);
            frameIfRow.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uIfTheLowBrightnessEnvironmentIsSatisfied), 700);
            //开关按钮
            var btnSwitch = frameIfRow.AddMostRightSwitchIcon();
            btnSwitch.IsSelected = this.pirConfigure.levelEnable;
            btnSwitch.ButtonClickEvent += (sender, e) =>
            {
                this.isDataChanged = true;
                this.pirConfigure.levelEnable = !btnSwitch.IsSelected;
                btnSwitch.IsSelected = this.pirConfigure.levelEnable;
                //展开折叠
                if (frameLight.Height > 10)
                {
                    frameLight.Height = 0;
                    listView.Height -= Application.GetRealHeight(558);
                }
                else
                {
                    frameLight.Height = Application.GetRealHeight(558);
                    listView.Height += Application.GetRealHeight(558);
                }
            };
            //底线
            frameIfRow.AddBottomLine();
            if (btnSwitch.IsSelected == true)
            {
                frameLight.Height = Application.GetRealHeight(558);
                listView.Height += Application.GetRealHeight(558);
            }
 
            listView.AddChidren(frameLight);
            //照度值
            var btnLightView = new NormalViewControl(500, 50, true);
            btnLightView.TextID = R.MyInternationalizationString.uIlluminationValue;
            btnLightView.TextSize = 12;
            btnLightView.TextColor = UserCenterColor.Current.TextGrayColor1;
            btnLightView.X = ControlCommonResourse.XXLeft;
            btnLightView.Y = Application.GetRealHeight(71);
            frameLight.AddChidren(btnLightView);
            var btnLightValue = new NormalViewControl(200, 50, true);
            btnLightValue.Y = btnLightView.Y;
            btnLightValue.X = Application.GetRealWidth(196);
            btnLightValue.TextSize = 12;
            btnLightValue.TextColor = UserCenterColor.Current.TextGrayColor1;
            btnLightValue.Text = this.pirConfigure.levelSize.ToString() + "lux";
            frameLight.AddChidren(btnLightValue);
 
            //进度条
            var seekBar = new SeekBarControl(940);
            seekBar.Gravity = Gravity.Frame;
            seekBar.X = Application.GetRealWidth(80);
            seekBar.Y = Application.GetRealHeight(159);
            seekBar.MaxValue = lightLevelCount;
            seekBar.ProgressBarColor = 0xfffdb500;
            frameLight.AddChidren(seekBar);
            seekBar.ProgressChangedEvent += (div, value) =>
            {
                this.isDataChanged = true;
                this.pirConfigure.levelSize = value;
                btnLightValue.Text = this.pirConfigure.levelSize.ToString() + "lux";
            };
            seekBar.Progress = pirConfigure.levelSize;
 
            //减号
            var btnMinus = new IconViewControl(104);
            btnMinus.UseClickStatu = true;
            btnMinus.X = Application.GetRealWidth(847);
            btnMinus.Y = Application.GetRealHeight(45);
            btnMinus.UnSelectedImagePath = "Item/MinusSign2.png";
            btnMinus.SelectedImagePath = "Item/MinusSign2Selected.png";
            frameLight.AddChidren(btnMinus);
            btnMinus.ButtonClickEvent += (sender, e) =>
            {
                if (seekBar.Progress <= 0)
                {
                    return;
                }
                this.isDataChanged = true;
                seekBar.Progress -= 1;
                this.pirConfigure.levelSize = seekBar.Progress;
                btnLightValue.Text = this.pirConfigure.levelSize.ToString() + "lux";
            };
 
            //加号
            var btnPlus = new IconViewControl(104);
            btnPlus.UseClickStatu = true;
            btnPlus.X = btnMinus.Right;
            btnPlus.Y = btnMinus.Y;
            btnPlus.UnSelectedImagePath = "Item/PlusSign2.png";
            btnPlus.SelectedImagePath = "Item/PlusSign2Selected.png";
            frameLight.AddChidren(btnPlus);
            btnPlus.ButtonClickEvent += (sender, e) =>
            {
                if (seekBar.Progress >= 100)
                {
                    return;
                }
                this.isDataChanged = true;
                seekBar.Progress += 1;
                this.pirConfigure.levelSize = seekBar.Progress;
                btnLightValue.Text = this.pirConfigure.levelSize.ToString() + "lux";
            };
 
            //暗
            var btnDark = new NormalViewControl(120, 50, true);
            btnDark.TextID = R.MyInternationalizationString.uDark;
            btnDark.TextSize = 12;
            btnDark.TextAlignment = TextAlignment.Center;
            btnDark.TextColor = UserCenterColor.Current.TextGrayColor3;
            btnDark.X = Application.GetRealWidth(70);
            btnDark.Y = seekBar.Bottom;
            frameLight.AddChidren(btnDark);
            var btnZero = new NormalViewControl(120, 50, true);
            btnZero.X = btnDark.X;
            btnZero.Y = btnDark.Bottom;
            btnZero.TextSize = 12;
            btnZero.TextAlignment = TextAlignment.Center;
            btnZero.TextColor = UserCenterColor.Current.TextGrayColor3;
            btnZero.Text = "0lux";
            frameLight.AddChidren(btnZero);
 
            //亮
            var btnBright = new NormalViewControl(120, 50, true);
            btnBright.TextID = R.MyInternationalizationString.uBright;
            btnBright.TextSize = 12;
            btnBright.TextAlignment = TextAlignment.Center;
            btnBright.TextColor = UserCenterColor.Current.TextGrayColor3;
            btnBright.X = frameLight.Width - Application.GetRealWidth(120 + 50);
            btnBright.Y = btnDark.Y;
            frameLight.AddChidren(btnBright);
            var btnPersent = new NormalViewControl(120, 50, true);
            btnPersent.X = btnBright.X;
            btnPersent.Y = btnBright.Bottom;
            btnPersent.TextSize = 12;
            btnPersent.TextAlignment = TextAlignment.Center;
            btnPersent.TextColor = UserCenterColor.Current.TextGrayColor3;
            btnPersent.Text = "100lux";
            frameLight.AddChidren(btnPersent);
 
            var btnIcon = new IconViewControl(58);
            btnIcon.X = Application.GetRealWidth(109);
            btnIcon.Y = Application.GetRealHeight(431);
            btnIcon.UnSelectedImagePath = "Item/Tips.png";
            frameLight.AddChidren(btnIcon);
            //在室内条件下,黄昏照度值约为10lux,阴天照度值约为5~50lux,请根据实际需要进行调节
            var btnTipView = new NormalViewControl(790, 100, true);
            btnTipView.TextColor = UserCenterColor.Current.TextGrayColor1;
            btnTipView.TextSize = 12;
            btnTipView.IsMoreLines = true;
            btnTipView.TextAlignment = TextAlignment.Center;
            btnTipView.TextID = R.MyInternationalizationString.uPirBrightnessTipMsg;
            btnTipView.X = btnIcon.Right + Application.GetRealWidth(23);
            btnTipView.Y = btnIcon.Y;
            frameLight.AddChidren(btnTipView);
 
            //底线
            var btnIfLine = new NormalViewControl(frameLight.Width, ControlCommonResourse.BottomLineHeight, false);
            btnIfLine.Y = frameLight.Height - ControlCommonResourse.BottomLineHeight;
            btnIfLine.BackgroundColor = UserCenterColor.Current.ButtomLine;
            frameLight.AddChidren(btnIfLine);
 
            //执行对象的Frame(因展开折叠,优先声明)
            var frameResult = new FrameListControl(29);
            frameResult.Height = Application.GetRealHeight(310);
 
            //就会--------------------------------------------------
            listView.rowSpace = Application.GetRealHeight(20);//切换间距
            var frameDo = new FrameRowControl(listView.rowSpace / 2);
            frameDo.UseClickStatu = false;
            listView.AddChidren(frameDo);
            frameDo.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uResultDo), 600);
            //右箭头
            var btnResultRight = frameDo.AddMostRightEmptyIcon(58, 58);
            frameDo.ChangedChidrenBindMode(btnResultRight, ChidrenBindMode.NotBind);
            btnResultRight.UseClickStatu = false;
            btnResultRight.UnSelectedImagePath = "Item/RightNext.png";
            btnResultRight.SelectedImagePath = "Item/Down.png";
            btnResultRight.IsSelected = true;
            btnResultRight.ButtonClickEvent += (sender, e) =>
            {
                btnResultRight.IsSelected = !btnResultRight.IsSelected;
                //展开折叠
                if (frameResult.Height > 10)
                {
                    frameResult.Height = 0;
                    listView.Height -= Application.GetRealHeight(310);
                }
                else
                {
                    frameResult.Height = Application.GetRealHeight(310);
                    listView.Height += Application.GetRealHeight(310);
                }
            };
            //底线
            frameDo.AddBottomLine();
 
            listView.AddChidren(frameResult);
            //触发目标
            var rowTarget = new FrameRowControl(listView.rowSpace / 2);
            rowTarget.LeftOffset = Application.GetRealWidth(138) - ControlCommonResourse.XXLeft;
            frameResult.AddChidren(rowTarget);
            rowTarget.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uTriggerTarget), 600);
            rowTarget.AddRightArrow();
            rowTarget.AddBottomLine();
            var btnTargetView = rowTarget.AddMostRightView("", 700);
            rowTarget.ButtonClickEvent += (sender, e) =>
            {
                var form = new PirSensorTargetSelectForm();
                form.AddForm(listSaveDevice == null ? listEsixtDevice : listSaveDevice);
                form.FinishSelectEvent += (listSelect) =>
                {
                    listSaveDevice = new List<string>();
                    listSaveDevice.AddRange(listSelect);
                    if (listSaveDevice.Count > 0)
                    {
                        //随便丢一个名字上去
                        var device = Common.LocalDevice.Current.GetDevice(listSaveDevice[0]);
                        btnTargetView.Text = Common.LocalDevice.Current.GetDeviceEpointName(device);
                    }
                    else
                    {
                        btnTargetView.Text = string.Empty;
                    }
                    this.isDataChanged = true;
                };
            };
 
            foreach (string mainkey in this.listEsixtDevice)
            {
                var device = Common.LocalDevice.Current.GetDevice(mainkey);
                if (device != null)
                {
                    //随便丢一个名字上去
                    btnTargetView.Text = Common.LocalDevice.Current.GetDeviceEpointName(device);
                    break;
                }
            }
 
            //延时(半自动没有延时的概念)
            if (this.pirConfigure.mode == 1)
            {
                string strMinute = string.Empty;
                if (pirConfigure.transitionTime / 60 > 0)
                {
                    strMinute = pirConfigure.transitionTime / 60 + Language.StringByID(R.MyInternationalizationString.uMinute);
                }
                string strSecond = pirConfigure.transitionTime % 60 + Language.StringByID(R.MyInternationalizationString.uSecond);
                var rowDelay = new FrameRowControl(listView.rowSpace / 2);
                rowDelay.LeftOffset = Application.GetRealWidth(138) - ControlCommonResourse.XXLeft;
                frameResult.AddChidren(rowDelay);
                rowDelay.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uDelayed), 300);
                rowDelay.AddRightArrow();
                var btnDelayView = rowDelay.AddMostRightView(strMinute + strSecond, 700);
                rowDelay.ButtonClickEvent += (sender, e) =>
                {
                    this.ShowDelayListTime(btnDelayView);
                };
            }
 
            //保存
            var btnSave = new BottomClickButton();
            btnSave.TextID = R.MyInternationalizationString.uSave;
            bodyFrameLayout.AddChidren(btnSave);
            btnSave.ButtonClickEvent += (sender, e) =>
            {
                HdlThreadLogic.Current.RunThread(() =>
                {
                    //保存Pir传感器数据
                    this.SavePirSensorData();
                });
            };
        }
 
        #endregion
 
        #region ■ 获取初始数据_______________________
 
        /// <summary>
        /// 获取初始数据
        /// </summary>
        /// <returns></returns>
        private async Task<bool> GetDeviceAllDefultData()
        {
            //打开进度条
            this.ShowProgressBar();
 
            //获取绑定目标设备
            List<CommonDevice> listDevice = HdlDeviceBindLogic.Current.GetBindTargetDevice(this.deviceIASZone);
            if (listDevice == null)
            {
                //关闭进度条
                this.CloseProgressBar(ShowReLoadMode.YES);
                return false;
            }
            this.listEsixtDevice.Clear();
            foreach (var device in listDevice)
            {
                string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
                if (listEsixtDevice.Contains(mainKeys) == false)
                {
                    listEsixtDevice.Add(mainKeys);
                }
            }
            //获取PIR传感器的【光感等级总刻度】
            this.lightLevelCount = await HdlDevicePirSensorLogic.Current.GetPirLightAbilitySize(this.deviceIASZone);
            if (lightLevelCount == -1)
            {
                //关闭进度条
                this.CloseProgressBar(ShowReLoadMode.YES);
                return false;
            }
            if (lightLevelCount > 100)
            {
                lightLevelCount = 100;
            }
 
            //获取pir的配置信息
            this.pirConfigure = HdlDevicePirSensorLogic.Current.GetPirSensorLightSettion(deviceIASZone);
            if (pirConfigure == null)
            {
                //关闭进度条
                this.CloseProgressBar(ShowReLoadMode.YES);
                return false;
            }
            //获取PIR传感器的【lux值】
            this.pirLuxValue = await HdlDevicePirSensorLogic.Current.GetPirSensorLux(deviceIASZone);
            if (pirLuxValue == -1)
            {
                //关闭进度条
                this.CloseProgressBar(ShowReLoadMode.YES);
                return false;
            }
 
            //关闭进度条
            this.CloseProgressBar();
 
            return true;
        }
 
        #endregion
 
        #region ■ 显示延时时间_______________________
 
        /// <summary>
        /// 显示延时时间列表
        /// </summary>
        /// <param name="btnTime"></param>
        private void ShowDelayListTime(NormalViewControl btnTime)
        {
            //分
            string strMinute = Language.StringByID(R.MyInternationalizationString.uMinute);
            //秒
            string strSecond = Language.StringByID(R.MyInternationalizationString.uSecond);
            var listfirst = new List<string>();
            var listSecond = new List<List<string>>();
            for (int i = 0; i <= 29; i++)
            {
                listfirst.Add(i.ToString().PadLeft(2, '0') + strMinute);
                var listTemp = new List<string>();
                for (int j = 0; j <= 59; j++)
                {
                    if (i == 0 && j == 0)
                    {
                        continue;
                    }
                    listTemp.Add(j.ToString().PadLeft(2, '0') + strSecond);
                }
                listSecond.Add(listTemp);
            }
            //加一个30分钟吧
            listfirst.Add("30" + strMinute);
            var listTemp2 = new List<string>() { "00" + strSecond };
            listSecond.Add(listTemp2);
 
            string value = (this.pirConfigure.transitionTime / 60).ToString().PadLeft(2, '0') + strMinute;
            int index1 = listfirst.IndexOf(value);
            if (index1 == -1)
            {
                index1 = 0;
            }
            value = (this.pirConfigure.transitionTime % 60).ToString().PadLeft(2, '0') + strSecond;
            int index2 = listSecond[index1].IndexOf(value);
            if (index2 == -1)
            {
                index2 = 0;
            }
 
            PickerView.ShowSecondary(listfirst, listSecond, (value1, value2) =>
             {
                 btnTime.Text = listfirst[value1].TrimStart('0') + listSecond[value1][value2];
                 int minute = Convert.ToInt32(listfirst[value1].Substring(0, 2));
                 int second = Convert.ToInt32(listSecond[value1][value2].Substring(0, 2));
                 int delaySecond = minute * 60 + second;
                 //更改数值
                 this.pirConfigure.transitionTime = delaySecond;
                 this.isDataChanged = true;
             },
             index1, index2,
             Language.StringByID(R.MyInternationalizationString.uDelayed),
             Language.StringByID(R.MyInternationalizationString.uFinish),
             Language.StringByID(R.MyInternationalizationString.uCancel));
        }
 
        #endregion
 
        #region ■ 数据保存___________________________
 
        /// <summary>
        /// 保存Pir传感器数据
        /// </summary>
        private void SavePirSensorData()
        {
            if (this.isDataChanged == false)
            {
                HdlThreadLogic.Current.RunMain(() =>
                {
                    //数据没有变更过,关闭界面
                    this.CloseForm();
                });
                return;
            }
 
            //打开进度条
            this.ShowProgressBar();
 
            if (listSaveDevice != null)
            {
                //删除绑定目标
                var listDelDevice = new List<CommonDevice>();
                var listLightDevice = new List<CommonDevice>();
                foreach (string mainKey in listEsixtDevice)
                {
                    if (this.listSaveDevice.Contains(mainKey) == false)
                    {
                        var myDevice = Common.LocalDevice.Current.GetDevice(mainKey);
                        listDelDevice.Add(myDevice);
                        if (myDevice.Type == DeviceType.DimmableLight)
                        {
                            //如果是调光器的话,特殊一点
                            listLightDevice.Add(myDevice);
                        }
                    }
                }
                if (listDelDevice.Count > 0)
                {
                    //删除目标
                    var listSucess = HdlDeviceBindLogic.Current.DeleteDeviceTarget(deviceIASZone, listDelDevice);
                    if (listSucess == null || listSucess.Count == 0)
                    {
                        //关闭进度条
                        this.CloseProgressBar();
                        return;
                    }
                    if (listLightDevice.Count > 0)
                    {
                        //删除调光器镞
                        listSucess = HdlDeviceBindLogic.Current.DeleteDeviceTarget(deviceIASZone, listLightDevice, 8);
                        if (listSucess == null || listSucess.Count == 0)
                        {
                            //关闭进度条
                            this.CloseProgressBar();
                            return;
                        }
                    }
                }
                //绑定目标
                var listBind = new List<CommonDevice>();
                listLightDevice = new List<CommonDevice>();
                foreach (var mainKey in listSaveDevice)
                {
                    var myDevice = Common.LocalDevice.Current.GetDevice(mainKey);
                    listBind.Add(myDevice);
                    if (myDevice.Type == DeviceType.DimmableLight)
                    {
                        //如果是调光器的话,特殊一点
                        listLightDevice.Add(myDevice);
                    }
                }
                if (listSaveDevice.Count > 0)
                {
                    //绑定目标
                    var listSucess = HdlDeviceBindLogic.Current.BindDeviceTarget(deviceIASZone, listBind);
                    if (listSucess == null || listSucess.Count == 0)
                    {
                        //关闭进度条
                        this.CloseProgressBar();
                        return;
                    }
                    if (listLightDevice.Count > 0)
                    {
                        //绑定调光镞
                        listSucess = HdlDeviceBindLogic.Current.BindDeviceTarget(deviceIASZone, listLightDevice, 8);
                        if (listSucess == null || listSucess.Count == 0)
                        {
                            //关闭进度条
                            this.CloseProgressBar();
                            return;
                        }
                    }
                }
            }
            //保存pir配置信息
            var result = HdlDevicePirSensorLogic.Current.SetPirSensorSettion(this.deviceIASZone, this.pirConfigure);
            if (result == false)
            {
                //关闭进度条
                this.CloseProgressBar();
                return;
            }
            //关闭进度条
            this.CloseProgressBar();
 
            HdlThreadLogic.Current.RunMain(() =>
            {
                //界面关闭
                this.CloseForm();
            });
        }
 
        #endregion
 
        #region ■ 一般方法___________________________
 
        #endregion
    }
}