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/Category/Controls/DeviceRow/DeviceColorLightRowControl.cs |   51 +++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 39 insertions(+), 12 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Category/Controls/DeviceRow/DeviceColorLightRowControl.cs b/ZigbeeApp/Shared/Phone/Category/Controls/DeviceRow/DeviceColorLightRowControl.cs
index 1066d1e..0caf09c 100755
--- a/ZigbeeApp/Shared/Phone/Category/Controls/DeviceRow/DeviceColorLightRowControl.cs
+++ b/ZigbeeApp/Shared/Phone/Category/Controls/DeviceRow/DeviceColorLightRowControl.cs
@@ -14,20 +14,12 @@
         #region 鈻� 鍒濆鍖朹____________________________
 
         /// <summary>
-        /// 鍒嗙被鐣岄潰鐨勫僵鐏�(璋冨厜鍣�)璁惧琛屾帶浠�
-        /// </summary>
-        /// <param name="i_ChidrenYaxis">瀛愭帶浠禮杞村亸绉婚噺(鐪熷疄鍊�,鏈変簺鐣岄潰闇�瑕佽繖绉嶇壒娈婃搷浣�)</param>
-        public DeviceColorLightRowControl(int i_ChidrenYaxis = 0) : base(i_ChidrenYaxis)
-        {
-        }
-
-        /// <summary>
         /// 鍒濆鍖栨帶浠�
         /// </summary>
         /// <param name="i_device"></param>
-        public override void InitControl(CommonDevice i_device)
+        public override void InitControl(CommonDevice i_device, Common.Room i_nowSelectRoom)
         {
-            base.InitControl(i_device);
+            base.InitControl(i_device, i_nowSelectRoom);
 
             //娣诲姞璺宠浆娣卞害鍗$墖淇℃伅浜嬩欢
             this.AddDetailInfoEvent(i_device);
@@ -36,6 +28,21 @@
             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;
+                }
                 bool setStatu = !btnSwitch.IsSelected;
                 //鍙樻洿鍗$墖鐘舵��
                 this.SetRowOpenStatu(setStatu);
@@ -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
                 {
@@ -71,7 +92,8 @@
             {
                 //褰╃伅,璋冨厜鍣ㄧ被鍨嬬殑娣卞害鍗$墖鐣岄潰
                 var form = new MainPage.ControlForm.DeviceColorLightDetailCardForm();
-                form.AddForm(i_device, UserCenter.HdlRoomLogic.Current.CurrentRoom, 965, 1316);
+                form.RowOrCardControl = this;
+                form.AddForm(i_device, this.nowSelectRoom, 965, 1316);
                 form.FormCloseEvent += this.CardDetailInfoBackEvent;
             };
         }
@@ -99,6 +121,11 @@
         /// </summary>
         public override void SendStatuComand()
         {
+            //濡傛灉浣忓畢涓鸿櫄鎷熶綇瀹�,姝ゅ姛鑳芥棤鏁�
+            if (Common.Config.Instance.Home.IsVirtually == true)
+            {
+                return;
+            }
             //妫�娴嬭兘鍚﹀彂閫佽幏鍙栫姸鎬佸懡浠�
             if (this.CheckCanSendStatuComand() == true)
             {

--
Gitblit v1.8.0