HDL Home App 第二版本 旧平台金堂用 正在使用
hxb
2022-08-30 25429f085093d89d543a0b90e30d0d62d1b7dac9
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,13 +53,21 @@
                {
                    //打开
                    this.SetDeviceStatuText(Language.StringByID(R.MyInternationalizationString.uOpen1));
                    i_device.SwitchControl(1);
                    HdlThreadLogic.Current.RunThread(() =>
                    if (level == 0)
                    {
                        //获取灯光亮度
                        System.Threading.Thread.Sleep(300);
                        HdlDeviceAttributeLogic.Current.SendLevelStatuComand(i_device);
                    });
                        //如果当前是打开状态,并且亮度为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
                {