From 0d9f64668fd7350d6a21fd157e32009a96d98134 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期三, 16 十二月 2020 13:09:08 +0800
Subject: [PATCH] 新云端代码Ver1.2

---
 ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceMiniLightDetailCardForm.cs |  143 ++++++++++++++++++++---------------------------
 1 files changed, 60 insertions(+), 83 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceMiniLightDetailCardForm.cs b/ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceMiniLightDetailCardForm.cs
index 693b662..471b9df 100755
--- a/ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceMiniLightDetailCardForm.cs
+++ b/ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceMiniLightDetailCardForm.cs
@@ -43,10 +43,6 @@
         /// </summary>
         private bool isColorProgressing = false;
         /// <summary>
-        /// 鑳藉惁鍙戦�佽繘搴﹀��
-        /// </summary>
-        private bool canSetProgressValue = true;
-        /// <summary>
         /// 1:鍙戦�佺殑鏄皬澶滅伅  2:鍙戦�佺殑鏄渹楦e櫒
         /// </summary>
         private int sendDiv = 0;
@@ -70,7 +66,7 @@
             if (((LightBase)this.device).OnOffStatus == 1)
             {
                 //浜害 XX
-                this.SetStatuText(Language.StringByID(R.MyInternationalizationString.uBrightness) + "  " + HdlDeviceOtherLogic.Current.GetDeviceStatu(this.device));
+                this.SetStatuText(Language.StringByID(R.MyInternationalizationString.uBrightness) + "  " + HdlDeviceCommonLogic.Current.GetMainPageDeviceStatuText(this.device));
             }
             else
             {
@@ -85,7 +81,7 @@
             btnLightView.Y = Application.GetRealHeight(320);
             frameWhiteBack.AddChidren(btnLightView);
             //搴曠嚎
-            var btnLightLine = new NormalViewControl(Application.GetRealWidth(841), ControlCommonResourse.BottomLineHeight, false);
+            var btnLightLine = new NormalViewControl(Application.GetRealWidth(841), HdlControlResourse.BottomLineHeight, false);
             btnLightLine.BackgroundColor = UserCenterColor.Current.ButtomLine;
             btnLightLine.X = btnLightView.X;
             btnLightLine.Y = btnLightView.Bottom + Application.GetRealHeight(37);
@@ -112,7 +108,7 @@
             btnColorView.Y = btnLightLine.Y + Application.GetRealHeight(107);
             frameWhiteBack.AddChidren(btnColorView);
             //搴曠嚎
-            var btnColorLine = new NormalViewControl(Application.GetRealWidth(841), ControlCommonResourse.BottomLineHeight, false);
+            var btnColorLine = new NormalViewControl(Application.GetRealWidth(841), HdlControlResourse.BottomLineHeight, false);
             btnColorLine.BackgroundColor = UserCenterColor.Current.ButtomLine;
             btnColorLine.X = btnColorView.X;
             btnColorLine.Y = btnColorView.Bottom + Application.GetRealHeight(37);
@@ -140,7 +136,7 @@
             seekBarColor.ProgressChangeDelayTime = 0;
             frameWhiteBack.AddChidren(seekBarColor);
             //鏄剧ず鑷畾涔夋枃鏈�
-            seekBarColor.ShowCustomTextView(Application.GetRealWidth(150), 15, UserCenterColor.Current.TextGrayColor3);
+            seekBarColor.ShowCustomTextView(Application.GetRealWidth(200), 15, UserCenterColor.Current.TextGrayColor3);
             //璁剧疆鍒濆鍊�
             int colorValue = ((ColorTemperatureLight)this.device).ColorTemperature;
             if (colorValue == 0) { colorValue = 3000; }
@@ -154,7 +150,7 @@
             btnBuzzerView.Y = btnColorLine.Y + Application.GetRealHeight(107);
             frameWhiteBack.AddChidren(btnBuzzerView);
             //搴曠嚎
-            var btnBuzzerLine = new NormalViewControl(Application.GetRealWidth(841), ControlCommonResourse.BottomLineHeight, false);
+            var btnBuzzerLine = new NormalViewControl(Application.GetRealWidth(841), HdlControlResourse.BottomLineHeight, false);
             btnBuzzerLine.BackgroundColor = UserCenterColor.Current.ButtomLine;
             btnBuzzerLine.X = btnBuzzerView.X;
             btnBuzzerLine.Y = btnBuzzerView.Bottom + Application.GetRealHeight(37);
@@ -182,7 +178,7 @@
             btnMiniView.Y = btnBuzzerLine.Y + Application.GetRealHeight(107);
             frameWhiteBack.AddChidren(btnMiniView);
             //搴曠嚎
-            var btnMiniLine = new NormalViewControl(Application.GetRealWidth(841), ControlCommonResourse.BottomLineHeight, false);
+            var btnMiniLine = new NormalViewControl(Application.GetRealWidth(841), HdlControlResourse.BottomLineHeight, false);
             btnMiniLine.BackgroundColor = UserCenterColor.Current.ButtomLine;
             btnMiniLine.X = btnMiniView.X;
             btnMiniLine.Y = btnMiniView.Bottom + Application.GetRealHeight(37);
@@ -202,13 +198,6 @@
                 this.SetLightSwitchCommand(!btnMiniSwitch.IsSelected);
             };
             btnMiniSwitch.IsSelected = ((LightBase)this.device).OnOffStatus == 1;
