From dc0309e64f02227d8e1468b7326c07955f804612 Mon Sep 17 00:00:00 2001
From: chenqiyang <1406175257@qq.com>
Date: 星期三, 22 六月 2022 11:22:18 +0800
Subject: [PATCH] 修改引用路径

---
 ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceColorTemperatureLightDetailCardForm.cs |   97 ++++++++++++++++++++++++------------------------
 1 files changed, 48 insertions(+), 49 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceColorTemperatureLightDetailCardForm.cs b/ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceColorTemperatureLightDetailCardForm.cs
index 6408315..89c017a 100755
--- a/ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceColorTemperatureLightDetailCardForm.cs
+++ b/ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceColorTemperatureLightDetailCardForm.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,12 @@
             this.ScrollEnabled = false;
             //鍏堟竻绌�
             this.listControl = new List<ButtonBase>();
+            //璁剧疆鍒濆鐘舵��
+            this.IsLightOpen = ((LightBase)this.device).OnOffStatus == 1;
+            this.canSetProgressValue = this.IsLightOpen;
+
             //璁剧疆鐘舵�佹枃瀛�
-            if (((LightBase)this.device).OnOffStatus == 1)
+            if (this.IsLightOpen == true)
             {
                 //浜害 XX
                 this.SetStatuText(Language.StringByID(R.MyInternationalizationString.uBrightness) + "  " + HdlDeviceOtherLogic.Current.GetDeviceStatu(this.device));
@@ -73,8 +73,16 @@
             waveSeekBar.Gravity = Gravity.CenterHorizontal;
             waveSeekBar.WavePadding = Application.GetRealWidth(8);
             waveSeekBar.MaxValue = 100;
-            waveSeekBar.Progress = (int)(((ColorTemperatureLight)this.device).Level * 1.0 / MaxLevel * 100);
+            waveSeekBar.Progress = HdlDeviceCommonLogic.Current.CalculateLightLevelPersent(((ColorTemperatureLight)this.device).Level);
             waveSeekBar.CornerRadius = Application.GetRealHeight(58);
+            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);
 
             //寮�鍏�
@@ -83,6 +91,7 @@
             btnSwitch.SelectedImagePath = "Item/SwitchSelected.png";
             btnSwitch.Y = waveSeekBar.Bottom + Application.GetRealHeight(418);
             btnSwitch.Gravity = Gravity.CenterHorizontal;
+            btnSwitch.IsSelected = this.IsLightOpen;
             frameWhiteBack.AddChidren(btnSwitch);
             listControl.Add(btnSwitch);
             btnSwitch.ButtonClickEvent += (sender, e) =>
@@ -90,21 +99,6 @@
                 //鍙戦�佸紑鍏冲懡浠�
                 this.SetSwitchCommand(!btnSwitch.IsSelected);
             };
-
-            //璁剧疆鍒濆鐘舵��
-            this.IsLightOpen = ((LightBase)this.device).OnOffStatus == 1;
-            this.canSetProgressValue = this.IsLightOpen;
-            if (IsLightOpen == true)
-            {
-                btnSwitch.IsSelected = true;
-                waveSeekBar.IsClickable = true;
-                waveSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarColor_Start, ZigbeeColor.Current.GXCWaveSeekBarColor_End);
-            }
-            else
-            {
-                waveSeekBar.IsClickable = false;
-                waveSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor, ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor);
-            }
 
             //褰╃伅鎺т欢閲岄潰鐨勯偅涓樉绀虹櫨鍒嗘瘮鐨勬帶浠�
             int progressY = waveSeekBar.Y - Application.GetMinReal(154);
@@ -157,7 +151,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));
                 }
@@ -218,7 +212,7 @@
                         if (nowProgressValue != oldProgressValue)
                         {
                             oldProgressValue = nowProgressValue;
-                            ((ColorTemperatureLight)this.device).SetLevel((int)(oldProgressValue * MaxLevel / 100.0));
+                            ((ColorTemperatureLight)this.device).SetLevel(HdlDeviceCommonLogic.Current.CalculateLightLevel(oldProgressValue));
                         }
                         //鍙戦�佽壊娓╁��
                         if (nowColorValue != oldColorValue)
