using System;
using HDL_ON.UI.CSS;
using Shared;
using HDL_ON.Entity;
namespace HDL_ON.UI
{
public partial class FloorsManagementPage : FrameLayout
{
FrameLayout bodyView;
///
/// 楼层显示区域
///
VerticalScrolViewLayout floorsListView;
///
/// 显示区域
///
FrameLayout contentView;
///
/// 楼层标题按钮
///
Button btnFloorTitle;
///
/// 房间绑定楼层的确定按钮
///
Button btnConfrim;
///
/// 当页面是编辑楼层时,该变量为空
/// 当页面是给房间绑定楼层时,该变量不为空
///
Room room;
///
/// 标题栏修改楼层之后的回调事件
///
Action topCallBack;
///
/// 后退回调事件
///
Action backAction;
public FloorsManagementPage()
{
bodyView = this;
}
public FloorsManagementPage(Action action)
{
bodyView = this;
backAction = action;
}
///
/// 加载界面
///
public void LoadPage()
{
bodyView.RemoveAll();
bodyView.BackgroundColor = CSS_Color.BackgroundColor;
topCallBack = (type,floor) => {
ChangeFloorsListView(type, floor);
};
new TopViewDiv(bodyView, Language.StringByID(StringId.FloorsManagement)).LoadTopView("floors",topCallBack,backAction);
//new PublicAssmebly().LoadTopView(bodyView, Language.StringByID(StringId.FloorsManagement),"floors",topCallBcak);
int count = DB_ResidenceData.residenceData.floors.Count > 8 ? 8 : DB_ResidenceData.residenceData.floors.Count;
var contentViewHeight = (count + 1) * Application.GetRealHeight(50);
contentView = new FrameLayout()
{
Gravity = Gravity.CenterHorizontal,
Y = Application.GetRealHeight(80),
Width = Application.GetRealWidth(343),
Height = contentViewHeight,
Radius = (uint)Application.GetRealHeight(5),
BorderColor = 0x00FFFFFF,
BorderWidth = 0,
BackgroundColor = CSS_Color.MainBackgroundColor,
};
bodyView.AddChidren(contentView);
btnFloorTitle = new Button()
{
Height = Application.GetRealHeight(50),
TextID = StringId.Floors,
TextAlignment = TextAlignment.Center,
TextSize = CSS_FontSize.SubheadingFontSize,
TextColor = CSS_Color.FirstLevelTitleColor,
};
contentView.AddChidren(btnFloorTitle);
floorsListView = new VerticalScrolViewLayout()
{
Y = btnFloorTitle.Bottom,
Height = count * Application.GetRealHeight(50),
};
contentView.AddChidren(floorsListView);
foreach(var floor in DB_ResidenceData.residenceData.floors)
{
LoadFloorRow(floor);
}
}
///
/// 加载楼层Row
///
///
void LoadFloorRow(string floor)
{
floorsListView.AddChidren(
new Button()
{
Height = Application.GetRealHeight(1),
BackgroundColor = CSS_Color.DividingLineColor,
Tag = floor + "line"
});
var row = new RowLayout()
{
Height = Application.GetRealHeight(50),
Tag = floor
};
floorsListView.AddChidren(row);
var btnFloor = new Button()
{
Height = Application.GetRealHeight(50),
TextAlignment = TextAlignment.Center,
TextSize = CSS_FontSize.SubheadingFontSize,
TextColor = CSS_Color.TextualColor,
SelectedTextColor = CSS_Color.MainColor,
Text = floor,
};
row.AddChidren(btnFloor);
if (room == null)
{
LoadEvent_FloorNamgeChange(floor, btnFloor);
var btnDel = new Button()
{
TextID = StringId.Del,
BackgroundColor = CSS_Color.WarningColor,
TextColor = CSS_Color.MainBackgroundColor,
Tag = floor
};
row.AddRightView(btnDel);
LoadEvent_DelFloor(btnDel);
}
else {
LoadEvent_FloorChoose(btnFloor);
}
}
void ChangeFloorsListView(string changeType,string floorName)
{
int count = DB_ResidenceData.residenceData.floors.Count > 10 ? 10 : DB_ResidenceData.residenceData.floors.Count;
floorsListView.Height = Application.GetRealHeight(50 * count);
contentView.Height = Application.GetRealHeight(50 * (count + 1));
switch (changeType)
{
case "add":
try
{
LoadFloorRow(floorName);
}
catch (Exception ex)
{
MainPage.Log("add floor eroor : " + ex.Message);
}
break;
case "edit":
for(int i=0;i
/// 分配给room楼层关系
///
public void LoadPage(Room r)
{
room = r;
LoadPage();
btnConfrim = new Button()
{
Gravity = Gravity.CenterHorizontal,
Y = Application.GetRealHeight(582),
Width = Application.GetRealWidth(220),
Height = Application.GetRealHeight(44),
Radius = (uint)Application.GetRealHeight(22),
BackgroundColor = CSS_Color .MainColor,
TextColor = CSS_Color.MainBackgroundColor,
TextSize = CSS_FontSize.SubheadingFontSize,
TextAlignment = TextAlignment.Center,
IsBold = true,
TextID = StringId.Confirm,
};
bodyView.AddChidren(btnConfrim);
LoadEvent_BindFloor();
}
}
}