From c0021397eeb8335d6d1f20990c71533c3d94e7af Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期五, 10 一月 2020 17:02:38 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev-tzy' into DEV_GXC

---
 ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/AutoOpenDirectionAndLimitSettionForm.cs |   74 ++++++++++++++-----------------------
 1 files changed, 28 insertions(+), 46 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/AutoOpenDirectionAndLimitSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/AutoOpenDirectionAndLimitSettionForm.cs
index 4f509d2..9784397 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/AutoOpenDirectionAndLimitSettionForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Curtain/AutoOpenDirectionAndLimitSettionForm.cs
@@ -61,7 +61,7 @@
         /// <param name="i_listdevice">绐楀笜鐨勫洖璺�</param>
         public void ShowForm(Rollershade i_CurtainDevice)
         {
-            UserView.HomePage.Instance.ScrollEnabled = false;
+            this.ScrollEnabled = false;
 
             this.curtainDevice = i_CurtainDevice;
 
@@ -116,11 +116,15 @@
                     //Log鍑哄姏
                     string msg = "褰撳墠婵�娲荤殑鐣岄潰[" + UserCenterResourse.NowActionFormID + "]";
                     HdlLogLogic.Current.WriteLog(ex, msg);
-                    //鍑虹幇鏈煡閿欒
-                    this.ShowMassage(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uUnKnownError));
-                    this.listView.RemoveAll();
-                    //璁惧寮傚父琛ユ晳 -> 娣诲姞閲嶇疆鐢垫満琛�
-                    this.AddElectricalMachineryRow();
+                    //鐢垫満鏁版嵁寮傚父,璇烽噸缃數鏈�
+                    this.ShowMassage(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uCurtainDataIsErrorPleaseResetCurtain));
+                    try
+                    {
+                        this.listView.RemoveAll();
+                        //璁惧寮傚父琛ユ晳 -> 娣诲姞閲嶇疆鐢垫満琛�
+                        this.AddElectricalMachineryRow();
+                    }
+                    catch (Exception ex2) { HdlLogLogic.Current.WriteLog(ex2, "寮�鍚堝笜琛ユ晳寮傚父"); }
                 }
             });
         }
@@ -238,7 +242,7 @@
             btnProgress1.Text = progressValue + "%";
             frameBack.AddChidren(btnProgress1);
             //杩涘害鏉�
-            this.openSeekBar = new  SeekBarControl(965);
+            this.openSeekBar = new SeekBarControl(965);
             openSeekBar.Y = btnProgressView.Bottom + Application.GetRealHeight(46);
             openSeekBar.ProgressBarColor = 0xff288bfd;
             openSeekBar.Progress = progressValue;
@@ -348,17 +352,7 @@
                     }
                     oldProValue = nowValue;
                     checking = true;
-                    if (curtainData.DeleteOpenLimit == true)
-                    {
-                        //閲嶇疆寮�闄愪綅鐐�
-                        var result = await HdlDeviceCurtainLogic.Current.DeleteCurtainLimitPoint(curtainDevice, Rollershade.LimiType.UpLimit);
-                        if (result == false)
-                        {
-                            checking = false;
-                            continue;
-                        }
-                        curtainData.DeleteOpenLimit = false;
-                    }
+
                     //灏嗙獥甯樿皟鏁村埌鎸囧畾鐧惧垎姣�
                     this.sendDiv = 1;
                     curtainDevice.WcdGoToTiltValue(nowValue);
@@ -376,12 +370,15 @@
             string msg = Language.StringByID(R.MyInternationalizationString.uCommitCurtainOpenLimitMsg);
             this.ShowMassage(ShowMsgType.Confirm, msg, async () =>
             {
+                decimal openValue = ((decimal)curtainData.OpenLimitPersent / 100) * curtainData.CurtainLength;
+                decimal closeValue = ((decimal)curtainData.CloseLimitPersent / 100) * curtainData.CurtainLength;
+                if (openValue < 0) { openValue = 0; }
+                if (closeValue < 0) { closeValue = curtainData.CurtainLength; }
                 //鎵ц纭鍙婅鐩栦笂闄愪綅鐐�
                 var result = await HdlDeviceCurtainLogic.Current.CommitCurtainLimitPoint(curtainDevice, Rollershade.CurtainPrivateInstalledLimi.UpLimit,
-                    curtainData.OpenLimitPersent, curtainData.CloseLimitPersent);
+                    (int)openValue, (int)closeValue);
                 if (result == true)
                 {
-                    curtainData.DeleteOpenLimit = true;
                     this.receiveOpenlimit = false;
                 }
             });
