From 4f0ab0ad21ce450b7856d50f98322a7899361386 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期二, 22 九月 2020 10:30:01 +0800
Subject: [PATCH] 不要下载这个备份
---
ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceMiniLightDetailCardForm.cs | 522 +++++++++++++++++++++++++++++++++++++--------------------
1 files changed, 334 insertions(+), 188 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceMiniLightDetailCardForm.cs b/ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceMiniLightDetailCardForm.cs
index 66122d1..c30c0e5 100755
--- a/ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceMiniLightDetailCardForm.cs
+++ b/ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceMiniLightDetailCardForm.cs
@@ -8,36 +8,44 @@
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:鍙戦�佺殑鏄渹楦e櫒
/// </summary>
- private bool canSetProgressValue = true;
- /// <summary>
- /// 褰╃伅鏄惁鏄墦寮�鐘舵��(涓嶈兘鐢ㄦ帶浠剁殑Select鏉ュ垽鏂�,澶潙)
- /// </summary>
- private bool IsLightOpen = false;
+ private int sendDiv = 0;
#endregion
@@ -49,10 +57,11 @@
/// <param name="frameWhiteBack"></param>
public override void InitMiddleFrameAfter(FrameLayout frameWhiteBack)
{
+ //娣诲姞鎺ユ敹铚傞福鍣ˋck涓婚
+ this.AddReceiveBuzzerAckEvent();
+
//宸︽粦涓嶈兘
this.ScrollEnabled = false;
- //鍏堟竻绌�
- this.listControl = new List<ButtonBase>();
//璁剧疆鐘舵�佹枃瀛�
if (((LightBase)this.device).OnOffStatus == 1)
{
@@ -65,235 +74,360 @@
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 鈻� 鍙戦�佽渹楦e櫒寮�鍏冲懡浠________________
+
+ /// <summary>
+ /// 鍙戦�佽渹楦e櫒寮�鍏冲懡浠�
+ /// </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>
+ /// 娣诲姞鎺ユ敹铚傞福鍣ˋck涓婚
+ /// </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;
+ }
+ //杩欓噷鍙鐞嗚渹楦e櫒鐨�
+ if (this.sendDiv == 2)
+ {
+ //缁撴灉宸茬粡鎺ユ敹鍒�
+ this.ResponeResult = 1;
+ }
+ });
}
#endregion
@@ -330,45 +464,57 @@
/// <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
--
Gitblit v1.8.0