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>();
|
#endregion
|
|
public RoomEditFunctionPage(Room r)
|
{
|
bodyView = this;
|
room = r;
|
}
|
|
/// <summary>
|
/// 加载界面
|
/// </summary>
|
public void LoadPage()
|
{
|
bodyView.BackgroundColor = CSS_Color.BackgroundColor;
|
new TopViewDiv(bodyView, Language.StringByID(StringId.AddFunction)).LoadTopView();
|
//new PublicAssmebly().LoadTopView(bodyView, Language.StringByID(StringId.AddFunction));
|
|
#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);
|
|
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 DB_ResidenceData.functionList.GetAllFunction())
|
{
|
function.roomIdList.Remove(null);
|
if (function.roomIdList.Count > 0 )
|
{
|
allocatedList.Add(function);
|
}
|
else
|
{
|
unallocatedList.Add(function);
|
}
|
}
|
|
LoadFunctionListRow(unallocatedList);
|
|
|
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);
|
|
LoadEventList();
|
}
|
|
|
/// <summary>
|
/// 显示功能Row
|
/// </summary>
|
/// <param name="showUnallocated">是否是显示未分配</param>
|
void LoadFunctionListRow(List<Function> functions)
|
{
|
showdFunctionCount = 0;
|
functionListView.RemoveAll();
|
|
foreach (var function in functions)
|
{
|
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);
|
switch (function.functionCategory)
|
{
|
case FunctionCategory.Thermostat:
|
switch (function.functionType)
|
{
|
case FunctionType.AC:
|
btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/AC/AcThinIcon1.png";
|
break;
|
case FunctionType.FloorHeating:
|
btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/FloorHeating/FloorHeatingThinIcon.png";
|
break;
|
}
|
break;
|
case FunctionCategory.Curtain:
|
btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/Curtain/CurtainThinIcon.png";
|
break;
|
case FunctionCategory.Light:
|
btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/Light/LightThinIcon.png";
|
break;
|
case FunctionCategory.SwitchDevice:
|
switch (function.functionType)
|
{
|
case FunctionType.Socket:
|
btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/Socket/SocketThinIcon.png";
|
break;
|
}
|
break;
|
case FunctionCategory.Electrical:
|
switch (function.functionType)
|
{
|
case FunctionType.Fan:
|
btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/Electrical/FanThinIcon.png";
|
break;
|
case FunctionType.TV:
|
btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/Electrical/TVThinIcon.png";
|
break;
|
}
|
break;
|
case FunctionCategory.Scene:
|
btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/Scene/SceneIcon.png";
|
break;
|
case FunctionCategory.Music:
|
btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/Music/MusicThinIcon.png";
|
break;
|
case FunctionCategory.Sensor:
|
switch(function.functionType)
|
{
|
case FunctionType.PM25:
|
btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/EnvironmentalScience/FunctionIconPm25.png";
|
break;
|
case FunctionType.CO2:
|
btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/EnvironmentalScience/FunctionIconCO2.png";
|
break;
|
case FunctionType.TVOC:
|
btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/EnvironmentalScience/FunctionIconTVOC.png";
|
break;
|
case FunctionType.Humidity:
|
btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/EnvironmentalScience/FunctionIconHumidity.png";
|
break;
|
case FunctionType.Temp:
|
btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/EnvironmentalScience/FunctionIconTemp.png";
|
break;
|
}
|
break;
|
}
|
|
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(50),
|
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.roomIdList.Contains(room.sid)
|
};
|
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()
|
{
|
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 DB_ResidenceData.rooms)
|
{
|
|
Button btnRoom = new Button()
|
{
|
X = Application.GetRealWidth(16),
|
Width = Application.GetRealWidth(128),
|
Height = Application.GetRealHeight(50),
|
Text = tempRoom.name,
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
SelectedTextColor = CSS_Color.MainColor,
|
TextSize = CSS_FontSize.SubheadingFontSize,
|
TextAlignment = TextAlignment.CenterLeft,
|
IsSelected = showedFunctionRoomId == tempRoom.sid,
|
Tag = tempRoom.sid,
|
};
|
roomListView.AddChidren(btnRoom);
|
LoadEvent_ChangeShowedFunctionList(btnRoom, dialog, tempRoom.name);
|
|
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();
|
|
|
}
|
|
}
|
}
|