@@ -232,7 +226,7 @@
                 if (nowProgressValue != oldProgressValue)
                 {
                     //鍙戦�佷寒搴﹀��
-                    ((ColorTemperatureLight)this.device).SetLevel((int)(nowProgressValue * MaxLevel / 100.0));
+                    ((ColorTemperatureLight)this.device).SetLevel(HdlDeviceCommonLogic.Current.CalculateLightLevel(nowProgressValue));
                 }
                 if (nowColorValue != oldColorValue)
                 {
@@ -252,10 +246,18 @@
         /// <param name="isOpen"></param>
         private void SetSwitchCommand(bool isOpen)
         {
+            //鑾峰彇褰撳墠浜害
+            int level = Convert.ToInt32(this.device.GetType().InvokeMember("Level", System.Reflection.BindingFlags.GetField, null, this.device, null));
+
             //濡傛灉浣忓畢鏄櫄鎷熶綇瀹�
             if (Common.Config.Instance.Home.IsVirtually == true)
             {
                 ((LightBase)this.device).OnOffStatus = isOpen == true ? 1 : 0;
+                if (((LightBase)this.device).OnOffStatus == 1 && level == 0)
+                {
+                    //濡傛灉褰撳墠鏄墦寮�鐘舵��,骞朵笖浜害涓�0鐨勮瘽,鍒欓渶瑕佸彉鎴�100%浜害
+                    this.device.GetType().InvokeMember("Level", System.Reflection.BindingFlags.SetField, null, this.device, new object[] { 100 });
+                }
                 //鍒锋柊寮�鍏崇姸鎬�
                 this.RefreshSwitchStatu(isOpen);
                 return;
@@ -269,29 +271,29 @@
             {
                 HdlThreadLogic.Current.RunMain(() =>
                 {
+                    bool statu = ((LightBase)this.device).OnOffStatus == 1;
                     //鎺ユ敹鍒扮綉鍏冲洖澶�
                     if (result == true)
                     {
-                        bool statu = ((LightBase)this.device).OnOffStatus == 1;
                         //鍒锋柊寮�鍏崇姸鎬�
                         this.RefreshSwitchStatu(statu);
-                        if (statu == true)
-                        {
-                            //绛夊緟缁撴灉缁撴潫鍚�,褰╃伅鎺т欢鍙互婊戝姩
-                            waveSeekBar.IsClickable = true;
-                        }
+                        //鐘舵�佸彇鍙�
+                        listControl[0].IsSelected = statu;
                     }
                 });
             });
-
-            //鍙戦�佺瓑寰呯殑鏃堕棿鍐�,涓嶈兘婊戝姩褰╃伅鎺т欢
-            waveSeekBar.IsClickable = false;
-            //鐘舵�佸彇鍙�
-            listControl[0].IsSelected = !listControl[0].IsSelected;
             if (isOpen == true)
             {
                 //鎵撳紑
-                this.device.SwitchControl(1);
+                if (level == 0)
+                {
+                    //濡傛灉褰撳墠鏄墦寮�鐘舵��,骞朵笖浜害涓�0鐨勮瘽,鍒欓渶瑕佸彉鎴�100%浜害
+                    this.device.GetType().InvokeMember("SetLevel", System.Reflection.BindingFlags.InvokeMethod, null, this.device, new object[] { 255 });
+                }
+                else
+                {
+                    this.device.SwitchControl(1);
+                }
             }
             else
             {
@@ -338,38 +340,35 @@
             {
                 //浜害鏄繀椤昏鍒锋柊鐨�  浜害 XX
                 this.SetStatuText(Language.StringByID(R.MyInternationalizationString.uBrightness) + "  " + HdlDeviceOtherLogic.Current.GetDeviceStatu(this.device));
-                if (this.isProgressing == false)
-                {
-                    //褰撹繘搴﹀�煎湪鎵嬪姩鍙樻洿涓椂,涓嶆帴鏀舵帹閫�
-                    waveSeekBar.Progress = (int)(((ColorTemperatureLight)this.device).Level * 1.0 / MaxLevel * 100);
-                }
             }
             if (isOpen == false && this.IsLightOpen == true)
             {
                 //鐘舵�佷笉涓�鏍�,鎵嶅彉鏇村瓧鏍�:鍏抽棴
                 this.SetStatuText(Language.StringByID(R.MyInternationalizationString.Close));
             }
-
             if (listControl[0].IsSelected != isOpen)
             {
                 //寮�鍏崇姸鎬佸彉鏇�
                 listControl[0].IsSelected = isOpen;
-            }
-
-            //鐘舵�佷笉涓�鏍锋墠鍙樻洿
-            if (this.IsLightOpen != isOpen)
-            {
                 if (isOpen == true)
                 {
-                    waveSeekBar.IsClickable = true;
                     waveSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarColor_Start, ZigbeeColor.Current.GXCWaveSeekBarColor_End);
                 }
                 else
                 {
-                    waveSeekBar.IsClickable = false;
                     waveSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor, ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor);
                 }
             }
+            if (this.isProgressing == false)
+            {
+                //褰撹繘搴﹀�煎湪鎵嬪姩鍙樻洿涓椂,涓嶆帴鏀舵帹閫�
+                int progress = HdlDeviceCommonLogic.Current.CalculateLightLevelPersent(((ColorTemperatureLight)this.device).Level);
+                if (waveSeekBar.Progress != progress)
+                {
+                    waveSeekBar.Progress = progress;
+                }
+            }
+
             this.IsLightOpen = isOpen;
             //鍥炲鐨勭粨鏋滆,澶勪簬鎵撳紑鐘舵�佹墠鑳藉彂閫�
             this.canSetProgressValue = this.IsLightOpen;

--
Gitblit v1.8.0