From 9f326f4000847e6167d8166fa2f6a66f53cb3734 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期四, 17 十二月 2020 09:07:13 +0800
Subject: [PATCH] 新云端Ver1.3

---
 ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorBindTargetSettionForm.cs |  165 ++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 120 insertions(+), 45 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorBindTargetSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorBindTargetSettionForm.cs
index f1f280b..34762cb 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorBindTargetSettionForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorBindTargetSettionForm.cs
@@ -44,31 +44,31 @@
 
         #endregion
 
-        #region 鈻� 鍒濆鍖朹____________________________
+        #region 鈻� 鍒濆鍖朹____________________________
 
         /// <summary>
         /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓)
         /// </summary>
-        /// <param name="i_iasZone">浼犳劅鍣ㄨ澶�</param>
-        public void ShowForm(IASZone i_iasZone)
+        /// <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(() =>
+            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uBindTargets));
+
+            HdlThreadLogic.Current.RunThread(() =>
             {
                 //鍒濆鍖栦腑閮ㄤ俊鎭�
                 this.InitMiddleFrame();
-            });
-        }
-
-        /// <summary>
-        /// 鍒濆鍖栦腑閮ㄤ俊鎭�
-        /// </summary>
-        private async void InitMiddleFrame()
+            });
+        }
+
+        /// <summary>
+        /// 鍒濆鍖栦腑閮ㄤ俊鎭�
+        /// </summary>
+        private async void InitMiddleFrame()
         {
             this.listEsixtDevice.Clear();
 
@@ -82,7 +82,7 @@
             {
                 //鍒濆鍖栨帶浠�
                 this.InitMiddleControl();
-            });
+            });
         }
 
         /// <summary>
@@ -102,6 +102,11 @@
             var btnLux = frameNowLinght.AddLeftCaption(txtValue + "锛�" + pirLuxValue + "lux", 900);
             HdlThreadLogic.Current.RunThread(async () =>
             {
+                //鏌ョ湅妯℃澘鏃�,涓嶅厑璁哥紪杈�
+                if (Common.Config.Instance.Home.IsShowTemplate == true)
+                {
+                    return;
+                }
                 while (this.Parent != null)
                 {
                     //浠栦滑璇磋繖涓笢瑗胯2绉掑埛鏂颁竴娆�  鑾峰彇PIR浼犳劅鍣ㄧ殑銆恖ux鍊笺��
@@ -167,7 +172,7 @@
             btnLightView.TextID = R.MyInternationalizationString.uIlluminationValue;
             btnLightView.TextSize = 12;
             btnLightView.TextColor = UserCenterColor.Current.TextGrayColor1;
-            btnLightView.X = ControlCommonResourse.XXLeft;
+            btnLightView.X = HdlControlResourse.XXLeft;
             btnLightView.Y = Application.GetRealHeight(71);
             frameLight.AddChidren(btnLightView);
             var btnLightValue = new NormalViewControl(200, 50, true);
@@ -233,6 +238,14 @@
                 this.pirConfigure.levelSize = seekBar.Progress;
                 btnLightValue.Text = this.pirConfigure.levelSize.ToString() + "lux";
             };
+            //鏌ョ湅妯℃澘鏃�,涓嶅厑璁哥紪杈�
+            if (Common.Config.Instance.Home.IsShowTemplate == true)
+            {
+                btnSwitch.CanClick = false;
+                seekBar.Enable = false;
+                btnMinus.CanClick = false;
+                btnPlus.CanClick = false;
+            }
 
             //鏆�
             var btnDark = new NormalViewControl(120, 50, true);
@@ -287,8 +300,8 @@
             frameLight.AddChidren(btnTipView);
 
             //搴曠嚎
-            var btnIfLine = new NormalViewControl(frameLight.Width, ControlCommonResourse.BottomLineHeight, false);
-            btnIfLine.Y = frameLight.Height - ControlCommonResourse.BottomLineHeight;
+            var btnIfLine = new NormalViewControl(frameLight.Width, HdlControlResourse.BottomLineHeight, false);
+            btnIfLine.Y = frameLight.Height - HdlControlResourse.BottomLineHeight;
             btnIfLine.BackgroundColor = UserCenterColor.Current.ButtomLine;
             frameLight.AddChidren(btnIfLine);
 
@@ -330,7 +343,7 @@
             listView.AddChidren(frameResult);
             //瑙﹀彂鐩爣
             var rowTarget = new FrameRowControl(listView.rowSpace / 2);
-            rowTarget.LeftOffset = Application.GetRealWidth(138) - ControlCommonResourse.XXLeft;
+            rowTarget.LeftOffset = Application.GetRealWidth(138) - HdlControlResourse.XXLeft;
             frameResult.AddChidren(rowTarget);
             rowTarget.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uTriggerTarget), 600);
             rowTarget.AddRightArrow();
@@ -347,8 +360,8 @@
                     if (listSaveDevice.Count > 0)
                     {
                         //闅忎究涓竴涓悕瀛椾笂鍘�
-                        var device = Common.LocalDevice.Current.GetDevice(listSaveDevice[0]);
-                        btnTargetView.Text = Common.LocalDevice.Current.GetDeviceEpointName(device);
+                        var device = HdlDeviceCommonLogic.Current.GetDevice(listSaveDevice[0]);
+                        btnTargetView.Text = HdlDeviceCommonLogic.Current.GetDeviceEpointName(device);
                     }
                     else
                     {
@@ -360,29 +373,40 @@
 
             foreach (string mainkey in this.listEsixtDevice)
             {
-                var device = Common.LocalDevice.Current.GetDevice(mainkey);
+                var device = HdlDeviceCommonLogic.Current.GetDevice(mainkey);
                 if (device != null)
                 {
                     //闅忎究涓竴涓悕瀛椾笂鍘�
-                    btnTargetView.Text = Common.LocalDevice.Current.GetDeviceEpointName(device);
+                    btnTargetView.Text = HdlDeviceCommonLogic.Current.GetDeviceEpointName(device);
                     break;
                 }
             }
 
-            //寤舵椂
-            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) - HdlControlResourse.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);
+                };
+                //鏌ョ湅妯℃澘鏃�,涓嶅厑璁哥紪杈�
+                if (Common.Config.Instance.Home.IsShowTemplate == true)
+                {
+                    rowDelay.CanClick = false;
+                }
+            }
             //淇濆瓨
             var btnSave = new BottomClickButton();
             btnSave.TextID = R.MyInternationalizationString.uSave;
