黄学彪
2020-09-01 dee21bf452a8979d0515d13e534fbb69ed9715dd
ZigbeeApp/Shared/Phone/Category/Controls/DeviceRow/DeviceColorLightRowControl.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[] { 254 });
                    }
                    else
                    {
                        i_device.SwitchControl(1);
                        HdlThreadLogic.Current.RunThread(() =>
                        {
                            //获取灯光亮度
                            System.Threading.Thread.Sleep(300);
                            HdlDeviceAttributeLogic.Current.SendLevelStatuComand(i_device);
                        });
                    }
                }
                else
                {