From 3272ca5b51e19f7f8a827b0f68400570a547fe60 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期二, 28 四月 2020 15:02:44 +0800
Subject: [PATCH] 2020-04-28-1

---
 ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorBindTargetSettionForm.cs |   77 +++++++++++++++++++++++++++++++-------
 1 files changed, 62 insertions(+), 15 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorBindTargetSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorBindTargetSettionForm.cs
index f1f280b..7c3b7e4 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorBindTargetSettionForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorBindTargetSettionForm.cs
@@ -369,19 +369,26 @@
                 }
             }
 
-            //寤舵椂
-            string 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) =>
+            //寤舵椂(鍗婅嚜鍔ㄦ病鏈夊欢鏃剁殑姒傚康)
+            if (this.pirConfigure.mode == 1)
             {
-                this.ShowDelayListTime(btnDelayView);
-            };
+                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();
@@ -421,7 +428,11 @@
             this.listEsixtDevice.Clear();
             foreach (var device in listDevice)
             {
-                this.listEsixtDevice.Add(Common.LocalDevice.Current.GetDeviceMainKeys(device));
+                string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
+                if (listEsixtDevice.Contains(mainKeys) == false)
+                {
+                    listEsixtDevice.Add(mainKeys);
+                }
             }
             //鑾峰彇PIR浼犳劅鍣ㄧ殑銆愬厜鎰熺瓑绾ф�诲埢搴︺��
             this.lightLevelCount = await HdlDevicePirSensorLogic.Current.GetPirLightAbilitySize(this.deviceIASZone);
@@ -549,11 +560,18 @@
             {
                 //鍒犻櫎缁戝畾鐩爣
                 var listDelDevice = new List<CommonDevice>();
+                var listLightDevice = new List<CommonDevice>();
                 foreach (string mainKey in listEsixtDevice)
                 {
                     if (this.listSaveDevice.Contains(mainKey) == false)
                     {
-                        listDelDevice.Add(Common.LocalDevice.Current.GetDevice(mainKey));
+                        var myDevice = Common.LocalDevice.Current.GetDevice(mainKey);
+                        listDelDevice.Add(myDevice);
+                        if (myDevice.Type == DeviceType.DimmableLight)
+                        {
+                            //濡傛灉鏄皟鍏夊櫒鐨勮瘽,鐗规畩涓�鐐�
+                            listLightDevice.Add(myDevice);
+                        }
                     }
                 }
                 if (listDelDevice.Count > 0)
@@ -566,12 +584,30 @@
                         this.CloseProgressBar();
                         return;
                     }
+                    if (listLightDevice.Count > 0)
+                    {
+                        //鍒犻櫎璋冨厜鍣ㄩ暈
+                        listSucess = await 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)
                 {
-                    listBind.Add(Common.LocalDevice.Current.GetDevice(mainKey));
+                    var myDevice = Common.LocalDevice.Current.GetDevice(mainKey);
+                    listBind.Add(myDevice);
+                    if (myDevice.Type == DeviceType.DimmableLight)
+                    {
+                        //濡傛灉鏄皟鍏夊櫒鐨勮瘽,鐗规畩涓�鐐�
+                        listLightDevice.Add(myDevice);
+                    }
                 }
                 if (listSaveDevice.Count > 0)
                 {
@@ -583,6 +619,17 @@
                         this.CloseProgressBar();
                         return;
                     }
+                    if (listLightDevice.Count > 0)
+                    {
+                        //缁戝畾璋冨厜闀�
+                        listSucess = await HdlDeviceBindLogic.Current.BindDeviceTarget(deviceIASZone, listLightDevice, 8);
+                        if (listSucess == null || listSucess.Count == 0)
+                        {
+                            //鍏抽棴杩涘害鏉�
+                            this.CloseProgressBar();
+                            return;
+                        }
+                    }
                 }
             }
             //淇濆瓨pir閰嶇疆淇℃伅

--
Gitblit v1.8.0