From 25429f085093d89d543a0b90e30d0d62d1b7dac9 Mon Sep 17 00:00:00 2001
From: hxb <hxb@hdlchina.com.cn>
Date: 星期二, 30 八月 2022 09:37:38 +0800
Subject: [PATCH] 合并了IOS的代码

---
 ZigbeeApp/Shared/Phone/MainPage/Controls/DeviceCard/DeviceColorLightCardControl.cs |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/MainPage/Controls/DeviceCard/DeviceColorLightCardControl.cs b/ZigbeeApp/Shared/Phone/MainPage/Controls/DeviceCard/DeviceColorLightCardControl.cs
index 0fda2b2..ab2ae45 100755
--- a/ZigbeeApp/Shared/Phone/MainPage/Controls/DeviceCard/DeviceColorLightCardControl.cs
+++ b/ZigbeeApp/Shared/Phone/MainPage/Controls/DeviceCard/DeviceColorLightCardControl.cs
@@ -28,11 +28,18 @@
             var btnSwitch = this.AddSwitchControl();
             btnSwitch.ButtonClickEvent += (sender, e) =>
             {
+                //鑾峰彇褰撳墠浜害
+                int level = Convert.ToInt32(i_device.GetType().InvokeMember("Level", System.Reflection.BindingFlags.GetField, null, i_device, null));
                 //濡傛灉浣忓畢涓鸿櫄鎷熶綇瀹�
                 if (Common.Config.Instance.Home.IsVirtually == true)
                 {
                     //鐩存帴鍙樻洿缂撳瓨
                     ((LightBase)i_device).OnOffStatus = btnSwitch.IsSelected == true ? 0 : 1;
+                    if (((LightBase)i_device).OnOffStatus == 1 && level == 0)
+                    {
+                        //濡傛灉褰撳墠鏄墦寮�鐘舵��,骞朵笖浜害涓�0鐨勮瘽,鍒欓渶瑕佸彉鎴�100%浜害
+                        i_device.GetType().InvokeMember("Level", System.Reflection.BindingFlags.SetField, null, i_device, new object[] { 100 });
+                    }
                     this.RefreshControlInfo(this.device);
                     return;
                 }
@@ -46,7 +53,21 @@
                 {
                     //鎵撳紑
                     this.SetDeviceStatuText(Language.StringByID(R.MyInternationalizationString.uOpen1));
-                    i_device.SwitchControl(1);
+                    if (level == 0)
+                    {
+                        //濡傛灉褰撳墠鏄墦寮�鐘舵��,骞朵笖浜害涓�0鐨勮瘽,鍒欓渶瑕佸彉鎴�100%浜害
+                        i_device.GetType().InvokeMember("SetLevel", System.Reflection.BindingFlags.InvokeMethod, null, i_device, new object[] { 255 });
+                    }
+                    else
+                    {
+                        i_device.SwitchControl(1);
+                        HdlThreadLogic.Current.RunThread(() =>
+                        {
+                            //鑾峰彇鐏厜浜害
+                            System.Threading.Thread.Sleep(300);
+                            HdlDeviceAttributeLogic.Current.SendLevelStatuComand(i_device);
+                        });
+                    }
                 }
                 else
                 {

--
Gitblit v1.8.0