| | |
| | | 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;
|
| | | }
|
| | |
| | | {
|
| | | //打开
|
| | | 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[] { 254 });
|
| | | }
|
| | | else
|
| | | {
|
| | | i_device.SwitchControl(1);
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | //获取灯光亮度
|
| | | System.Threading.Thread.Sleep(300);
|
| | | HdlDeviceAttributeLogic.Current.SendLevelStatuComand(i_device);
|
| | | });
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | |
| | | {
|
| | | Common.CommonPage.Instance.IsDrawerLockMode = true;
|
| | |
|
| | | var form = new ControlForm.DeviceColorTemperatureLightDetailCardForm();
|
| | | form.RowOrCardControl = this;
|
| | | form.AddForm(i_device, this.nowSelectRoom, 965, 1466);
|
| | | form.FormCloseEvent += this.CardDetailInfoBackEvent;
|
| | | if (HdlDeviceCommonLogic.Current.IsMiniLight(this.device) == false)
|
| | | {
|
| | | var form = new ControlForm.DeviceColorTemperatureLightDetailCardForm();
|
| | | form.RowOrCardControl = this;
|
| | | form.AddForm(i_device, this.nowSelectRoom, 965, 1466);
|
| | | form.FormCloseEvent += this.CardDetailInfoBackEvent;
|
| | | }
|
| | | else
|
| | | {
|
| | | //mini夜灯
|
| | | var form = new ControlForm.DeviceMiniLightDetailCardForm();
|
| | | form.RowOrCardControl = this;
|
| | | form.AddForm(i_device, this.nowSelectRoom, 965, 1466);
|
| | | form.FormCloseEvent += this.CardDetailInfoBackEvent;
|
| | | }
|
| | | };
|
| | | }
|
| | |
|