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/DeviceMiniLightDetailCardForm.cs |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceMiniLightDetailCardForm.cs b/ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceMiniLightDetailCardForm.cs
index c30c0e5..4c219f0 100755
--- a/ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceMiniLightDetailCardForm.cs
+++ b/ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceMiniLightDetailCardForm.cs
@@ -31,10 +31,6 @@
         /// </summary>
         private SeekBarControl seekBarColor = null;
         /// <summary>
-        /// MaxLevel
-        /// </summary>
-        private const int MaxLevel = 254;
-        /// <summary>
         /// 浜害杩涘害鍊兼槸鍚﹀湪鏀瑰彉涓�
         /// </summary>
         private bool isLightProgressing = false;
@@ -98,7 +94,7 @@
             seekBarLight.ProgressTextSize = 14;
             seekBarLight.ProgressTextColor = UserCenterColor.Current.TextGrayColor2;
             seekBarLight.Gravity = Gravity.Frame;
-            seekBarLight.Progress = (int)(((ColorTemperatureLight)this.device).Level * 1.0 / MaxLevel * 100);
+            seekBarLight.Progress = HdlDeviceCommonLogic.Current.CalculateLightLevelPersent(((ColorTemperatureLight)this.device).Level);
             frameWhiteBack.AddChidren(seekBarLight);
 
             //鑹叉俯
@@ -226,7 +222,7 @@
                 else
                 {
                     //濡傛灉浣忓畢涓鸿櫄鎷熶綇瀹�,鐩存帴鏀圭紦瀛�
-                    ((ColorTemperatureLight)this.device).Level = value * MaxLevel / 100;
+                    ((ColorTemperatureLight)this.device).Level = HdlDeviceCommonLogic.Current.CalculateLightLevel(value);
                     //浜害 XX
                     this.SetStatuText(Language.StringByID(R.MyInternationalizationString.uBrightness) + "  " + HdlDeviceOtherLogic.Current.GetDeviceStatu(this.device));
                 }
@@ -281,7 +277,7 @@
                     if (nowLightValue != oldLightValue)
                     {
                         oldLightValue = nowLightValue;
-                        ((ColorTemperatureLight)this.device).SetLevel((int)(oldLightValue * MaxLevel / 100.0));
+                        ((ColorTemperatureLight)this.device).SetLevel(HdlDeviceCommonLogic.Current.CalculateLightLevel(oldLightValue));
                     }
                     //鍙戦�佽壊娓╁��
                     if (nowColorValue != oldColorValue)
@@ -295,7 +291,7 @@
                 if (nowLightValue != oldLightValue)
                 {
                     //鍙戦�佷寒搴﹀��
-                    ((ColorTemperatureLight)this.device).SetLevel((int)(nowLightValue * MaxLevel / 100.0));
+                    ((ColorTemperatureLight)this.device).SetLevel(HdlDeviceCommonLogic.Current.CalculateLightLevel(nowLightValue));
                 }
                 if (nowColorValue != oldColorValue)
                 {
@@ -354,7 +350,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
                 {
@@ -493,7 +489,11 @@
             if (this.isLightProgressing == false)
             {
                 //褰撹繘搴﹀�煎湪鎵嬪姩鍙樻洿涓椂,涓嶆帴鏀舵帹閫�
-                seekBarLight.Progress = (int)(((ColorTemperatureLight)this.device).Level * 1.0 / MaxLevel * 100);
+                int progress = HdlDeviceCommonLogic.Current.CalculateLightLevelPersent(((ColorTemperatureLight)this.device).Level);
+                if (seekBarLight.Progress != progress)
+                {
+                    seekBarLight.Progress = progress;
+                }
             }
             if (this.isColorProgressing == false)
             {

--
Gitblit v1.8.0