@@ -395,6 +419,11 @@
                     this.SavePirSensorData();
                 });
             };
+            //鏌ョ湅妯℃澘鏃�,涓嶅厑璁哥紪杈�
+            if (Common.Config.Instance.Home.IsShowTemplate == true)
+            {
+                btnSave.CanClick = false;
+            }
         }
 
         #endregion
@@ -411,7 +440,7 @@
             this.ShowProgressBar();
 
             //鑾峰彇缁戝畾鐩爣璁惧
-            List<CommonDevice> listDevice = await HdlDeviceBindLogic.Current.GetBindTargetDevice(this.deviceIASZone);
+            List<CommonDevice> listDevice = HdlDeviceBindLogic.Current.GetBindTargetDevice(this.deviceIASZone);
             if (listDevice == null)
             {
                 //鍏抽棴杩涘害鏉�
@@ -421,7 +450,11 @@
             this.listEsixtDevice.Clear();
             foreach (var device in listDevice)
             {
-                this.listEsixtDevice.Add(Common.LocalDevice.Current.GetDeviceMainKeys(device));
+                string mainKeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device);
+                if (listEsixtDevice.Contains(mainKeys) == false)
+                {
+                    listEsixtDevice.Add(mainKeys);
+                }
             }
             //鑾峰彇PIR浼犳劅鍣ㄧ殑銆愬厜鎰熺瓑绾ф�诲埢搴︺��
             this.lightLevelCount = await HdlDevicePirSensorLogic.Current.GetPirLightAbilitySize(this.deviceIASZone);
@@ -437,7 +470,7 @@
             }
 
             //鑾峰彇pir鐨勯厤缃俊鎭�
-            this.pirConfigure = await HdlDevicePirSensorLogic.Current.GetPirSensorLightSettion(deviceIASZone);
+            this.pirConfigure = HdlDevicePirSensorLogic.Current.GetPirSensorLightSettion(deviceIASZone);
             if (pirConfigure == null)
             {
                 //鍏抽棴杩涘害鏉�
@@ -509,7 +542,13 @@
 
             PickerView.ShowSecondary(listfirst, listSecond, (value1, value2) =>
              {
-                 btnTime.Text = listfirst[value1] + listSecond[value1][value2];
+                 string textValue = listSecond[value1][value2];
+                 if (value1 != 0)
+                 {
+                     textValue = listfirst[value1].TrimStart('0') + textValue;
+                 }
+                 btnTime.Text = textValue;
+
                  int minute = Convert.ToInt32(listfirst[value1].Substring(0, 2));
                  int second = Convert.ToInt32(listSecond[value1][value2].Substring(0, 2));
                  int delaySecond = minute * 60 + second;
@@ -530,7 +569,7 @@
         /// <summary>
         /// 淇濆瓨Pir浼犳劅鍣ㄦ暟鎹�
         /// </summary>
-        private async void SavePirSensorData()
+        private void SavePirSensorData()
         {
             if (this.isDataChanged == false)
             {
@@ -549,44 +588,80 @@
             {
                 //鍒犻櫎缁戝畾鐩爣
                 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 = HdlDeviceCommonLogic.Current.GetDevice(mainKey);
+                        listDelDevice.Add(myDevice);
+                        if (myDevice.Type == DeviceType.DimmableLight)
+                        {
+                            //濡傛灉鏄皟鍏夊櫒鐨勮瘽,鐗规畩涓�鐐�
+                            listLightDevice.Add(myDevice);
+                        }
                     }
                 }
                 if (listDelDevice.Count > 0)
                 {
                     //鍒犻櫎鐩爣
-                    var listSucess = await HdlDeviceBindLogic.Current.DeleteDeviceTarget(deviceIASZone, listDelDevice);
+                    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)
                 {
-                    listBind.Add(Common.LocalDevice.Current.GetDevice(mainKey));
+                    var myDevice = HdlDeviceCommonLogic.Current.GetDevice(mainKey);
+                    listBind.Add(myDevice);
+                    if (myDevice.Type == DeviceType.DimmableLight)
+                    {
+                        //濡傛灉鏄皟鍏夊櫒鐨勮瘽,鐗规畩涓�鐐�
+                        listLightDevice.Add(myDevice);
+                    }
                 }
                 if (listSaveDevice.Count > 0)
                 {
                     //缁戝畾鐩爣
-                    var listSucess = await HdlDeviceBindLogic.Current.BindDeviceTarget(deviceIASZone, listBind);
+                    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 = await HdlDevicePirSensorLogic.Current.SetPirSensorSettion(this.deviceIASZone, this.pirConfigure);
+            var result = HdlDevicePirSensorLogic.Current.SetPirSensorSettion(this.deviceIASZone, this.pirConfigure);
             if (result == false)
             {
                 //鍏抽棴杩涘害鏉�

--
Gitblit v1.8.0