using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using HDL_ON.Entity;
|
using HDL_ON.UI.CSS;
|
using Shared;
|
namespace HDL_ON.UI
|
{
|
public partial class FunctionPage : FrameLayout
|
{
|
#region 控件列表
|
/// <summary>
|
/// 当前窗体
|
/// </summary>
|
static FrameLayout bodyView;
|
/// <summary>
|
/// 楼层选择下拉图标
|
/// </summary>
|
Button btnFloorDownIcon;
|
/// <summary>
|
/// 楼层显示
|
/// </summary>
|
Button btnFloor;
|
/// <summary>
|
/// 功能列表集合显示区域
|
/// </summary>
|
static VerticalScrolViewLayout functionListView;
|
#endregion
|
|
List<Function> functionList;
|
|
public FunctionPage()
|
{
|
bodyView = this;
|
functionList = new List<Function>();
|
}
|
|
public void LoadPage(int titleId)
|
{
|
bodyView.BackgroundColor = CSS_Color.BackgroundColor;
|
new TopViewDiv(bodyView, Language.StringByID(titleId)).LoadTopView();
|
|
/// <summary>
|
/// 房间内容显示区域
|
/// </summary>
|
var roomFloorChangeView = new FrameLayout()
|
{
|
Y = Application.GetRealHeight(64),
|
Height = Application.GetRealHeight(52),
|
};
|
bodyView.AddChidren(roomFloorChangeView);
|
#region 房间顶部切换显示区域
|
btnFloorDownIcon = new Button()
|
{
|
Width = Application.GetMinRealAverage(16),
|
Height = Application.GetMinRealAverage(16),
|
X = Application.GetRealWidth(16),
|
Y = Application.GetRealHeight(18),
|
UnSelectedImagePath = "Public/DownIcon.png",
|
};
|
roomFloorChangeView.AddChidren(btnFloorDownIcon);
|
|
btnFloor = new Button()
|
{
|
X = btnFloorDownIcon.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 = DB_ResidenceData.residenceData.CurFoor,
|
};
|
roomFloorChangeView.AddChidren(btnFloor);
|
#endregion
|
|
functionListView = new VerticalScrolViewLayout()
|
{
|
Y = Application.GetRealHeight(64 + 52),
|
Height = Application.GetRealHeight(603 - 12 - 52),
|
};
|
bodyView.AddChidren(functionListView);
|
|
if (titleId == StringId.Lights)
|
{
|
functionList.AddRange(DB_ResidenceData.functionList.lights);
|
}
|
else if (titleId == StringId.AC)
|
{
|
functionList.AddRange(DB_ResidenceData.functionList.aCs);
|
}
|
else if (titleId == StringId.Curtain)
|
{
|
functionList.AddRange(DB_ResidenceData.functionList.curtains);
|
}
|
else if (titleId == StringId.FloorHeating)
|
{
|
functionList.AddRange(DB_ResidenceData.functionList.floorHeatings);
|
}
|
else if (titleId == StringId.Electric)
|
{
|
functionList.AddRange(DB_ResidenceData.functionList.electricals);
|
}
|
else if (titleId == StringId.EnvironmentalScience)
|
{
|
functionList.AddRange(DB_ResidenceData.functionList.sensorsEnvironmentalScience);
|
}
|
functionList.OrderByDescending(o => o.usageCount).ToList();
|
|
ShowFunctionRow(functionList);
|
|
LoadDialog_ChangeFloor();
|
}
|
|
/// <summary>
|
/// 加载功能row
|
/// </summary>
|
void ShowFunctionRow(List<Function> showList)
|
{
|
functionListView.RemoveAll();
|
foreach (var function in showList)
|
{
|
|
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.sid
|
};
|
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.sid
|
};
|
functionDiv.LoadFunctionDiv();
|
functionListView.AddChidren(functionDiv);
|
}
|
functionListView.AddChidren(new Button() { Height = Application.GetRealHeight(10) });
|
}
|
}
|
|
|
/// <summary>
|
/// 住宅列表点击事件
|
/// </summary>
|
void LoadDialog_ChangeFloor()
|
{
|
EventHandler<MouseEventArgs> eventHandler = (sender, e) =>
|
{
|
var dialog = new Dialog();
|
var dialogBody = new FrameLayout();
|
dialog.AddChidren(dialogBody);
|
dialogBody.MouseUpEventHandler += (sender1, e1) =>
|
{
|
dialog.Close();
|
};
|
|
var dispalyView = new FrameLayout()
|
{
|
X = Application.GetRealWidth(10),
|
Y = Application.GetRealHeight(100),
|
Width = Application.GetRealWidth(160),
|
Height = Application.GetRealHeight(110),
|
BackgroundImagePath = "PersonalCenter/HomeList1bg.png",
|
};
|
dialogBody.AddChidren(dispalyView);
|
|
var contentView = new VerticalScrolViewLayout()
|
{
|
X = Application.GetRealWidth(8),
|
Y = Application.GetRealHeight(15),
|
Width = Application.GetRealWidth(150),
|
Height = Application.GetRealHeight(45 * 2),
|
ScrollEnabled = false
|
};
|
dispalyView.AddChidren(contentView);
|
|
if (DB_ResidenceData.rooms.Count < 2)
|
{
|
}
|
else if (DB_ResidenceData.rooms.Count < 3)
|
{
|
dispalyView = new FrameLayout()
|
{
|
X = Application.GetRealWidth(10),
|
Y = Application.GetRealHeight(100),
|
Width = Application.GetRealWidth(160),
|
Height = Application.GetRealHeight(155),
|
BackgroundImagePath = "PersonalCenter/HomeList2bg.png",
|
};
|
dialogBody.AddChidren(dispalyView);
|
|
contentView.Height = Application.GetRealHeight(45 * 3);
|
dispalyView.AddChidren(contentView);
|
}
|
else if (DB_ResidenceData.rooms.Count < 4)
|
{
|
dispalyView = new FrameLayout()
|
{
|
X = Application.GetRealWidth(10),
|
Y = Application.GetRealHeight(100),
|
Width = Application.GetRealWidth(160),
|
Height = Application.GetRealHeight(200),
|
BackgroundImagePath = "PersonalCenter/HomeList3bg.png",
|
};
|
dialogBody.AddChidren(dispalyView);
|
|
contentView.Height = Application.GetRealHeight(45 * 4);
|
dispalyView.AddChidren(contentView);
|
}
|
else
|
{
|
dispalyView = new FrameLayout()
|
{
|
X = Application.GetRealWidth(10),
|
Y = Application.GetRealHeight(100),
|
Width = Application.GetRealWidth(160),
|
Height = Application.GetRealHeight(245),
|
BackgroundImagePath = "PersonalCenter/HomeList4bg.png",
|
};
|
dialogBody.AddChidren(dispalyView);
|
|
contentView.Height = Application.GetRealHeight(45 * 5);
|
contentView.ScrollEnabled = true;
|
dispalyView.AddChidren(contentView);
|
}
|
|
|
List<Room> roomList = new List<Room>();
|
roomList.Add(new Room() { sid = "", name = Language.StringByID(StringId.All) });
|
roomList.AddRange(DB_ResidenceData.rooms);
|
foreach (var tempRoom in roomList)
|
{
|
var roomName = tempRoom.name;
|
if (roomName != Language.StringByID(StringId.All))
|
{
|
contentView.AddChidren(new Button()
|
{
|
Gravity = Gravity.CenterHorizontal,
|
Width = Application.GetRealWidth(112),
|
Height = Application.GetRealHeight(1),
|
BackgroundColor = CSS_Color.BackgroundColor
|
});
|
}
|
var btnHomeName = new Button()
|
{
|
Gravity = Gravity.CenterHorizontal,
|
Width = Application.GetRealWidth(112),
|
Height = Application.GetRealHeight(44),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
SelectedTextColor = CSS_Color.MainColor,
|
Text = roomName,
|
TextSize = CSS_FontSize.SubheadingFontSize,
|
IsSelected = btnFloor.Text == roomName,
|
IsMoreLines = true,
|
};
|
contentView.AddChidren(btnHomeName);
|
|
btnHomeName.MouseUpEventHandler += (senderH, en) =>
|
{
|
dialog.Close();
|
btnFloor.Text = roomName;
|
if (roomName == Language.StringByID(StringId.All))
|
{
|
ShowFunctionRow(functionList);
|
}
|
else
|
{
|
var showList = new List<Function>();
|
foreach (var sf in functionList)
|
{
|
if(sf.roomIdList.Contains(tempRoom.sid))
|
{
|
showList.Add(sf);
|
}
|
}
|
ShowFunctionRow(showList);
|
}
|
};
|
}
|
|
dialog.Show();
|
};
|
|
btnFloor.MouseUpEventHandler = eventHandler;
|
btnFloorDownIcon.MouseUpEventHandler = eventHandler;
|
}
|
}
|
}
|