using System;
using System.Collections.Generic;
using HDL_ON.Entity;
using HDL_ON.UI.CSS;
using Shared;
namespace HDL_ON.UI
{
public partial class FunctionPage : FrameLayout
{
#region 控件列表
///
/// 当前窗体
///
static FrameLayout bodyView;
///
/// 功能列表集合显示区域
///
static VerticalScrolViewLayout functionListView;
#endregion
public FunctionPage()
{
bodyView = this;
}
public void LoadPage(int titleId)
{
bodyView.BackgroundColor = CSS_Color.BackgroundColor;
new TopViewDiv(bodyView, Language.StringByID(titleId)).LoadTopView();
///
/// 房间内容显示区域
///
var roomFloorChangeView = new FrameLayout()
{
Y = Application.GetRealHeight(64),
Height = Application.GetRealHeight(52),
};
bodyView.AddChidren(roomFloorChangeView);
#region 房间顶部切换显示区域
///
/// 楼层选择下拉图标
///
var btnFoorDownIcon = new Button()
{
Width = Application.GetMinRealAverage(16),
Height = Application.GetMinRealAverage(16),
X = Application.GetRealWidth(16),
Y = Application.GetRealHeight(18),
UnSelectedImagePath = "Public/DownIcon.png",
};
roomFloorChangeView.AddChidren(btnFoorDownIcon);
///
/// 楼层显示
///
var btnFoor = new Button()
{
X = btnFoorDownIcon.Right,
Y = Application.GetRealHeight(18),
Width = Application.GetRealWidth(200),
Height = Application.GetMinRealAverage(16),
TextColor = CSS_Color.FirstLevelTitleColor,
TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
TextAlignment = TextAlignment.CenterLeft,
Text = OnAppConfig.Instance.CurFoor,
};
roomFloorChangeView.AddChidren(btnFoor);
#endregion
functionListView = new VerticalScrolViewLayout()
{
Y = Application.GetRealHeight(64 + 52),
Height = Application.GetRealHeight(603 - 12 - 52),
};
bodyView.AddChidren(functionListView);
foreach (var function in DB_ResidenceData.functionList.GetAllFunction())
{
if (titleId == StringId.Lights)
{
if (function.functionCategory != FunctionCategory.Light)
{
continue;
}
}
if (titleId == StringId.AC)
{
if (function.functionType != FunctionType.AC)
{
continue;
}
}
if (titleId == StringId.Curtain)
{
if (function.functionCategory != FunctionCategory.Curtain)
{
continue;
}
}
if(titleId == StringId.FloorHeating)
{
if(function.functionType != FunctionType.FloorHeating )
{
continue;
}
}
if(titleId == StringId.Electric)
{
if(function.functionType != FunctionType.Socket &&
function.functionType != FunctionType.TV &&
function.functionType != FunctionType.Fan)
{
continue;
}
}
if (titleId == StringId.EnvironmentalScience)
{
if (function.functionType != FunctionType.PM25 ||
function.functionType != FunctionType.CO2 ||
function.functionType != FunctionType.Temp ||
function.functionType != FunctionType.TVOC ||
function.functionType != FunctionType.Humidity)
{
continue;
}
}
if (function.functionType == FunctionType.RGB || function.functionType == FunctionType.Dimmer)
{
var functionDiv = new FunctionControlZone(function)
{
Gravity = Gravity.CenterHorizontal,
Width = Application.GetRealWidth(343),
Height = Application.GetRealHeight(116),
Radius = (uint)Application.GetMinRealAverage(12),
BorderColor = 0x00FFFFFF,
BorderWidth = 1,
BackgroundColor = CSS_Color.MainBackgroundColor,
Tag = function.functionCategory.ToString() + "-" + function.functionType
};
functionDiv.LoadFunctionDiv();
functionListView.AddChidren(functionDiv);
}
else
{
var functionDiv = new FunctionControlZone(function)
{
Gravity = Gravity.CenterHorizontal,
Width = Application.GetRealWidth(343),
Height = Application.GetRealHeight(96),
Radius = (uint)Application.GetMinRealAverage(12),
BorderColor = 0x00FFFFFF,
BorderWidth = 1,
BackgroundColor = CSS_Color.MainBackgroundColor,
Tag = function.functionCategory.ToString() + "-" + function.functionType
};
functionDiv.LoadFunctionDiv();
functionListView.AddChidren(functionDiv);
}
functionListView.AddChidren(new Button() { Height = Application.GetRealHeight(10) });
}
}
}
}