using System;
using System.Collections.Generic;
using HDL_ON.DriverLayer;
using HDL_ON.Entity;
using HDL_ON.Stan;
using HDL_ON.UI.CSS;
using Shared;
namespace HDL_ON.UI
{
public class IrFanPage : DeviceFunctionCardCommonForm
{
#region ■ 变量声明___________________________
///
/// 图标
///
private Button btnIcon = null;
#endregion
#region ■ 初始化_____________________________
///
/// 初始化白色区域的内容
///
public override void InitFrameWhiteContent()
{
base.ShowColltionButton = false;
base.SetTitleText(Language.StringByID(StringId.Electric));
//初始化第一个索引页的内容
this.InitFrameWhiteContent1();
}
///
/// 初始化第一个索引页的内容
///
private void InitFrameWhiteContent1()
{
btnIcon = new Button()
{
Gravity = Gravity.CenterHorizontal,
Y = Application.GetRealHeight(88),
Width = Application.GetRealWidth(134),
Height = Application.GetRealWidth(134),
UnSelectedImagePath = "FunctionIcon/IrFan/FanIcon.png",
};
FrameWhiteCentet1.AddChidren(btnIcon);
var patternView = new IrFanControl("FunctionIcon/IrFan/PatternIcon.png",
"FunctionIcon/IrFan/PatternIconOn.png",
Language.StringByID(StringId.Mode),
"");
patternView.Y = Application.GetRealHeight(263);
patternView.X = Application.GetRealWidth(36);
patternView.Width = Application.GetRealWidth(96);
patternView.Height = Application.GetRealHeight(74);
FrameWhiteCentet1.AddChidren(patternView);
EventHandler mode_EventHandler = (sender, e) =>
{
Dictionary d = new Dictionary();
d.Add("mode", "");
Control.Ins.SendWriteCommand(device, d);
};
patternView.SetThouchEvent(mode_EventHandler);
var swingView = new IrFanControl("FunctionIcon/IrFan/HeadSwingingIcon.png",
"FunctionIcon/IrFan/HeadSwingingIconOn.png",
Language.StringByID(StringId.HeadSwinging),
"");
swingView.Y = Application.GetRealHeight(263);
swingView.X = Application.GetRealWidth(229-34);
swingView.Width = Application.GetRealWidth(96);
swingView.Height = Application.GetRealHeight(74);
FrameWhiteCentet1.AddChidren(swingView);
EventHandler swing_EventHandler = (sender, e) =>
{
Dictionary d = new Dictionary();
d.Add("swing", "");
Control.Ins.SendWriteCommand(device, d);
};
swingView.SetThouchEvent(swing_EventHandler);
var timingView = new IrFanControl("FunctionIcon/IrFan/TimingIcon.png",
"FunctionIcon/IrFan/TimingIconOn.png",
Language.StringByID(StringId.Timing),
"");
timingView.Y = Application.GetRealHeight(366);
timingView.X = Application.GetRealWidth(36);
timingView.Width = Application.GetRealWidth(96);
timingView.Height = Application.GetRealHeight(74);
FrameWhiteCentet1.AddChidren(timingView);
EventHandler timing_EventHandler = (sender, e) =>
{
Dictionary d = new Dictionary();
d.Add("timer", "");
Control.Ins.SendWriteCommand(device, d);
};
timingView.SetThouchEvent(timing_EventHandler);
var airVolumeView = new IrFanControl("FunctionIcon/IrFan/SpeedIcon.png",
"FunctionIcon/IrFan/SpeedIconOn.png",
Language.StringByID(StringId.AirVolume),
"");
airVolumeView.Y = Application.GetRealHeight(366);
airVolumeView.X = Application.GetRealWidth(229 - 34);
airVolumeView.Width = Application.GetRealWidth(96);
airVolumeView.Height = Application.GetRealHeight(74);
FrameWhiteCentet1.AddChidren(airVolumeView);
EventHandler speed_EventHandler = (sender, e) =>
{
Dictionary d = new Dictionary();
d.Add("speed", "");
Control.Ins.SendWriteCommand(device, d);
};
airVolumeView.SetThouchEvent(speed_EventHandler);
Button btnPower = new Button()
{
Gravity = Gravity.CenterHorizontal,
Y = Application.GetRealHeight(468),
Width = Application.GetRealWidth(32),
Height = Application.GetRealWidth(32),
UnSelectedImagePath = "FunctionIcon/IrFan/PowerIcon.png",
SelectedImagePath = "FunctionIcon/IrFan/PowerIconOn.png"
};
FrameWhiteCentet1.AddChidren(btnPower);
btnPower.MouseDownEventHandler = (sender, e) =>
{
btnPower.IsSelected = true;
};
btnPower.MouseUpEventHandler = (sender, e) => {
new System.Threading.Thread(() => {
Dictionary d = new Dictionary();
d.Add(FunctionAttributeKey.OnOff, "");
Control.Ins.SendWriteCommand(device, d);
System.Threading.Thread.Sleep(500);
Application.RunOnMainThread(() => {
btnPower.IsSelected = false;
});
}) { IsBackground = true }.Start();
};
}
#endregion
#region ■ 设备状态反馈_______________________
///
/// 设备状态反馈
///
///
public override void DeviceStatuPush(Function i_LocalDevice)
{
}
#endregion
}
public class IrFanControl : FrameLayout
{
private Button btnIcon;
private Button btnTitle;
public bool Lighting = false;
public IrFanControl(string unSelectedIconPath, string selectedIconPath, string title, string time)
{
btnIcon = new Button()
{
Gravity = Gravity.CenterHorizontal,
Width = Application.GetRealWidth(28),
Height = Application.GetRealWidth(28),
UnSelectedImagePath = unSelectedIconPath,
SelectedImagePath = selectedIconPath,
};
this.AddChidren(btnIcon);
btnTitle = new Button()
{
Y = Application.GetRealWidth(28),
Text = title,
Height = Application.GetRealHeight(30),
TextColor = CSS_Color.TextualColor,
SelectedTextColor = CSS_Color.MainColor,
TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
};
this.AddChidren(btnTitle);
}
public void SetViewStatus(bool state)
{
btnIcon.IsSelected = btnTitle.IsSelected = Lighting = state;
}
///
/// 设置点击事件
///
public void SetThouchEvent(EventHandler eventHandler)
{
btnIcon.MouseUpEventHandler = eventHandler;
btnTitle.MouseUpEventHandler = eventHandler;
btnIcon.MouseDownEventHandler = (sender, e) => {
btnTitle.IsSelected = true;
btnIcon.IsSelected = true;
};
btnTitle.MouseDownEventHandler = (sender, e) => {
btnTitle.IsSelected = true;
btnIcon.IsSelected = true;
};
btnIcon.MouseUpEventHandler += (sender, e) => {
new System.Threading.Thread(() => {
System.Threading.Thread.Sleep(500);
Application.RunOnMainThread(() =>
{
btnTitle.IsSelected = false;
btnIcon.IsSelected = false;
});
})
{ IsBackground = true }.Start();
};
btnTitle.MouseUpEventHandler += (sender, e) => {
new System.Threading.Thread(() => {
System.Threading.Thread.Sleep(500);
Application.RunOnMainThread(() =>
{
btnTitle.IsSelected = false;
btnIcon.IsSelected = false;
});
})
{ IsBackground = true }.Start();
};
}
}
}