using System;
|
using HDL_ON.Entity;
|
using HDL_ON.UI.CSS;
|
using Shared;
|
|
namespace HDL_ON.UI
|
{
|
public partial class RoomPage : FrameLayout
|
{
|
|
#region 控件列表
|
/// <summary>
|
/// 当前窗体
|
/// </summary>
|
static FrameLayout bodyView;
|
/// <summary>
|
/// 功能列表集合显示区域
|
/// </summary>
|
static VerticalScrolViewLayout functionListView;
|
#endregion
|
|
#region
|
static Room room;
|
Action skipEditPageAction;
|
Action ReloadRoomName;
|
/// <summary>
|
/// 删除房间事件
|
/// </summary>
|
Action deleteAction;
|
/// <summary>
|
/// 图片修改事件
|
/// </summary>
|
Action modifyImageAction;
|
|
#endregion
|
|
/// <summary>
|
///
|
/// </summary>
|
/// <param name="r"></param>
|
/// <param name="rrn">编辑事件</param>
|
/// <param name="delAction">删除事件回调</param>
|
/// <param name="modifyImageAction">房间背景图修改事件回调</param>
|
public RoomPage(Room r, Action rrn, Action delAction, Action modifyImageAction)
|
{
|
bodyView = this;
|
room = r;
|
skipEditPageAction = () =>
|
{
|
LoadEvent_SkipEditRoomPage();
|
};
|
ReloadRoomName = rrn;
|
deleteAction = delAction;
|
this.modifyImageAction = modifyImageAction;
|
}
|
/// <summary>
|
/// 重载界面
|
/// </summary>
|
void ReLoadPage()
|
{
|
bodyView.RemoveAll();
|
LoadPage();
|
}
|
|
public void LoadPage()
|
{
|
bodyView.BackgroundColor = CSS_Color.BackgroundColor;
|
|
new TopViewDiv(bodyView,room.roomName).LoadTopView_RoomTop(ReloadRoomName, skipEditPageAction);
|
|
functionListView = new VerticalScrolViewLayout()
|
{
|
Y = Application.GetRealHeight(64),
|
Height = Application.GetRealHeight(603-12),
|
};
|
bodyView.AddChidren(functionListView);
|
|
foreach (var function in room.GetRoomFunctions(false))
|
{
|
if (function.Spk_Prefix == FunctionCategory.Sensor)
|
{
|
continue;
|
}
|
|
functionListView.AddChidren(new Button() { Height = Application.GetRealHeight(12) });
|
|
if (function.spk == SPK.LightRGB || function.spk == SPK.LightDimming)
|
{
|
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.spk + 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.spk + function.sid
|
};
|
functionDiv.LoadFunctionDiv();
|
functionListView.AddChidren(functionDiv);
|
}
|
}
|
foreach (var scene in room.GetRoomScenes(false))
|
{
|
functionListView.AddChidren(new Button() { Height = Application.GetRealHeight(12) });
|
var sceneRow = new FrameLayout()
|
{
|
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 = "Scene-" + scene.sid
|
};
|
functionListView.AddChidren(sceneRow);
|
LoadSceneRow(sceneRow, scene);
|
}
|
}
|
|
|
|
|
/// <summary>
|
/// 加载功能类型控制卡片
|
/// </summary>
|
public void LoadSceneRow(FrameLayout bodyDiv, Scene scene)
|
{
|
var btnIcon = new Button()
|
{
|
X = Application.GetRealWidth(10),
|
Y = Application.GetRealHeight(15),
|
Width = Application.GetRealWidth(32),
|
Height = Application.GetRealWidth(32),
|
};
|
bodyDiv.AddChidren(btnIcon);
|
|
var btnName = new Button()
|
{
|
X = Application.GetRealWidth(8 + 10 + 32),
|
Y = Application.GetRealHeight(10),
|
Width = Application.GetRealWidth(200),
|
Height = Application.GetRealHeight(24),
|
Text = scene.name,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
TextSize = CSS_FontSize.TextFontSize,
|
};
|
bodyDiv.AddChidren(btnName);
|
|
var btnFromFloor = new Button()
|
{
|
X = Application.GetRealWidth(8 + 10 + 32),
|
Y = Application.GetRealHeight(10 + 24),
|
Width = Application.GetRealWidth(200),
|
Height = Application.GetRealHeight(18),
|
Text = scene.GetRoomListName(),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = CSS_Color.PromptingColor1,
|
TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
|
};
|
bodyDiv.AddChidren(btnFromFloor);
|
|
var btnCollectionIcon = new Button()
|
{
|
X = Application.GetRealWidth(299),
|
Y = Application.GetRealHeight(10),
|
Width = Application.GetMinRealAverage(40),
|
Height = Application.GetMinRealAverage(40),
|
SelectedImagePath = "Collection/CollectionIcon.png",
|
UnSelectedImagePath = "Collection/CollectionGrayIcon.png",
|
IsSelected = scene.collect
|
};
|
//bodyDiv.AddChidren(btnCollectionIcon);
|
//2020-12-16 如果是成员隐藏收藏功能
|
if (!DB_ResidenceData.Instance.CurrentRegion.IsOthreShare)
|
{
|
bodyDiv.AddChidren(btnCollectionIcon);
|
}
|
|
btnIcon.UnSelectedImagePath = "FunctionIcon/Scene/SceneIcon.png";
|
if (scene.sceneType == SceneType.MovieScene)
|
{
|
var movieIcon = new Button()
|
{
|
X = Application.GetRealWidth(52),
|
Y = Application.GetRealHeight(14),
|
Width = Application.GetRealWidth(16),
|
Height = Application.GetRealWidth(16),
|
UnSelectedImagePath = "FunctionIcon/Scene/MovieMark.png",
|
};
|
bodyDiv.AddChidren(movieIcon);
|
btnName.X = Application.GetRealWidth(52 + 16);
|
}
|
//加载场景控制事件
|
LoadEvent_ControlScene(btnName,btnFromFloor,bodyDiv,scene );
|
|
LoadEvent_FunctionCollection(btnCollectionIcon,scene);
|
}
|
|
/// <summary>
|
/// 加载功能收藏按钮事件
|
/// </summary>
|
void LoadEvent_FunctionCollection(Button btnCollectionIcon,Scene scene)
|
{
|
btnCollectionIcon.MouseUpEventHandler += (sender, e) =>
|
{
|
btnCollectionIcon.IsSelected = scene.collect = !btnCollectionIcon.IsSelected;
|
scene.CollectScene();
|
};
|
}
|
/// <summary>
|
/// 加载场景控制事件
|
/// </summary>
|
void LoadEvent_ControlScene(Button btnName,Button btnFromFloor,FrameLayout bodyDiv, Scene scene)
|
{
|
EventHandler<MouseEventArgs> upEvent = (sender, e) => {
|
DriverLayer.Control.Ins.ControlScene(scene);
|
string msg = scene.name + Language.StringByID(StringId.AlreadyOpened);
|
new PublicAssmebly().TipMsgAutoClose(msg, false);
|
};
|
btnName.MouseUpEventHandler = upEvent;
|
btnFromFloor.MouseUpEventHandler = upEvent;
|
bodyDiv.MouseUpEventHandler = upEvent;
|
}
|
|
}
|
}
|