-            this.canSetProgressValue = btnMiniSwitch.IsSelected;
-            if (btnMiniSwitch.IsSelected == false)
-            {
-                //鍦ㄦ病鏈夋墦寮�澶滅伅寮�鍏充箣鍓�,涓嶅厑璁告粦鍔�
-                seekBarLight.Enable = false;
-                seekBarColor.Enable = false;
-            }
 
             //浜害寮�濮嬫粦鍔ㄧ殑浜嬩欢
             seekBarLight.OnStartTrackingTouchEvent += (sender, e) =>
@@ -231,18 +220,15 @@
             {
                 if (Common.Config.Instance.Home.IsVirtually == false)
                 {
-                    if (this.canSetProgressValue == true)
-                    {
-                        //鑳藉鍙戦�佽繘搴﹀�肩殑鏃跺��,鎵嶈褰�
-                        nowLightValue = value;
-                    }
+                    //鑳藉鍙戦�佽繘搴﹀�肩殑鏃跺��,鎵嶈褰�
+                    nowLightValue = value;
                 }
                 else
                 {
                     //濡傛灉浣忓畢涓鸿櫄鎷熶綇瀹�,鐩存帴鏀圭紦瀛�
                     ((ColorTemperatureLight)this.device).Level = value * MaxLevel / 100;
                     //浜害 XX
-                    this.SetStatuText(Language.StringByID(R.MyInternationalizationString.uBrightness) + "  " + HdlDeviceOtherLogic.Current.GetDeviceStatu(this.device));
+                    this.SetStatuText(Language.StringByID(R.MyInternationalizationString.uBrightness) + "  " + HdlDeviceCommonLogic.Current.GetMainPageDeviceStatuText(this.device));
                 }
             };
 
@@ -270,11 +256,8 @@
                 seekBarColor.SetCustomText(value * 100 + "K");
                 if (Common.Config.Instance.Home.IsVirtually == false)
                 {
-                    if (this.canSetProgressValue == true)
-                    {
-                        //鑳藉鍙戦�佽繘搴﹀�肩殑鏃跺��,鎵嶈褰�
-                        nowColorValue = value;
-                    }
+                    //鑳藉鍙戦�佽繘搴﹀�肩殑鏃跺��,鎵嶈褰�
+                    nowColorValue = value;
                 }
                 else
                 {
@@ -282,8 +265,13 @@
                     ((ColorTemperatureLight)this.device).ColorTemperature = value * 100;
                 }
             };
