| | |
| | | namespace Shared.Phone.MainPage.ControlForm
|
| | | {
|
| | | /// <summary>
|
| | | /// 彩灯(调光器)类型的深度卡片界面
|
| | | /// mini夜灯的深度卡片界面
|
| | | /// </summary>
|
| | | public class DeviceMiniLightDetailCardForm : DeviceDetailCardCommonForm
|
| | | {
|
| | | #region ■ 变量声明___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 界面上可以操作的控件
|
| | | /// 蜂鸣器的开关控件
|
| | | /// </summary>
|
| | | private List<ButtonBase> listControl = new List<ButtonBase>();
|
| | | private IconBigViewControl btnBuzzerSwitch = null;
|
| | | /// <summary>
|
| | | /// mini夜灯的开关控件
|
| | | /// </summary>
|
| | | private IconBigViewControl btnMiniSwitch = null;
|
| | | /// <summary>
|
| | | /// 亮度的进度条控件
|
| | | /// </summary>
|
| | | private SeekBarControl seekBarLight = null;
|
| | | /// <summary>
|
| | | /// 色温的进度条控件
|
| | | /// </summary>
|
| | | private SeekBarControl seekBarColor = null;
|
| | | /// <summary>
|
| | | /// MaxLevel
|
| | | /// </summary>
|
| | | private const int MaxLevel = 254;
|
| | | /// <summary>
|
| | | /// 彩灯控件
|
| | | /// 亮度进度值是否在改变中
|
| | | /// </summary>
|
| | | private WaveSeekBar waveSeekBar = null;
|
| | | private bool isLightProgressing = false;
|
| | | /// <summary>
|
| | | /// 进度值是否在改变中
|
| | | /// 色温进度值是否在改变中
|
| | | /// </summary>
|
| | | private bool isProgressing = false;
|
| | | private bool isColorProgressing = false;
|
| | | /// <summary>
|
| | | /// 能否发送进度值
|
| | | /// 1:发送的是小夜灯 2:发送的是蜂鸣器
|
| | | /// </summary>
|
| | | private bool canSetProgressValue = true;
|
| | | /// <summary>
|
| | | /// 彩灯是否是打开状态(不能用控件的Select来判断,太坑)
|
| | | /// </summary>
|
| | | private bool IsLightOpen = false;
|
| | | private int sendDiv = 0;
|
| | |
|
| | | #endregion
|
| | |
|
| | |
| | | /// <param name="frameWhiteBack"></param>
|
| | | public override void InitMiddleFrameAfter(FrameLayout frameWhiteBack)
|
| | | {
|
| | | //添加接收蜂鸣器Ack主题
|
| | | this.AddReceiveBuzzerAckEvent();
|
| | |
|
| | | //左滑不能
|
| | | this.ScrollEnabled = false;
|
| | | //先清空
|
| | | this.listControl = new List<ButtonBase>();
|
| | | //设置状态文字
|
| | | if (((LightBase)this.device).OnOffStatus == 1)
|
| | | {
|
| | |
| | | this.SetStatuText(Language.StringByID(R.MyInternationalizationString.Close));
|
| | | }
|
| | |
|
| | | //彩灯控件
|
| | | this.waveSeekBar = new WaveSeekBar();
|
| | | waveSeekBar.Y = Application.GetRealHeight(233);
|
| | | waveSeekBar.Width = this.GetPictrueRealSize(253);
|
| | | waveSeekBar.Height = this.GetPictrueRealSize(516);
|
| | | waveSeekBar.Gravity = Gravity.CenterHorizontal;
|
| | | waveSeekBar.WavePadding = Application.GetRealWidth(8);
|
| | | waveSeekBar.MaxValue = 100;
|
| | | waveSeekBar.Progress = (int)(((DimmableLight)this.device).Level * 1.0 / MaxLevel * 100);
|
| | | waveSeekBar.CornerRadius = Application.GetRealHeight(58);
|
| | | frameWhiteBack.AddChidren(waveSeekBar);
|
| | | //亮度
|
| | | var btnLightView = new NormalViewControl(300, 60, true);
|
| | | btnLightView.Text = Language.StringByID(R.MyInternationalizationString.uBrightness) + ":";
|
| | | btnLightView.X = Application.GetRealWidth(43);
|
| | | btnLightView.Y = Application.GetRealHeight(320);
|
| | | frameWhiteBack.AddChidren(btnLightView);
|
| | | //底线
|
| | | var btnLightLine = new NormalViewControl(Application.GetRealWidth(841), ControlCommonResourse.BottomLineHeight, false);
|
| | | btnLightLine.BackgroundColor = UserCenterColor.Current.ButtomLine;
|
| | | btnLightLine.X = btnLightView.X;
|
| | | btnLightLine.Y = btnLightView.Bottom + Application.GetRealHeight(37);
|
| | | frameWhiteBack.AddChidren(btnLightLine);
|
| | | //进度条(+60的偏移量)
|
| | | this.seekBarLight = new SeekBarControl(611 + 120);
|
| | | seekBarLight.Y = Application.GetRealHeight(280);
|
| | | seekBarLight.X = Application.GetRealWidth(266 - 60);
|
| | | seekBarLight.Height = Application.GetRealHeight(144);
|
| | | seekBarLight.SeekBarViewHeight = Application.GetRealHeight(20);
|
| | | seekBarLight.SeekBarPadding = Application.GetRealWidth(60);
|
| | | seekBarLight.IsProgressTextShow = true;
|
| | | seekBarLight.ProgressBarColor = 0xffff6c2c;
|
| | | seekBarLight.ProgressTextSize = 14;
|
| | | seekBarLight.ProgressTextColor = UserCenterColor.Current.TextGrayColor2;
|
| | | seekBarLight.Gravity = Gravity.Frame;
|
| | | seekBarLight.Progress = (int)(((ColorTemperatureLight)this.device).Level * 1.0 / MaxLevel * 100);
|
| | | frameWhiteBack.AddChidren(seekBarLight);
|
| | |
|
| | | //色温
|
| | | var btnColorView = new NormalViewControl(300, 60, true);
|
| | | btnColorView.Text = Language.StringByID(R.MyInternationalizationString.uColorTemperature) + ":";
|
| | | btnColorView.X = Application.GetRealWidth(43);
|
| | | btnColorView.Y = btnLightLine.Y + Application.GetRealHeight(107);
|
| | | frameWhiteBack.AddChidren(btnColorView);
|
| | | //底线
|
| | | var btnColorLine = new NormalViewControl(Application.GetRealWidth(841), ControlCommonResourse.BottomLineHeight, false);
|
| | | btnColorLine.BackgroundColor = UserCenterColor.Current.ButtomLine;
|
| | | btnColorLine.X = btnColorView.X;
|
| | | btnColorLine.Y = btnColorView.Bottom + Application.GetRealHeight(37);
|
| | | frameWhiteBack.AddChidren(btnColorLine);
|
| | | //色温的渐变色背景
|
| | | var btnColorBack = new PicViewControl(611, 20);
|
| | | btnColorBack.UnSelectedImagePath = "Item/ColorTemperatureBar.png";
|
| | | btnColorBack.X = Application.GetRealWidth(266);
|
| | | btnColorBack.Y = btnColorView.Y + btnColorView.Height / 2 - HdlControlLogic.Current.GetPictrueRealSize(20) / 2;
|
| | | frameWhiteBack.AddChidren(btnColorBack);
|
| | | //进度条(+60的偏移量,色温的范围是 3000~6000)
|
| | | this.seekBarColor = new SeekBarControl(611 + 120);
|
| | | seekBarColor.Y = btnLightLine.Bottom + Application.GetRealHeight(88);
|
| | | seekBarColor.X = Application.GetRealWidth(266 - 60);
|
| | | seekBarColor.SeekBarViewHeight = Application.GetRealHeight(20);
|
| | | seekBarColor.SeekBarPadding = Application.GetRealWidth(60);
|
| | | seekBarColor.ProgressBarColor = UserCenterColor.Current.Transparent;
|
| | | seekBarColor.ProgressBarUnEnableColor = UserCenterColor.Current.Transparent;
|
| | | seekBarColor.SeekBarBackgroundColor = UserCenterColor.Current.Transparent;
|
| | | seekBarColor.ProgressTextSize = 14;
|
| | | seekBarColor.ProgressTextColor = UserCenterColor.Current.TextGrayColor2;
|
| | | seekBarColor.Gravity = Gravity.Frame;
|
| | | seekBarColor.MinValue = 30;
|
| | | seekBarColor.MaxValue = 60;
|
| | | seekBarColor.ProgressChangeDelayTime = 0;
|
| | | frameWhiteBack.AddChidren(seekBarColor);
|
| | | //显示自定义文本
|
| | | seekBarColor.ShowCustomTextView(Application.GetRealWidth(200), 15, UserCenterColor.Current.TextGrayColor3);
|
| | | //设置初始值
|
| | | int colorValue = ((ColorTemperatureLight)this.device).ColorTemperature;
|
| | | if (colorValue == 0) { colorValue = 3000; }
|
| | | seekBarColor.Progress = colorValue / 100;
|
| | | seekBarColor.SetCustomText(seekBarColor.Progress * 100 + "K");
|
| | |
|
| | | //蜂鸣器开关:
|
| | | var btnBuzzerView = new NormalViewControl(300, 60, true);
|
| | | btnBuzzerView.Text = Language.StringByID(R.MyInternationalizationString.uBuzzerSwitch) + ":";
|
| | | btnBuzzerView.X = Application.GetRealWidth(43);
|
| | | btnBuzzerView.Y = btnColorLine.Y + Application.GetRealHeight(107);
|
| | | frameWhiteBack.AddChidren(btnBuzzerView);
|
| | | //底线
|
| | | var btnBuzzerLine = new NormalViewControl(Application.GetRealWidth(841), ControlCommonResourse.BottomLineHeight, false);
|
| | | btnBuzzerLine.BackgroundColor = UserCenterColor.Current.ButtomLine;
|
| | | btnBuzzerLine.X = btnBuzzerView.X;
|
| | | btnBuzzerLine.Y = btnBuzzerView.Bottom + Application.GetRealHeight(37);
|
| | | frameWhiteBack.AddChidren(btnBuzzerLine);
|
| | | //开关
|
| | | var btnSwitch = new IconViewControl(81);
|
| | | btnSwitch.UnSelectedImagePath = "Item/Switch.png";
|
| | | btnSwitch.SelectedImagePath = "Item/SwitchSelected.png";
|
| | | btnSwitch.Y = waveSeekBar.Bottom + Application.GetRealHeight(418);
|
| | | btnSwitch.Gravity = Gravity.CenterHorizontal;
|
| | | frameWhiteBack.AddChidren(btnSwitch);
|
| | | listControl.Add(btnSwitch);
|
| | | btnSwitch.ButtonClickEvent += (sender, e) =>
|
| | | this.btnBuzzerSwitch = new IconBigViewControl(81, 81);
|
| | | btnBuzzerSwitch.UnSelectedImagePath = "Item/Switch.png";
|
| | | btnBuzzerSwitch.SelectedImagePath = "Item/SwitchSelected.png";
|
| | | btnBuzzerSwitch.IsSelected = ((ColorTemperatureLight)this.device).IsBuzzerRing;
|
| | | frameWhiteBack.AddChidren(btnBuzzerSwitch);
|
| | | btnBuzzerSwitch.InitControl();
|
| | | btnBuzzerSwitch.UseClickStatu = false;
|
| | | btnBuzzerSwitch.X = Application.GetRealWidth(795) - btnBuzzerSwitch.XOffset;
|
| | | btnBuzzerSwitch.Y = btnColorLine.Y + Application.GetRealHeight(98) - btnBuzzerSwitch.YOffset;
|
| | | btnBuzzerSwitch.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //发送开关命令
|
| | | this.SetSwitchCommand(!btnSwitch.IsSelected);
|
| | | this.SetBuzzerSwitchCommand(!btnBuzzerSwitch.IsSelected);
|
| | | };
|
| | |
|
| | | //设置初始状态
|
| | | this.IsLightOpen = ((LightBase)this.device).OnOffStatus == 1;
|
| | | this.canSetProgressValue = this.IsLightOpen;
|
| | | if (IsLightOpen == true)
|
| | | //小夜灯开关:
|
| | | var btnMiniView = new NormalViewControl(300, 60, true);
|
| | | btnMiniView.Text = Language.StringByID(R.MyInternationalizationString.uMiniLightSwitch) + ":";
|
| | | btnMiniView.X = Application.GetRealWidth(43);
|
| | | btnMiniView.Y = btnBuzzerLine.Y + Application.GetRealHeight(107);
|
| | | frameWhiteBack.AddChidren(btnMiniView);
|
| | | //底线
|
| | | var btnMiniLine = new NormalViewControl(Application.GetRealWidth(841), ControlCommonResourse.BottomLineHeight, false);
|
| | | btnMiniLine.BackgroundColor = UserCenterColor.Current.ButtomLine;
|
| | | btnMiniLine.X = btnMiniView.X;
|
| | | btnMiniLine.Y = btnMiniView.Bottom + Application.GetRealHeight(37);
|
| | | frameWhiteBack.AddChidren(btnMiniLine);
|
| | | //开关
|
| | | this.btnMiniSwitch = new IconBigViewControl(81, 81);
|
| | | btnMiniSwitch.UnSelectedImagePath = "Item/Switch.png";
|
| | | btnMiniSwitch.SelectedImagePath = "Item/SwitchSelected.png";
|
| | | frameWhiteBack.AddChidren(btnMiniSwitch);
|
| | | btnMiniSwitch.InitControl();
|
| | | btnMiniSwitch.UseClickStatu = false;
|
| | | btnMiniSwitch.X = Application.GetRealWidth(795) - btnMiniSwitch.XOffset;
|
| | | btnMiniSwitch.Y = btnBuzzerLine.Y + Application.GetRealHeight(98) - btnMiniSwitch.YOffset;
|
| | | btnMiniSwitch.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | btnSwitch.IsSelected = true;
|
| | | waveSeekBar.IsClickable = true;
|
| | | waveSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarColor_Start, ZigbeeColor.Current.GXCWaveSeekBarColor_End);
|
| | | }
|
| | | else
|
| | | {
|
| | | waveSeekBar.IsClickable = false;
|
| | | waveSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor, ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor);
|
| | | }
|
| | | //发送开关命令
|
| | | this.SetLightSwitchCommand(!btnMiniSwitch.IsSelected);
|
| | | };
|
| | | btnMiniSwitch.IsSelected = ((LightBase)this.device).OnOffStatus == 1;
|
| | |
|
| | | //彩灯控件里面的那个显示百分比的控件
|
| | | int progressY = waveSeekBar.Y - Application.GetMinReal(154);
|
| | | var btnProgress = new NormalViewControl(Application.GetMinReal(135), Application.GetMinReal(104), false);
|
| | | btnProgress.Y = progressY;
|
| | | btnProgress.UnSelectedImagePath = "Item/ProgressBubbles.png";
|
| | | btnProgress.IsBold = true;
|
| | | btnProgress.TextColor = UserCenterColor.Current.White;
|
| | | btnProgress.Gravity = Gravity.CenterHorizontal;
|
| | | btnProgress.TextAlignment = TextAlignment.Center;
|
| | | frameWhiteBack.AddChidren(btnProgress);
|
| | | btnProgress.Visible = false;
|
| | |
|
| | | //开始滑动的事件
|
| | | waveSeekBar.OnStartTrackingTouchEvent += (sender, e) =>
|
| | | //亮度开始滑动的事件
|
| | | seekBarLight.OnStartTrackingTouchEvent += (sender, e) =>
|
| | | {
|
| | | //进度值开始变更
|
| | | this.isProgressing = true;
|
| | | //变更进度百分比的显示
|
| | | btnProgress.Y = progressY + waveSeekBar.NowProgressY;
|
| | | btnProgress.Text = waveSeekBar.Progress + "%";
|
| | | waveSeekBar.IsProgressTextShow = false;
|
| | | if (btnProgress.Visible == false)
|
| | | {
|
| | | btnProgress.Visible = true;
|
| | | }
|
| | | this.isLightProgressing = true;
|
| | | };
|
| | |
|
| | | //结束滑动的事件
|
| | | waveSeekBar.OnStopTrackingTouchEvent += (sender, e) =>
|
| | | //亮度结束滑动的事件
|
| | | seekBarLight.OnStopTrackingTouchEvent += (sender, e) =>
|
| | | {
|
| | | //进度值开始结束
|
| | | this.isProgressing = false;
|
| | | btnProgress.Visible = false;
|
| | | waveSeekBar.IsProgressTextShow = true;
|
| | | this.isLightProgressing = false;
|
| | | };
|
| | |
|
| | | //滑动过程中
|
| | | int oldProgressValue = waveSeekBar.Progress;//之前的值
|
| | | int nowProgressValue = oldProgressValue;//变更的值
|
| | | waveSeekBar.OnProgressChangedEvent += (sender, value) =>
|
| | | //亮度滑动过程中
|
| | | int oldLightValue = seekBarLight.Progress;//之前的值
|
| | | int nowLightValue = oldLightValue;//变更的值
|
| | | seekBarLight.OnProgressChangedEvent += (sender, value) =>
|
| | | {
|
| | | //变更进度百分比的显示
|
| | | btnProgress.Y = progressY + waveSeekBar.NowProgressY;
|
| | | btnProgress.Text = value + "%";
|
| | | if (Common.Config.Instance.Home.IsVirtually == false)
|
| | | {
|
| | | nowProgressValue = value;
|
| | | //能够发送进度值的时候,才记录
|
| | | nowLightValue = value;
|
| | | }
|
| | | else
|
| | | {
|
| | | //如果住宅为虚拟住宅,直接改缓存
|
| | | ((DimmableLight)this.device).Level = value * MaxLevel / 100;
|
| | | ((ColorTemperatureLight)this.device).Level = value * MaxLevel / 100;
|
| | | //亮度 XX
|
| | | this.SetStatuText(Language.StringByID(R.MyInternationalizationString.uBrightness) + " " + HdlDeviceOtherLogic.Current.GetDeviceStatu(this.device));
|
| | | }
|
| | | };
|
| | |
|
| | | //色温
|
| | | var btnColor = new NormalViewControl(300, 50, true);
|
| | | btnColor.X = Application.GetRealWidth(132);
|
| | | btnColor.Y = Application.GetRealHeight(829);
|
| | | btnColor.TextSize = 12;
|
| | | btnColor.Text = Language.StringByID(R.MyInternationalizationString.uColorTemperature) + ":";
|
| | | btnColor.TextColor = UserCenterColor.Current.TextGrayColor3;
|
| | | frameWhiteBack.AddChidren(btnColor);
|
| | | //上部显示文本
|
| | | var btnColorView = new NormalViewControl(150, 60, true);
|
| | | btnColorView.Y = btnColor.Bottom;
|
| | | btnColorView.TextAlignment = TextAlignment.Center;
|
| | | btnColorView.TextSize = 15;
|
| | | btnColorView.Gravity = Gravity.CenterHorizontal;
|
| | | btnColorView.TextColor = UserCenterColor.Current.TextGrayColor3;
|
| | | frameWhiteBack.AddChidren(btnColorView);
|
| | | //进度条(色温的范围是 3400~6000)
|
| | | var seekBar1 = new SeekBarControl(683);
|
| | | seekBar1.Y = btnColorView.Bottom;
|
| | | seekBar1.MinValue = 34;
|
| | | seekBar1.MaxValue = 60;
|
| | | seekBar1.ProgressBarColor = 0xff707070;
|
| | | seekBar1.SeekBarViewHeight = Application.GetRealHeight(19);
|
| | | frameWhiteBack.AddChidren(seekBar1);
|
| | |
|
| | | int oldColorValue = 0;
|
| | | int nowColorValue = 0;
|
| | | seekBar1.ProgressChangedEvent += (div, value) =>
|
| | | //色温开始滑动的事件
|
| | | seekBarColor.OnStartTrackingTouchEvent += (sender, e) =>
|
| | | {
|
| | | //数据变更
|
| | | btnColorView.Text = value * 100 + "K";
|
| | | //进度值开始变更
|
| | | this.isColorProgressing = true;
|
| | | };
|
| | |
|
| | | //色温结束滑动的事件
|
| | | seekBarColor.OnStopTrackingTouchEvent += (sender, e) =>
|
| | | {
|
| | | //进度值开始结束
|
| | | this.isColorProgressing = false;
|
| | | };
|
| | |
|
| | | //色温滑动过程中
|
| | | int oldColorValue = seekBarColor.Progress;//之前的值
|
| | | int nowColorValue = oldColorValue;//变更的值
|
| | | seekBarColor.OnProgressChangedEvent += (sender, value) =>
|
| | | {
|
| | | //设置自定义的文本
|
| | | seekBarColor.SetCustomText(value * 100 + "K");
|
| | | if (Common.Config.Instance.Home.IsVirtually == false)
|
| | | {
|
| | | //能够发送进度值的时候,才记录
|
| | | nowColorValue = value;
|
| | | }
|
| | | else
|
| | | {
|
| | | //如果住宅为虚拟住宅,直接改缓存
|
| | | ((ColorTemperatureLight)this.device).ColorTemperature = value * 100;
|
| | | }
|
| | | };
|
| | | //设置初始值
|
| | | seekBar1.Progress = 34;
|
| | | btnColorView.Text = 34 * 100 + "K";
|
| | | if (Config.Instance.Home.IsVirtually == true)
|
| | | {
|
| | | //虚拟住宅
|
| | | return;
|
| | | }
|
| | |
|
| | | //开一个线程,监视是否滑动的滑动条,每秒检测一次
|
| | | //开一个线程,监视是否滑动的滑动条,每秒检测一次
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | while (this.Parent != null)
|
| | | {
|
| | | System.Threading.Thread.Sleep(1000);
|
| | | //能够发送
|
| | | if (this.canSetProgressValue == true)
|
| | | //发送亮度值
|
| | | if (nowLightValue != oldLightValue)
|
| | | {
|
| | | //发送亮度值
|
| | | if (nowProgressValue != oldProgressValue)
|
| | | {
|
| | | oldProgressValue = nowProgressValue;
|
| | | ((DimmableLight)this.device).SetLevel((int)(oldProgressValue * MaxLevel / 100.0));
|
| | | }
|
| | | //发送色温值
|
| | | if (nowColorValue != oldColorValue)
|
| | | {
|
| | | oldColorValue = nowColorValue;
|
| | | }
|
| | | oldLightValue = nowLightValue;
|
| | | ((ColorTemperatureLight)this.device).SetLevel((int)(oldLightValue * MaxLevel / 100.0));
|
| | | }
|
| | | //发送色温值
|
| | | if (nowColorValue != oldColorValue)
|
| | | {
|
| | | oldColorValue = nowColorValue;
|
| | | int value = 1000000 / (oldColorValue * 100);
|
| | | ((ColorTemperatureLight)this.device).SetColorTemperature(value);
|
| | | }
|
| | | }
|
| | | //界面关闭时
|
| | | if (nowProgressValue != oldProgressValue)
|
| | | if (nowLightValue != oldLightValue)
|
| | | {
|
| | | //发送亮度值
|
| | | ((DimmableLight)this.device).SetLevel((int)(nowProgressValue * MaxLevel / 100.0));
|
| | | ((ColorTemperatureLight)this.device).SetLevel((int)(nowLightValue * MaxLevel / 100.0));
|
| | | }
|
| | | if (nowColorValue != oldColorValue)
|
| | | {
|
| | | //发送色温值
|
| | | int value = 1000000 / (nowColorValue * 100);
|
| | | ((ColorTemperatureLight)this.device).SetColorTemperature(value);
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 发送开关命令_______________________
|
| | | #region ■ 发送夜灯开关命令___________________
|
| | |
|
| | | /// <summary>
|
| | | /// 发送开关命令
|
| | | /// 发送夜灯开关命令
|
| | | /// </summary>
|
| | | /// <param name="isOpen"></param>
|
| | | private void SetSwitchCommand(bool isOpen)
|
| | | private void SetLightSwitchCommand(bool isOpen)
|
| | | {
|
| | | //获取当前亮度
|
| | | int level = Convert.ToInt32(this.device.GetType().InvokeMember("Level", System.Reflection.BindingFlags.GetField, null, this.device, null));
|
| | | //如果住宅是虚拟住宅
|
| | | if (Common.Config.Instance.Home.IsVirtually == true)
|
| | | {
|
| | | ((LightBase)this.device).OnOffStatus = isOpen == true ? 1 : 0;
|
| | | if (((LightBase)this.device).OnOffStatus == 1 && level == 0)
|
| | | {
|
| | | //如果当前是打开状态,并且亮度为0的话,则需要变成100%亮度
|
| | | this.device.GetType().InvokeMember("Level", System.Reflection.BindingFlags.SetField, null, this.device, new object[] { 100 });
|
| | | }
|
| | | //刷新开关状态
|
| | | this.RefreshSwitchStatu(isOpen);
|
| | | return;
|
| | | }
|
| | |
|
| | | //当按下开关按钮时,不能再发送进度值
|
| | | this.canSetProgressValue = false;
|
| | |
|
| | | //检测是否获取网关反馈的结果,如果网关没有回复,则会弹出消息
|
| | | this.StartCheckResponeResult(this.listControl, (result) =>
|
| | | {
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | //接收到网关回复
|
| | | if (result == true)
|
| | | {
|
| | | bool statu = ((LightBase)this.device).OnOffStatus == 1;
|
| | | //刷新开关状态
|
| | | this.RefreshSwitchStatu(statu);
|
| | | if (statu == true)
|
| | | {
|
| | | //等待结果结束后,彩灯控件可以滑动
|
| | | waveSeekBar.IsClickable = true;
|
| | | }
|
| | | }
|
| | | });
|
| | | });
|
| | | this.StartCheckResponeResult(new List<ButtonBase> { this.btnMiniSwitch.btnIcon }, (result) =>
|
| | | {
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | //接收到网关回复
|
| | | if (result == true)
|
| | | {
|
| | | bool statu = ((LightBase)this.device).OnOffStatus == 1;
|
| | | //刷新开关状态
|
| | | this.RefreshSwitchStatu(statu);
|
| | | }
|
| | | });
|
| | | });
|
| | |
|
| | | //发送等待的时间内,不能滑动彩灯控件
|
| | | waveSeekBar.IsClickable = false;
|
| | | //状态取反
|
| | | listControl[0].IsSelected = !listControl[0].IsSelected;
|
| | | this.sendDiv = 1;
|
| | | if (isOpen == true)
|
| | | {
|
| | | //打开
|
| | | this.device.SwitchControl(1);
|
| | | if (level == 0)
|
| | | {
|
| | | //如果当前是打开状态,并且亮度为0的话,则需要变成100%亮度
|
| | | this.device.GetType().InvokeMember("SetLevel", System.Reflection.BindingFlags.InvokeMethod, null, this.device, new object[] { 254 });
|
| | | }
|
| | | else
|
| | | {
|
| | | this.device.SwitchControl(1);
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | //关闭
|
| | | this.device.SwitchControl(0);
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 发送蜂鸣器开关命令_________________
|
| | |
|
| | | /// <summary>
|
| | | /// 发送蜂鸣器开关命令
|
| | | /// </summary>
|
| | | /// <param name="isOpen"></param>
|
| | | private void SetBuzzerSwitchCommand(bool isOpen)
|
| | | {
|
| | | //如果住宅是虚拟住宅
|
| | | if (Common.Config.Instance.Home.IsVirtually == true)
|
| | | {
|
| | | ((ColorTemperatureLight)this.device).IsBuzzerRing = isOpen;
|
| | | //刷新开关状态
|
| | | this.RefreshSwitchStatu(isOpen);
|
| | | return;
|
| | | }
|
| | |
|
| | | //检测是否获取网关反馈的结果,如果网关没有回复,则会弹出消息
|
| | | this.btnBuzzerSwitch.CanClick = false;
|
| | | this.StartCheckResponeResult(new List<ButtonBase>(), (result) =>
|
| | | {
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | //接收到网关回复
|
| | | this.btnBuzzerSwitch.CanClick = true;
|
| | | if (result == true)
|
| | | {
|
| | | this.btnBuzzerSwitch.IsSelected = isOpen;
|
| | | }
|
| | | });
|
| | | });
|
| | | //发送命令
|
| | | this.sendDiv = 2;
|
| | | ((ColorTemperatureLight)this.device).SendBuzzerSwitchControl(isOpen);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 添加接收蜂鸣器Ack主题
|
| | | /// </summary>
|
| | | private void AddReceiveBuzzerAckEvent()
|
| | | {
|
| | | //Ack主题上报
|
| | | string mainKeys = LocalDevice.Current.GetDeviceMainKeys(this.device);
|
| | | HdlGatewayReceiveLogic.Current.AddAttributeEvent("DeviceBuzzerDetailCardACK", ReceiveComandDiv.A节点控制反馈, (report) =>
|
| | | {
|
| | | string mainKey2 = LocalDevice.Current.GetDeviceMainKeys(report);
|
| | | if (mainKeys != mainKey2)
|
| | | {
|
| | | //不是同一个东西
|
| | | return;
|
| | | }
|
| | | //这里只处理蜂鸣器的
|
| | | if (this.sendDiv == 2)
|
| | | {
|
| | | //结果已经接收到
|
| | | this.ResponeResult = 1;
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | /// <param name="isOpen">打开状态</param>
|
| | | private void RefreshSwitchStatu(bool isOpen)
|
| | | {
|
| | | //刷新蜂鸣器开关状态
|
| | | bool isBuzzerRing = ((ColorTemperatureLight)this.device).IsBuzzerRing;
|
| | | if (this.btnBuzzerSwitch.IsSelected != isBuzzerRing)
|
| | | {
|
| | | this.btnBuzzerSwitch.IsSelected = isBuzzerRing;
|
| | | }
|
| | |
|
| | | if (isOpen == true)
|
| | | {
|
| | | //亮度是必须要刷新的 亮度 XX
|
| | | this.SetStatuText(Language.StringByID(R.MyInternationalizationString.uBrightness) + " " + HdlDeviceOtherLogic.Current.GetDeviceStatu(this.device));
|
| | | if (this.isProgressing == false)
|
| | | if (this.btnMiniSwitch.IsSelected == false)
|
| | | {
|
| | | //当进度值在手动变更中时,不接收推送
|
| | | waveSeekBar.Progress = (int)(((DimmableLight)this.device).Level * 1.0 / MaxLevel * 100);
|
| | | this.btnMiniSwitch.IsSelected = true;
|
| | | }
|
| | | }
|
| | | if (isOpen == false && this.IsLightOpen == true)
|
| | | else
|
| | | {
|
| | | //状态不一样,才变更字样:关闭
|
| | | this.SetStatuText(Language.StringByID(R.MyInternationalizationString.Close));
|
| | | if (this.btnMiniSwitch.IsSelected == true)
|
| | | {
|
| | | this.btnMiniSwitch.IsSelected = false;
|
| | | //变更字样:关闭
|
| | | this.SetStatuText(Language.StringByID(R.MyInternationalizationString.Close));
|
| | | }
|
| | | }
|
| | |
|
| | | if (listControl[0].IsSelected != isOpen)
|
| | | if (this.isLightProgressing == false)
|
| | | {
|
| | | //开关状态变更
|
| | | listControl[0].IsSelected = isOpen;
|
| | | //当进度值在手动变更中时,不接收推送
|
| | | seekBarLight.Progress = (int)(((ColorTemperatureLight)this.device).Level * 1.0 / MaxLevel * 100);
|
| | | }
|
| | | if (this.isColorProgressing == false)
|
| | | {
|
| | | //当进度值在手动变更中时,不接收推送
|
| | | seekBarColor.Progress = (int)(((ColorTemperatureLight)this.device).ColorTemperature / 100);
|
| | | //设置自定义的文本
|
| | | seekBarColor.SetCustomText(seekBarColor.Progress * 100 + "K");
|
| | | }
|
| | | }
|
| | |
|
| | | //状态不一样才变更
|
| | | if (this.IsLightOpen != isOpen)
|
| | | {
|
| | | if (isOpen == true)
|
| | | {
|
| | | waveSeekBar.IsClickable = true;
|
| | | waveSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarColor_Start, ZigbeeColor.Current.GXCWaveSeekBarColor_End);
|
| | | }
|
| | | else
|
| | | {
|
| | | waveSeekBar.IsClickable = false;
|
| | | waveSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor, ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor);
|
| | | }
|
| | | }
|
| | | this.IsLightOpen = isOpen;
|
| | | //回复的结果说,处于打开状态才能发送
|
| | | this.canSetProgressValue = this.IsLightOpen;
|
| | | #endregion
|
| | |
|
| | | #region ■ 界面关闭___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 界面关闭
|
| | | /// </summary>
|
| | | public override void CloseFormBefore()
|
| | | {
|
| | | base.CloseFormBefore();
|
| | | HdlGatewayReceiveLogic.Current.RemoveEvent("DeviceBuzzerDetailCardACK");
|
| | | }
|
| | |
|
| | | #endregion
|