using System;
|
using HDL_ON.Entity;
|
|
namespace HDL_ON.UI
|
{
|
public partial class FunctionDiv
|
{
|
/// <summary>
|
/// 加载事件列表
|
/// </summary>
|
void LoadEventList()
|
{
|
LoadCollectionEvent();
|
}
|
|
/// <summary>
|
/// 加载收藏按钮事件
|
/// </summary>
|
void LoadCollectionEvent()
|
{
|
btnCollectionIcon.MouseUpEventHandler += (sender, e) => {
|
btnCollectionIcon.IsSelected = function.collection = !btnCollectionIcon.IsSelected;
|
DB_ResidenceData.residenceData.SaveResidenceData();
|
};
|
}
|
#region 灯光的事件列表
|
/// <summary>
|
/// 加载灯光控件的事件
|
/// </summary>
|
void LoadLightEventList()
|
{
|
LightSwitchEvent();
|
LightDivSkipEvent();
|
LightDimmingEvent();
|
}
|
/// <summary>
|
/// 灯光开关事件
|
/// </summary>
|
void LightSwitchEvent()
|
{
|
btnSwitch.MouseUpEventHandler += (sender, e) => {
|
btnSwitch.IsSelected = !btnSwitch.IsSelected;
|
new System.Threading.Thread(() =>
|
{
|
var light = function as Light;
|
light.state = btnSwitch.IsSelected ? 1 : 0;
|
Control.Send("write", function, 3);
|
})
|
{ IsBackground = true }.Start();
|
};
|
}
|
|
/// <summary>
|
/// 灯光亮度调节事件
|
/// </summary>
|
void LightDimmingEvent()
|
{
|
if (function.functionType == "Dimmer" || function.functionType == "RGB")
|
{
|
if (dimmerControlBar == null)
|
return;
|
|
var light = function as Light;
|
dimmerControlBar.OnProgressChangedEvent += (sender, e) =>
|
{
|
dimmerControlBar.Tag = DateTime.Now;
|
if ((DateTime.Now - (DateTime)(dimmerControlBar.Tag)).TotalMilliseconds < 200)//调光命令发送间隔事件
|
{
|
new System.Threading.Thread(() =>
|
{
|
light.dicPropert["brightness"] = (byte)e;
|
Control.Send("write", function, 3);
|
dimmerControlBar.Tag = DateTime.Now;
|
})
|
{ IsBackground = true }.Start();
|
}
|
};
|
dimmerControlBar.MouseUpEventHandler += (sender, e) =>
|
{
|
light.dicPropert["brightness"] = (byte)dimmerControlBar.Progress;
|
Control.Send("write", function, 3);
|
};
|
}
|
}
|
|
/// <summary>
|
/// 灯光控制界面跳转
|
/// </summary>
|
void LightDivSkipEvent()
|
{
|
this.MouseUpEventHandler += (sender, e) =>
|
{
|
//跳转到功能信息设置页面
|
switch (function.functionType)
|
{
|
case "Relay":
|
var relayView = new RelayPage(function as Light);
|
MainPage.BasePageView.AddChidren(relayView);
|
relayView.LoadPage();
|
MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
|
break;
|
case "RGB":
|
var rgbView = new RGBPage(function as Light);
|
MainPage.BasePageView.AddChidren(rgbView);
|
rgbView.LoadPage();
|
MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
|
break;
|
}
|
};
|
}
|
|
#endregion
|
}
|
}
|