+            if (Config.Instance.Home.IsVirtually == true)
+            {
+                //铏氭嫙浣忓畢
+                return;
+            }
 
-            //寮�涓�涓嚎绋�,鐩戣鏄惁婊戝姩鐨勬粦鍔ㄦ潯,姣忕妫�娴嬩竴娆�
+                //寮�涓�涓嚎绋�,鐩戣鏄惁婊戝姩鐨勬粦鍔ㄦ潯,姣忕妫�娴嬩竴娆�
             HdlThreadLogic.Current.RunThread(() =>
             {
                 while (this.Parent != null)
@@ -303,20 +291,17 @@
                         ((ColorTemperatureLight)this.device).SetColorTemperature(value);
                     }
                 }
-                if (this.canSetProgressValue == true)
+                //鐣岄潰鍏抽棴鏃�
+                if (nowLightValue != oldLightValue)
                 {
-                    //鐣岄潰鍏抽棴鏃�
-                    if (nowLightValue != oldLightValue)
-                    {
-                        //鍙戦�佷寒搴﹀��
-                        ((ColorTemperatureLight)this.device).SetLevel((int)(nowLightValue * MaxLevel / 100.0));
-                    }
-                    if (nowColorValue != oldColorValue)
-                    {
-                        //鍙戦�佽壊娓╁��
-                        int value = 1000000 / (nowColorValue * 100);
-                        ((ColorTemperatureLight)this.device).SetColorTemperature(value);
-                    }
+                    //鍙戦�佷寒搴﹀��
+                    ((ColorTemperatureLight)this.device).SetLevel((int)(nowLightValue * MaxLevel / 100.0));
+                }
+                if (nowColorValue != oldColorValue)
+                {
+                    //鍙戦�佽壊娓╁��
+                    int value = 1000000 / (nowColorValue * 100);
+                    ((ColorTemperatureLight)this.device).SetColorTemperature(value);
                 }
             });
         }
@@ -331,17 +316,21 @@
         /// <param name="isOpen"></param>
         private void SetLightSwitchCommand(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;
             }
-
-            //褰撴寜涓嬪紑鍏虫寜閽椂,涓嶈兘鍐嶅彂閫佽繘搴﹀��
-            this.canSetProgressValue = false;
 
             //妫�娴嬫槸鍚﹁幏鍙栫綉鍏冲弽棣堢殑缁撴灉,濡傛灉缃戝叧娌℃湁鍥炲,鍒欎細寮瑰嚭娑堟伅
             this.StartCheckResponeResult(new List<ButtonBase> { this.btnMiniSwitch.btnIcon }, (result) =>
@@ -354,18 +343,6 @@
                          bool statu = ((LightBase)this.device).OnOffStatus == 1;
                          //鍒锋柊寮�鍏崇姸鎬�
                          this.RefreshSwitchStatu(statu);
-                         if (statu == true)
-                         {
-                             //褰撴槸鎵撳紑鐘舵�佹椂,缃戝叧璇村畠浼氶粯璁ゆ妸浜害鍙樻垚100%
-                             //浠ラ槻涓囦竴,杩欓噷鍐嶆璇诲彇涓�涓�
-                             HdlThreadLogic.Current.RunThread(() =>
-                             {
-                                 ((ColorTemperatureLight)device).ReadLevel();
-                                 System.Threading.Thread.Sleep(300);
-                                 ((ColorTemperatureLight)device).ReadColorTemperature();
-                             });
-
-                         }
                      }
                  });
              });
@@ -374,7 +351,15 @@
             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[] { 254 });
