using System;
|
using System.Collections.Generic;
|
using HDL_ON.Entity;
|
using HDL_ON.UI.CSS;
|
using Shared;
|
|
namespace HDL_ON.UI
|
{
|
public partial class RoomEditFunctionPage : FrameLayout
|
{
|
#region 窗体列表
|
/// <summary>
|
/// 当前窗体
|
/// </summary>
|
FrameLayout bodyView;
|
/// <summary>
|
/// 功能列表显示区域
|
/// </summary>
|
VerticalScrolViewLayout functionListView;
|
/// <summary>
|
/// 显示功能的类型切换区域
|
/// </summary>
|
FrameLayout showdFunctionTypeRow;
|
/// <summary>
|
/// 未分配功能类型切换显示
|
/// </summary>
|
Button btnUnallocated;
|
/// <summary>
|
/// 已分配功能类型切换
|
/// </summary>
|
Button btnAllocated;
|
/// <summary>
|
/// 保存数据按钮
|
/// </summary>
|
Button btnConfrim;
|
/// <summary>
|
/// 当前显示的房间按钮
|
/// </summary>
|
Button btnChoosedRoom;
|
/// <summary>
|
/// 切换显示房间的按钮
|
/// </summary>
|
Button btnChooseRoomIcon;
|
#endregion
|
|
#region 区域变量
|
/// <summary>
|
/// 需要显示的功能总数,影响到界面显示
|
/// </summary>
|
int showdFunctionCount = 0;
|
Room room;
|
string showedFunctionRoomId = "0";
|
List<Function> unallocatedList = new List<Function>();
|
List<Function> allocatedList = new List<Function>();
|
/// <summary>
|
/// 被修改数据的功能列表,在需要保存的时候再保存数据
|
/// </summary>
|
List<Function> changeList = new List<Function>();
|
/// <summary>
|
/// 新增的房间绑定功能事件,用户确定生成房间之后,再将功能绑定到房间
|
/// </summary>
|
Action<List<Function>> newRoomAddFunction;
|
#endregion
|
/// <summary>
|
/// 编辑现有房间的构造函数
|
/// </summary>
|
/// <param name="r"></param>
|
public RoomEditFunctionPage(Room r)
|
{
|
bodyView = this;
|
room = r;
|
}
|
|
public RoomEditFunctionPage(Room r, Action<List<Function>> action)
|
{
|
bodyView = this;
|
room = r;
|
newRoomAddFunction = action;
|
}
|
/// <summary>
|
/// 加载界面
|
/// </summary>
|
public void LoadPage()
|
{
|
bodyView.BackgroundColor = CSS_Color.BackgroundColor;
|
new TopViewDiv(bodyView, Language.StringByID(StringId.AddFunction)).LoadTopView();
|
|
#region 显示的功能类型切换区域
|
showdFunctionTypeRow = new FrameLayout()
|
{
|
Y = Application.GetRealHeight(64),
|
Height = Application.GetRealHeight(62),
|
BackgroundColor = CSS_Color.MainBackgroundColor,
|
};
|
bodyView.AddChidren(showdFunctionTypeRow);
|
|
btnUnallocated = new Button()
|
{
|
Width = Application.GetRealWidth(106),
|
Height = Application.GetRealHeight(49),
|
TextAlignment = TextAlignment.Center,
|
SelectedTextColor = CSS_Color.MainColor,
|
TextColor = CSS_Color.PromptingColor1,
|
TextSize = CSS_FontSize.HeadlineFontSize,
|
TextID = StringId.Unallocated,
|
IsSelected = true,
|
IsBold = true
|
};
|
showdFunctionTypeRow.AddChidren(btnUnallocated);
|
if(Language.CurrentLanguage != "Chinese")
|
{
|
btnUnallocated.Width = Application.GetRealWidth(130);
|
}
|
|
btnAllocated = new Button()
|
{
|
X = btnUnallocated.Right + Application.GetRealWidth(10),
|
Width = Application.GetRealWidth(106),
|
Height = Application.GetRealHeight(49),
|
TextAlignment = TextAlignment.CenterLeft,
|
SelectedTextColor = CSS_Color.MainColor,
|
TextColor = CSS_Color.PromptingColor1,
|
TextSize = CSS_FontSize.TextFontSize,
|
TextID = StringId.Allocated,
|
};
|
showdFunctionTypeRow.AddChidren(btnAllocated);
|
|
btnChoosedRoom = new Button()
|
{
|
X = Application.GetRealWidth(313 - 100 + 24),
|
Width = Application.GetRealWidth(100),
|
//Height = Application.GetRealHeight(55),
|
TextAlignment = TextAlignment.CenterRight,
|
TextID = StringId.All,
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
|
Visible = false,
|
};
|
showdFunctionTypeRow.AddChidren(btnChoosedRoom);
|
|
btnChooseRoomIcon = new Button()
|
{
|
X = btnChoosedRoom.Right,
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetMinRealAverage(20),
|
Height = Application.GetMinRealAverage(20),
|
UnSelectedImagePath = "Public/DownIcon_2.png",
|
Visible = false,
|
};
|
showdFunctionTypeRow.AddChidren(btnChooseRoomIcon);
|
|
|
#endregion
|
|
functionListView = new VerticalScrolViewLayout()
|
{
|
Y = showdFunctionTypeRow.Bottom,
|
Height = Application.GetRealHeight(518 - 40 - 62),
|
BackgroundColor = CSS_Color.BackgroundColor,
|
|
};
|
bodyView.AddChidren(functionListView);
|
|
foreach (var function in FunctionList.List.GetDeviceFunctionList())
|
{
|
function.roomIds.Remove(null);
|
if (function.roomIds.Count > 0 )
|
{
|
allocatedList.Add(function);
|
}
|
else
|
{
|
unallocatedList.Add(function);
|
}
|
}
|
|
LoadFunctionListRow(unallocatedList);
|
|
var bottomView = new FrameLayout()
|
{
|
Y = Application.GetRealHeight(591),
|
Height = Application.GetRealHeight(76) + Application.GetRealWidth(44),
|
Radius = (uint)Application.GetRealWidth(22),
|
BackgroundColor = CSS_Color.MainBackgroundColor,
|
};
|
bodyView.AddChidren(bottomView);
|
|
|
btnConfrim = new Button()
|
{
|
Gravity = Gravity.CenterHorizontal,
|
Y = Application.GetRealHeight(603),
|
Width = Application.GetRealWidth(220),
|
Height = Application.GetRealWidth(44),
|
Radius = (uint)Application.GetRealWidth(22),
|
BackgroundColor = CSS_Color.MainColor,
|
TextColor = CSS_Color.MainBackgroundColor,
|
TextSize = CSS_FontSize.SubheadingFontSize,
|
TextAlignment = TextAlignment.Center,
|
IsBold = true,
|
TextID = StringId.ConfirmAdd,
|
};
|
bodyView.AddChidren(btnConfrim);
|
|
LoadEventList();
|
}
|
|
/// <summary>
|
/// 显示功能Row
|
/// </summary>
|
/// <param name="showUnallocated">是否是显示未分配</param>
|
void LoadFunctionListRow(List<Function> functions)
|
{
|
showdFunctionCount = 0;
|
functionListView.RemoveAll();
|
|
bool isFrist = true;
|
|
foreach (var function in functions)
|
{
|
if (isFrist)
|
{
|
isFrist = false;
|
}
|
else
|
{
|
functionListView.AddChidren(new Button()
|
{
|
Gravity = Gravity.CenterHorizontal,
|
Width = Application.GetRealWidth(343),
|
Height = Application.GetRealWidth(1),
|
BackgroundColor = CSS_Color.DividingLineColor,
|
});
|
}
|
|
FrameLayout functionRow = new FrameLayout()
|
{
|
Height = Application.GetRealHeight(50),
|
BackgroundColor = CSS_Color.MainBackgroundColor,
|
};
|
functionListView.AddChidren(functionRow);
|
|
var btnFunctionIcon = new Button()
|
{
|
X = Application.GetRealWidth(12),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetMinRealAverage(28),
|
Height = Application.GetMinRealAverage(28),
|
};
|
functionRow.AddChidren(btnFunctionIcon);
|
|
btnFunctionIcon.UnSelectedImagePath = $"FunctionIcon/Icon/{function.IconName}.png";
|
|
|
if (!btnAllocated.IsSelected)
|
{
|
var btnFunctionName = new Button()
|
{
|
X = btnFunctionIcon.Right + Application.GetRealWidth(12),
|
Width = Application.GetRealWidth(200),
|
Text = function.name,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
TextSize = CSS_FontSize.TextFontSize,
|
};
|
functionRow.AddChidren(btnFunctionName);
|
}
|
else
|
{
|
var btnFunctionName = new Button()
|
{
|
X = btnFunctionIcon.Right + Application.GetRealWidth(12),
|
Width = Application.GetRealWidth(200),
|
Height = Application.GetRealHeight(40),
|
Text = function.name,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
TextSize = CSS_FontSize.TextFontSize,
|
};
|
functionRow.AddChidren(btnFunctionName);
|
|
var btnFunctionFloorName = new Button()
|
{
|
X = btnFunctionIcon.Right + Application.GetRealWidth(12),
|
Y = Application.GetRealHeight(30),
|
Width = Application.GetRealWidth(200),
|
Height = Application.GetRealHeight(20),
|
Text = function.GetRoomListName(),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = CSS_Color.PromptingColor1,
|
TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
|
};
|
functionRow.AddChidren(btnFunctionFloorName);
|
}
|
|
Button btnChooseIcon = new Button()
|
{
|
Gravity = Gravity.CenterVertical,
|
X = Application.GetRealWidth(335),
|
Width = Application.GetRealWidth(28),
|
Height = Application.GetRealWidth(28),
|
UnSelectedImagePath = "Public/ChooseIcon.png",
|
SelectedImagePath = "Public/ChooseOnIcon.png",
|
IsSelected = function.roomIds.Contains(room.roomId)
|
};
|
functionRow.AddChidren(btnChooseIcon);
|
LoadEvent_ChangeRoomFunctionList(functionRow, btnChooseIcon, function);
|
|
showdFunctionCount++;
|
}
|
|
if (showdFunctionCount < 9)
|
{
|
functionListView.Height = Application.GetRealHeight(51 * showdFunctionCount);
|
}else
|
{
|
functionListView.Height = Application.GetRealHeight(518 - 40 - 62);
|
}
|
}
|
|
/// <summary>
|
/// 显示房间选选择弹窗
|
/// </summary>
|
void LoadPage_LoadChooseRoomDialog()
|
{
|
Action<string, string> action = (key, value) => {
|
if (lastButton != null)
|
{
|
lastButton.IsSelected = false;
|
}
|
showedFunctionRoomId = key;
|
if (showedFunctionRoomId == "0")
|
{
|
LoadFunctionListRow(allocatedList);
|
}
|
else
|
{
|
LoadFunctionListRow(allocatedList.FindAll((obj) => obj.roomIds.Contains(showedFunctionRoomId)));
|
}
|
btnChoosedRoom.Text = value;
|
};
|
|
Dictionary<string, string> items = new Dictionary<string, string>();
|
items.Add("0",Language.StringByID(StringId.All));
|
foreach(var room in SpatialInfo.CurrentSpatial.RoomList)
|
{
|
items.Add(room.roomId,room.roomName);
|
}
|
var chooseDialog = new ListCellDialog(items,showedFunctionRoomId,action);
|
chooseDialog.ShowRightDialog();
|
|
//Dialog dialog = new Dialog();
|
//FrameLayout dialogBodyView = new FrameLayout()
|
//{
|
// BackgroundColor = CSS_Color.DialogTransparentColor1,
|
//};
|
//dialog.AddChidren(dialogBodyView);
|
|
//FrameLayout contentView;
|
//contentView = new FrameLayout()
|
//{
|
// X = Application.GetRealWidth(205),
|
// Y = Application.GetRealHeight(106),
|
// Width = Application.GetRealWidth(160),
|
// Height = Application.GetRealHeight(200),
|
// BackgroundImagePath = "Public/ChooseRoomListbg.png",
|
//};
|
//dialogBodyView.AddChidren(contentView);
|
|
//VerticalScrolViewLayout roomListView;
|
//roomListView = new VerticalScrolViewLayout()
|
//{
|
// X = Application.GetRealWidth(8),
|
// Y = Application.GetRealHeight(15),
|
// Width = Application.GetRealWidth(160),
|
// Height = Application.GetRealHeight(45 * 4),
|
//};
|
//contentView.AddChidren(roomListView);
|
|
//Button btnAllRoom;
|
//btnAllRoom = new Button()
|
//{
|
// X = Application.GetRealWidth(16),
|
// Width = Application.GetRealWidth(128),
|
// Height = Application.GetRealHeight(50),
|
// TextID = StringId.All,
|
// TextColor = CSS_Color.FirstLevelTitleColor,
|
// SelectedTextColor = CSS_Color.MainColor,
|
// TextSize = CSS_FontSize.SubheadingFontSize,
|
// IsSelected = showedFunctionRoomId == "0",
|
// TextAlignment = TextAlignment.CenterLeft,
|
// Tag = "0"
|
//};
|
//roomListView.AddChidren(btnAllRoom);
|
//LoadEvent_ChangeShowedFunctionList(btnAllRoom, dialog, Language.StringByID(StringId.All));
|
|
//roomListView.AddChidren(new Button()
|
//{
|
// Gravity = Gravity.CenterHorizontal,
|
// Width = Application.GetRealWidth(112),
|
// Height = Application.GetRealWidth(1),
|
// BackgroundColor = CSS_Color.DividingLineColor,
|
//});
|
//foreach (var tempRoom in SpatialInfo.CurrentSpatial.RoomList)
|
//{
|
|
// Button btnRoom = new Button()
|
// {
|
// X = Application.GetRealWidth(16),
|
// Width = Application.GetRealWidth(128),
|
// Height = Application.GetRealHeight(50),
|
// Text = tempRoom.roomName,
|
// TextColor = CSS_Color.FirstLevelTitleColor,
|
// SelectedTextColor = CSS_Color.MainColor,
|
// TextSize = CSS_FontSize.SubheadingFontSize,
|
// TextAlignment = TextAlignment.CenterLeft,
|
// IsSelected = showedFunctionRoomId == tempRoom.roomId,
|
// Tag = tempRoom.roomId,
|
// };
|
// roomListView.AddChidren(btnRoom);
|
// LoadEvent_ChangeShowedFunctionList(btnRoom, dialog, tempRoom.roomName);
|
|
// roomListView.AddChidren(new Button()
|
// {
|
// Gravity = Gravity.CenterHorizontal,
|
// Width = Application.GetRealWidth(112),
|
// Height = Application.GetRealWidth(1),
|
// BackgroundColor = CSS_Color.DividingLineColor,
|
// });
|
//}
|
//dialogBodyView.MouseUpEventHandler = (sender, e) =>
|
//{
|
// dialog.Close();
|
//};
|
|
//dialog.Show();
|
|
|
}
|
|
}
|
}
|