From b2f2494386c4629cf0e0f0a3740e7672919d53a2 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期三, 06 一月 2021 17:09:55 +0800
Subject: [PATCH] 修改了彩灯的百分比计算

---
 ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceColorLightDetailCardForm.cs |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceColorLightDetailCardForm.cs b/ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceColorLightDetailCardForm.cs
index c5167cc..37874aa 100755
--- a/ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceColorLightDetailCardForm.cs
+++ b/ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceColorLightDetailCardForm.cs
@@ -19,10 +19,6 @@
         /// </summary>
         private List<ButtonBase> listControl = new List<ButtonBase>();
         /// <summary>
-        /// MaxLevel
-        /// </summary>
-        private const int MaxLevel = 254;
-        /// <summary>
         /// 褰╃伅鎺т欢
         /// </summary>
         private WaveSeekBar waveSeekBar = null;
@@ -75,7 +71,7 @@
             waveSeekBar.Gravity = Gravity.CenterHorizontal;
             waveSeekBar.WavePadding = Application.GetRealWidth(8);
             waveSeekBar.MaxValue = 100;
-            waveSeekBar.Progress = (int)(((DimmableLight)this.device).Level * 1.0 / MaxLevel * 100);
+            waveSeekBar.Progress = HdlDeviceCommonLogic.Current.CalculateLightLevelPersent(((DimmableLight)this.device).Level);
             waveSeekBar.CornerRadius = Application.GetRealHeight(58);
             if (this.IsLightOpen == true)
             {
@@ -153,7 +149,7 @@
                 else
                 {
                     //濡傛灉浣忓畢涓鸿櫄鎷熶綇瀹�,鐩存帴鏀圭紦瀛�
-                    ((DimmableLight)this.device).Level = value * MaxLevel / 100;
+                    ((DimmableLight)this.device).Level = HdlDeviceCommonLogic.Current.CalculateLightLevel(value);
                     //浜害 XX
                     this.SetStatuText(Language.StringByID(R.MyInternationalizationString.uBrightness) + "  " + HdlDeviceOtherLogic.Current.GetDeviceStatu(this.device));
                 }
@@ -185,7 +181,7 @@
                     }
                     oldProgressValue = nowProgressValue;
                     //鍙戦�佽繘搴﹀��
-                    ((DimmableLight)this.device).SetLevel((int)(oldProgressValue * MaxLevel / 100.0));
+                    ((DimmableLight)this.device).SetLevel(HdlDeviceCommonLogic.Current.CalculateLightLevel(oldProgressValue));
                 }
             });
         }
@@ -238,7 +234,7 @@
                 if (level == 0)
                 {
                     //濡傛灉褰撳墠鏄墦寮�鐘舵��,骞朵笖浜害涓�0鐨勮瘽,鍒欓渶瑕佸彉鎴�100%浜害
-                    this.device.GetType().InvokeMember("SetLevel", System.Reflection.BindingFlags.InvokeMethod, null, this.device, new object[] { 254 });
+                    this.device.GetType().InvokeMember("SetLevel", System.Reflection.BindingFlags.InvokeMethod, null, this.device, new object[] { 255 });
                 }
                 else
                 {
@@ -300,7 +296,11 @@
             if (this.isProgressing == false)
             {
                 //褰撹繘搴﹀�煎湪鎵嬪姩鍙樻洿涓椂,涓嶆帴鏀舵帹閫�
-                waveSeekBar.Progress = (int)(((DimmableLight)this.device).Level * 1.0 / MaxLevel * 100);
+                int progress = HdlDeviceCommonLogic.Current.CalculateLightLevelPersent(((DimmableLight)this.device).Level);
+                if (waveSeekBar.Progress != progress)
+                {
+                    waveSeekBar.Progress = progress;
+                }
             }
 
             if (listControl[0].IsSelected != isOpen)

--
Gitblit v1.8.0