@@ -415,7 +412,7 @@
             btnProgress1.Text = progressValue + "%";
             frameBack.AddChidren(btnProgress1);
             //杩涘害鏉�
-            this.closeSeekBar = new  SeekBarControl(965);
+            this.closeSeekBar = new SeekBarControl(965);
             closeSeekBar.Y = btnProgressView.Bottom + Application.GetRealHeight(46);
             closeSeekBar.ProgressBarColor = 0xff288bfd;
             closeSeekBar.Progress = progressValue;
@@ -471,7 +468,7 @@
             frameBack.AddChidren(btnPlus);
             btnPlus.ButtonClickEvent += (sender, e) =>
             {
-                if (closeSeekBar.Progress >=100)
+                if (closeSeekBar.Progress >= 100)
                 {
                     return;
                 }
@@ -525,16 +522,7 @@
                     }
                     checking = true;
                     oldProValue = nowValue;
-                    if (curtainData.DeleteCloseLimit == true)
-                    {
-                        //閲嶇疆鍚堥檺浣嶇偣
-                        var result = await HdlDeviceCurtainLogic.Current.DeleteCurtainLimitPoint(curtainDevice, Rollershade.LimiType.DownLimit);
-                        if (result == false)
-                        {
-                            continue;
-                        }
-                        curtainData.DeleteCloseLimit = false;
-                    }
+
                     //灏嗙獥甯樿皟鏁村埌鎸囧畾鐧惧垎姣�
                     this.sendDiv = 2;
                     curtainDevice.WcdGoToTiltValue(nowValue);
@@ -552,12 +540,16 @@
             string msg = Language.StringByID(R.MyInternationalizationString.uCommitCurtainCloseLimitMsg);
             this.ShowMassage(ShowMsgType.Confirm, msg, async () =>
             {
-                //鎵ц纭鍙婅鐩栧悎闄愪綅鐐�
+                decimal openValue = ((decimal)curtainData.OpenLimitPersent / 100) * curtainData.CurtainLength;
+                decimal closeValue = ((decimal)curtainData.CloseLimitPersent / 100) * curtainData.CurtainLength;
+                if (openValue < 0) { openValue = 0; }
+                if (closeValue < 0) { closeValue = curtainData.CurtainLength; }
+                //鎵ц纭鍙婅鐩栦笂闄愪綅鐐�
                 var result = await HdlDeviceCurtainLogic.Current.CommitCurtainLimitPoint(curtainDevice, Rollershade.CurtainPrivateInstalledLimi.DownLimit,
-                    curtainData.OpenLimitPersent, curtainData.CloseLimitPersent);
+                    (int)openValue, (int)closeValue);
+
                 if (result == true)
                 {
-                    curtainData.DeleteCloseLimit = true;
                     this.receiveCloseLimit = false;
                 }
             });
@@ -722,7 +714,7 @@
                     //鏂瑰悜澶囦唤
                     await HdlDeviceCurtainLogic.Current.BackupCurtainDirection(curtainDevice, curtainData.Direction);
                     //闄愪綅澶囦唤
-                    int uplimit= (int)(curtainData.OpenLimitValue / (curtainData.CurtainLength * 1.0) * 100);
+                    int uplimit = (int)(curtainData.OpenLimitValue / (curtainData.CurtainLength * 1.0) * 100);
                     int downlimit = (int)(curtainData.CloseLimitValue / (curtainData.CurtainLength * 1.0) * 100);
                     await HdlDeviceCurtainLogic.Current.BackupCurtainLimitPoint(curtainDevice, uplimit, downlimit);
                 });
@@ -784,8 +776,6 @@
             HdlGatewayReceiveLogic.Current.RemoveEvent("CurtainDeviceAttribute");
             HdlGatewayReceiveLogic.Current.RemoveEvent("ReceiveLimitData");
 
-            UserView.HomePage.Instance.ScrollEnabled = true;
-
             base.CloseFormBefore();
         }
 
@@ -802,14 +792,6 @@
             /// false:鐢垫満鏂瑰悜姝e悜锛泃rue:鐢垫満鏂瑰悜鍙嶅悜
             /// </summary>
             public bool Direction = false;
-            /// <summary>
-            /// 鏄惁閲嶇疆寮�闄愪綅鐐�
-            /// </summary>
-            public bool DeleteOpenLimit = true;
-            /// <summary>
-            /// 鏄惁閲嶇疆鍚堥檺浣嶇偣
-            /// </summary>
-            public bool DeleteCloseLimit = true;
             /// <summary>
             /// 寮�闄愪綅鐨勫��
             /// </summary>

--
Gitblit v1.8.0