using System;
|
using HDL_ON.Entity;
|
|
namespace HDL_ON.UI
|
{
|
public partial class RelayPage
|
{
|
/// <summary>
|
/// 加载事件列表
|
/// </summary>
|
void LoadEventList()
|
{
|
LoadSwitchEvent();
|
LoadCollectionEvent();
|
}
|
|
/// <summary>
|
/// 收藏功能按钮事件
|
/// </summary>
|
void LoadCollectionEvent()
|
{
|
btnCollection.MouseUpEventHandler += (sender, e) => {
|
btnCollection.IsSelected = light.collection = !btnCollection.IsSelected;
|
DB_ResidenceData.residenceData.SaveResidenceData();
|
};
|
}
|
|
/// <summary>
|
/// 加载开关事件
|
/// </summary>
|
void LoadSwitchEvent()
|
{
|
btnSwitchIcon.MouseUpEventHandler += (sender, e) =>
|
{
|
btnSwitchIcon.IsSelected = btnSwitch.IsSelected = !btnSwitchIcon.IsSelected;
|
|
new System.Threading.Thread(() =>
|
{
|
var light = this.light as Light;
|
light.state = btnSwitch.IsSelected ? 1 : 0;
|
Control.Send("write", this.light, 3);
|
})
|
{ IsBackground = true }.Start();
|
};
|
btnSwitch.MouseUpEventHandler += (sender, e) =>
|
{
|
btnSwitch.IsSelected = btnSwitchIcon.IsSelected = !btnSwitch.IsSelected;
|
|
new System.Threading.Thread(() =>
|
{
|
var light = this.light as Light;
|
light.state = btnSwitch.IsSelected ? 1 : 0;
|
Control.Send("write", this.light, 3);
|
})
|
{ IsBackground = true }.Start();
|
};
|
|
}
|
|
}
|
}
|