using System;
using HDL_ON.Entity;
namespace HDL_ON.UI
{
public partial class RGBPage
{
void LoadEventList()
{
LoadColorChangeEvent();
LoadCollectionEvent();
LoadSwitchEvent();
//回退刷新信息事件
actionRefresh = () => {
btnFunctionName.Text = btnFunctionName_Out.Text = light.name;
btnFromFloor_Out.Text = btnFromFoorAndRoom.Text = light.GetRoomListName();
};
}
///
/// 颜色变化事件
///
void LoadColorChangeEvent()
{
DateTime colorChangeTime = DateTime.MinValue;
colorPicker.ColorChaged += (sender2, e2) => {
if ((DateTime.Now - colorChangeTime).TotalMilliseconds > 50)
{
//lightLigicBytes[6] = e2[0];
//lightLigicBytes[7] = e2[1];
//lightLigicBytes[8] = e2[2];
//Control.ControlBytesSend(Command.SetLogicLoopColor, lightRGB.SubnetID, lightRGB.DeviceID, lightLigicBytes, SendCount.Zero);
colorChangeTime = DateTime.Now;
btnCurColor.BackgroundColor = (uint)(0xFF000000 + e2[0] * 256 * 256 + e2[1] * 256 + e2[2]);
}
};
}
///
/// 收藏功能按钮事件
///
void LoadCollectionEvent()
{
btnCollection.MouseUpEventHandler += (sender, e) => {
btnCollection.IsSelected = light.collection = btnCollection_Out.IsSelected = !btnCollection.IsSelected;
DB_ResidenceData.residenceData.SaveResidenceData();
};
}
///
/// 加载开关事件
///
void LoadSwitchEvent()
{
btnSwitch.MouseUpEventHandler += (sender, e) =>
{
btnSwitch.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();
};
}
}
}