From 351bdda734832d821a9764b0cde8be5d83c4ec50 Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期四, 01 十二月 2022 09:56:25 +0800
Subject: [PATCH] 2022年12月01日09:56:23

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

diff --git a/ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceColorLightDetailCardForm.cs b/ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceColorLightDetailCardForm.cs
index 8aab3d5..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;
@@ -53,8 +49,10 @@
             this.ScrollEnabled = false;
             //鍏堟竻绌�
             this.listControl = new List<ButtonBase>();
+            //璁剧疆鍒濆鐘舵��
+            this.IsLightOpen = ((LightBase)this.device).OnOffStatus == 1;
             //璁剧疆鐘舵�佹枃瀛�
-            if (((LightBase)this.device).OnOffStatus == 1)
+            if (this.IsLightOpen == true)
             {
                 //浜害 XX
                 this.SetStatuText(Language.StringByID(R.MyInternationalizationString.uBrightness) + "  " + HdlDeviceOtherLogic.Current.GetDeviceStatu(this.device));
@@ -73,9 +71,16 @@
             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);
-            waveSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarColor_Start, ZigbeeColor.Current.GXCWaveSeekBarColor_End);
+            if (this.IsLightOpen == true)
+            {
+                waveSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarColor_Start, ZigbeeColor.Current.GXCWaveSeekBarColor_End);
+            }
+            else
+            {
+                waveSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor, ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor);
+            }
             frameWhiteBack.AddChidren(waveSeekBar);
 
             //寮�鍏�
@@ -84,6 +89,7 @@
             btnSwitch.SelectedImagePath = "Item/SwitchSelected.png";
             btnSwitch.Y = waveSeekBar.Bottom + Application.GetRealHeight(84);
             btnSwitch.Gravity = Gravity.CenterHorizontal;
+            btnSwitch.IsSelected = this.IsLightOpen;
             frameWhiteBack.AddChidren(btnSwitch);
             listControl.Add(btnSwitch);
             btnSwitch.ButtonClickEvent += (sender, e) =>
@@ -91,13 +97,6 @@
                 //鍙戦�佸紑鍏冲懡浠�
                 this.SetSwitchCommand(!btnSwitch.IsSelected);
             };
-
-            //璁剧疆鍒濆鐘舵��
-            this.IsLightOpen = ((LightBase)this.device).OnOffStatus == 1;
-            if (IsLightOpen == true)
-            {
-                btnSwitch.IsSelected = true;
-            }
 
             //褰╃伅鎺т欢閲岄潰鐨勯偅涓樉绀虹櫨鍒嗘瘮鐨勬帶浠�
             int progressY = waveSeekBar.Y - Application.GetMinReal(154);
@@ -150,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));
                 }
@@ -182,7 +181,7 @@
                     }
                     oldProgressValue = nowProgressValue;
                     //鍙戦�佽繘搴﹀��
-                    ((DimmableLight)this.device).SetLevel((int)(oldProgressValue * MaxLevel / 100.0));
+                    ((DimmableLight)this.device).SetLevel(HdlDeviceCommonLogic.Current.CalculateLightLevel(oldProgressValue));
                 }
             });
         }
@@ -235,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
                 {
@@ -297,13 +296,25 @@
             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)
             {
                 //寮�鍏崇姸鎬佸彉鏇�
                 listControl[0].IsSelected = isOpen;
+                if (isOpen == true)
+                {
+                    waveSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarColor_Start, ZigbeeColor.Current.GXCWaveSeekBarColor_End);
+                }
+                else
+                {
+                    waveSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor, ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor);
+                }
             }
 
             this.IsLightOpen = isOpen;

--
Gitblit v1.8.0