using System;
|
using HDL_ON.Entity;
|
using Shared;
|
|
namespace HDL_ON.UI
|
{
|
|
|
public partial class HomePage
|
{
|
|
/// <summary>
|
/// 修改显示的功能类型
|
/// 设备功能/场景功能
|
/// </summary>
|
void LoadEvent_ChangeShowedFunctionType()
|
{
|
btnChangeFunction.MouseUpEventHandler = (sender, e) => {
|
btnChangeFunction.IsSelected = true;
|
btnChangeFunction.TextSize = CSS.CSS_FontSize.HeadlineFontSize;
|
btnChangeFunction.IsBold = true;
|
btnChangeScene.TextSize = CSS.CSS_FontSize.TextFontSize;
|
btnChangeScene.IsSelected = false;
|
btnChangeScene.IsBold = false;
|
CurShowTypeIsFunction = true;
|
contentView.PageIndex = 0;
|
};
|
|
btnChangeScene.MouseUpEventHandler = (sender, e) => {
|
btnChangeScene.IsSelected = true;
|
btnChangeScene.TextSize = CSS.CSS_FontSize.HeadlineFontSize;
|
btnChangeScene.IsBold = true;
|
btnChangeFunction.TextSize = CSS.CSS_FontSize.TextFontSize;
|
btnChangeFunction.IsSelected = false;
|
btnChangeFunction.IsBold = false;
|
CurShowTypeIsFunction = false;
|
contentView.PageIndex = 1;
|
};
|
|
contentView.PageChange = (sender, e) => {
|
if (contentView.PageIndex == 0)
|
{
|
btnChangeFunction.IsSelected = true;
|
btnChangeFunction.TextSize = CSS.CSS_FontSize.HeadlineFontSize;
|
btnChangeFunction.IsBold = true;
|
btnChangeScene.TextSize = CSS.CSS_FontSize.TextFontSize;
|
btnChangeScene.IsSelected = false;
|
btnChangeScene.IsBold = false;
|
CurShowTypeIsFunction = true;
|
}
|
else
|
{
|
btnChangeScene.IsSelected = true;
|
btnChangeScene.TextSize = CSS.CSS_FontSize.HeadlineFontSize;
|
btnChangeScene.IsBold = true;
|
btnChangeFunction.TextSize = CSS.CSS_FontSize.TextFontSize;
|
btnChangeFunction.IsSelected = false;
|
btnChangeFunction.IsBold = false;
|
CurShowTypeIsFunction = false;
|
}
|
};
|
}
|
|
|
|
/// <summary>
|
/// 更新灯光显示状态
|
/// </summary>
|
/// <param name="light"></param>
|
public static void UpdataLightView(Light light)
|
{
|
Application.RunOnMainThread(() =>
|
{
|
if (bodyView != null)
|
{
|
foreach (var dic in LightViews)
|
{
|
if (dic.Key == light.sid)
|
{
|
var state = light.state == 1;
|
var view = dic.Value;
|
for (int i = 0; i < view.ChildrenCount; i++)
|
{
|
if (view.GetChildren(i).GetType() == typeof(Button))
|
{
|
var btn = view.GetChildren(i) as Button;
|
btn.IsSelected = state;
|
if (btn.Tag != null && btn.Tag.ToString() == "state")
|
{
|
btn.Text = light.lastState;
|
}
|
}
|
}
|
}
|
}
|
}
|
});
|
}
|
|
/// <summary>
|
/// 加载继电器开关事件
|
/// </summary>
|
/// <param name="function"></param>
|
/// <param name="btnSwitch"></param>
|
/// <param name="view"></param>
|
void LoadRelaySwitchEvent(Function function,Button btnSwitch,FrameLayout view)
|
{
|
|
btnSwitch.MouseUpEventHandler += (sender, e) =>
|
{
|
if (function.functionCategory == FunctionType.Light)
|
{
|
var curState = !btnSwitch.IsSelected;
|
for (int i = 0; i < view.ChildrenCount; i++)
|
{
|
if (view.GetChildren(i).GetType() == typeof(Button))
|
{
|
var btn = view.GetChildren(i) as Button;
|
btn.IsSelected = curState;
|
}
|
}
|
new System.Threading.Thread(() =>
|
{
|
var light = function as Light;
|
light.state = btnSwitch.IsSelected ? 1 : 0;
|
Control.Send("write", function, 3);
|
})
|
{ IsBackground = true }.Start();
|
}
|
};
|
}
|
}
|
}
|