+                }
+                else
+                {
+                    this.device.SwitchControl(1);
+                }
             }
             else
             {
@@ -427,10 +412,10 @@
         private void AddReceiveBuzzerAckEvent()
         {
             //Ack涓婚涓婃姤
-            string mainKeys = LocalDevice.Current.GetDeviceMainKeys(this.device);
+            string mainKeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(this.device);
             HdlGatewayReceiveLogic.Current.AddAttributeEvent("DeviceBuzzerDetailCardACK", ReceiveComandDiv.A鑺傜偣鎺у埗鍙嶉, (report) =>
             {
-                string mainKey2 = LocalDevice.Current.GetDeviceMainKeys(report);
+                string mainKey2 = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(report);
                 if (mainKeys != mainKey2)
                 {
                     //涓嶆槸鍚屼竴涓笢瑗�
@@ -489,42 +474,34 @@
             if (isOpen == true)
             {
                 //浜害鏄繀椤昏鍒锋柊鐨�  浜害 XX
-                this.SetStatuText(Language.StringByID(R.MyInternationalizationString.uBrightness) + "  " + HdlDeviceOtherLogic.Current.GetDeviceStatu(this.device));
-                if (this.isLightProgressing == false)
-                {
-                    //褰撹繘搴﹀�煎湪鎵嬪姩鍙樻洿涓椂,涓嶆帴鏀舵帹閫�
-                    seekBarLight.Progress = (int)(((ColorTemperatureLight)this.device).Level * 1.0 / MaxLevel * 100);
-                }
-                if (this.isColorProgressing == false)
-                {
-                    //褰撹繘搴﹀�煎湪鎵嬪姩鍙樻洿涓椂,涓嶆帴鏀舵帹閫�
-                    seekBarColor.Progress = (int)(((ColorTemperatureLight)this.device).ColorTemperature / 100);
-                    //璁剧疆鑷畾涔夌殑鏂囨湰
-                    seekBarColor.SetCustomText(seekBarColor.Progress * 100 + "K");
-                }
+                this.SetStatuText(Language.StringByID(R.MyInternationalizationString.uBrightness) + "  " + HdlDeviceCommonLogic.Current.GetMainPageDeviceStatuText(this.device));
                 if (this.btnMiniSwitch.IsSelected == false)
                 {
                     this.btnMiniSwitch.IsSelected = true;
                 }
-                //婊戝姩鏉″彲浠ユ粦鍔�
-                seekBarLight.Enable = true;
-                seekBarColor.Enable = true;
             }
             else
             {
-                //鍙樻洿瀛楁牱:鍏抽棴
-                this.SetStatuText(Language.StringByID(R.MyInternationalizationString.Close));
                 if (this.btnMiniSwitch.IsSelected == true)
                 {
                     this.btnMiniSwitch.IsSelected = false;
+                    //鍙樻洿瀛楁牱:鍏抽棴
+                    this.SetStatuText(Language.StringByID(R.MyInternationalizationString.Close));
                 }
-                //婊戝姩鏉′笉鍙互婊戝姩
-                seekBarLight.Enable = false;
-                seekBarColor.Enable = false;
             }
 
-            //鍥炲鐨勭粨鏋滆,澶勪簬鎵撳紑鐘舵�佹墠鑳藉彂閫�
-            this.canSetProgressValue = isOpen;
+            if (this.isLightProgressing == false)
+            {
+                //褰撹繘搴﹀�煎湪鎵嬪姩鍙樻洿涓椂,涓嶆帴鏀舵帹閫�
+                seekBarLight.Progress = (int)(((ColorTemperatureLight)this.device).Level * 1.0 / MaxLevel * 100);
+            }
+            if (this.isColorProgressing == false)
+            {
+                //褰撹繘搴﹀�煎湪鎵嬪姩鍙樻洿涓椂,涓嶆帴鏀舵帹閫�
+                seekBarColor.Progress = (int)(((ColorTemperatureLight)this.device).ColorTemperature / 100);
+                //璁剧疆鑷畾涔夌殑鏂囨湰
+                seekBarColor.SetCustomText(seekBarColor.Progress * 100 + "K");
+            }
         }
 
         #endregion

--
Gitblit v1.8.0