From cc0d80c7d86c6d0167269b3408c4b30c24ce84e9 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期一, 23 三月 2020 16:55:37 +0800
Subject: [PATCH] ???????

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

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorBindTargetSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorBindTargetSettionForm.cs
index dfd70e0..29fe305 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorBindTargetSettionForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorBindTargetSettionForm.cs
@@ -52,7 +52,7 @@
         /// <param name="i_iasZone">浼犳劅鍣ㄨ澶�</param>
         public void ShowForm(IASZone i_iasZone)
         {
-            UserView.HomePage.Instance.ScrollEnabled = false;
+            this.ScrollEnabled = false;
             deviceIASZone = i_iasZone;
 
             //璁剧疆澶撮儴淇℃伅
@@ -94,11 +94,29 @@
             this.ClearBodyFrame();
 
             //褰撳墠浜害鍊�
+            string txtValue = Language.StringByID(R.MyInternationalizationString.uNowBrightnessValue);
             var frameNowLinght = new FrameRowControl();
             frameNowLinght.UseClickStatu = false;
             frameNowLinght.BackgroundColor = UserCenterColor.Current.White;
             bodyFrameLayout.AddChidren(frameNowLinght);
-            frameNowLinght.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uNowBrightnessValue) + "锛�" + pirLuxValue + "lux", 900);
+            var btnLux = frameNowLinght.AddLeftCaption(txtValue + "锛�" + pirLuxValue + "lux", 900);
+            HdlThreadLogic.Current.RunThread(async () =>
+            {
+                while (this.Parent != null)
+                {
+                    //浠栦滑璇磋繖涓笢瑗胯2绉掑埛鏂颁竴娆�  鑾峰彇PIR浼犳劅鍣ㄧ殑銆恖ux鍊笺��
+                    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);
@@ -352,7 +370,11 @@
             }
 
             //寤舵椂
-            string strMinute = pirConfigure.transitionTime / 60 + Language.StringByID(R.MyInternationalizationString.uMinute);
+            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;
@@ -403,7 +425,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);
@@ -531,11 +557,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)
@@ -548,12 +581,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)
                 {
@@ -564,6 +615,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;
+                        }
                     }
                 }
             }
@@ -588,15 +650,6 @@
         #endregion
 
         #region 鈻� 涓�鑸柟娉昣__________________________
-
-        /// <summary>
-        /// 鐣岄潰鍏抽棴
-        /// </summary>
-        public override void CloseFormBefore()
-        {
-            UserView.HomePage.Instance.ScrollEnabled = true;
-            base.CloseFormBefore();
-        }
 
         #endregion
     }

--
Gitblit v1.8.0