using System;
|
using HDL_ON.Entity;
|
using HDL_ON.UI.CSS;
|
using Shared;
|
|
namespace HDL_ON.UI
|
{
|
public partial class IntelligencePage : FrameLayout
|
{
|
FrameLayout bodyView;
|
/// <summary>
|
/// 场景/自动化分页区域
|
/// </summary>
|
PageLayout contentPageView;
|
#region 场景区域
|
FrameLayout scenePageView;
|
/// <summary>
|
/// 场景内容显示区域
|
/// </summary>
|
FrameLayout floorChangeView;
|
#region 场景底部切换显示区域
|
/// <summary>
|
/// 场景区域,顶部区域
|
/// </summary>
|
FrameLayout sceneTopView;
|
/// <summary>
|
/// 楼层选择下拉图标
|
/// </summary>
|
Button btnFloorDownIcon;
|
/// <summary>
|
/// 楼层显示
|
/// </summary>
|
Button btnFloor;
|
/// <summary>
|
/// 添加场景按钮
|
/// </summary>
|
Button btnAddIcon;
|
|
#endregion
|
/// <summary>
|
/// 场景功能控制区域
|
/// </summary>
|
VerticalScrolViewLayout sceneFunctionView;
|
#endregion
|
|
public IntelligencePage()
|
{
|
bodyView = this;
|
}
|
|
public void LoadPage()
|
{
|
bodyView.BackgroundColor = CSS_Color.MainBackgroundColor;
|
#region top
|
FrameLayout topView = new FrameLayout()
|
{
|
Height = Application.GetRealHeight(64),
|
BackgroundColor = CSS_Color.TopViewColor,
|
};
|
bodyView.AddChidren(topView);
|
|
Button btnSceneTilte = new Button()
|
{
|
Y = Application.GetRealHeight(30),
|
Width = Application.GetRealWidth(170),
|
Height = Application.GetRealHeight(25),
|
TextAlignment = TextAlignment.CenterRight,
|
TextSize = CSS_FontSize.HeadlineFontSize,
|
TextColor = CSS_Color.PromptingColor1,
|
SelectedTextColor = CSS_Color.MainColor,
|
TextID = StringId.Scenes,
|
IsSelected = true
|
};
|
topView.AddChidren(btnSceneTilte);
|
|
Button btnAutomationTitle = new Button()
|
{
|
X = Application.GetRealWidth(209),
|
Y = Application.GetRealHeight(30),
|
Width = Application.GetRealWidth(170),
|
Height = Application.GetRealHeight(25),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextSize = CSS_FontSize.TextFontSize,
|
TextColor = CSS_Color.PromptingColor1,
|
SelectedTextColor = CSS_Color.MainColor,
|
TextID = StringId.Automation,
|
};
|
topView.AddChidren(btnAutomationTitle);
|
|
btnAddIcon = new Button()
|
{
|
X = Application.GetRealWidth(337),
|
Y = Application.GetRealHeight(29),
|
Width = Application.GetMinRealAverage(28),
|
Height = Application.GetMinRealAverage(28),
|
UnSelectedImagePath = "Public/AddIcon.png",
|
};
|
topView.AddChidren(btnAddIcon);
|
#endregion
|
|
contentPageView = new PageLayout()
|
{
|
Y = Application.GetRealHeight(64),
|
Height = Application.GetRealHeight(667 - 64 - 49 + 30),
|
BackgroundColor = CSS_Color.BackgroundColor,
|
IsShowPoint = false
|
};
|
bodyView.AddChidren(contentPageView);
|
|
LoadScenePageView();
|
//LoadFunctionPageView();
|
LoadEventList();
|
}
|
/// <summary>
|
/// 加载场景列表界面
|
/// </summary>
|
void LoadScenePageView()
|
{
|
scenePageView = new FrameLayout();
|
contentPageView.AddChidren(scenePageView);
|
/// <summary>
|
/// 场景内容显示区域
|
/// </summary>
|
floorChangeView = new FrameLayout()
|
{
|
Height = Application.GetRealHeight(52),
|
};
|
scenePageView.AddChidren(floorChangeView);
|
#region 场景底部切换显示区域
|
/// <summary>
|
/// 场景区域,顶部区域
|
/// </summary>
|
sceneTopView = new FrameLayout()
|
{
|
Height = Application.GetRealHeight(53),
|
};
|
floorChangeView.AddChidren(sceneTopView);
|
/// <summary>
|
/// 楼层选择下拉图标
|
/// </summary>
|
btnFloorDownIcon = new Button()
|
{
|
Width = Application.GetMinRealAverage(16),
|
Height = Application.GetMinRealAverage(16),
|
X = Application.GetRealWidth(16),
|
Y = Application.GetRealHeight(18),
|
UnSelectedImagePath = "Public/DownIcon.png",
|
};
|
floorChangeView.AddChidren(btnFloorDownIcon);
|
/// <summary>
|
/// 楼层显示
|
/// </summary>
|
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 = OnAppConfig.Instance.CurFoor,
|
};
|
floorChangeView.AddChidren(btnFloor);
|
|
#endregion
|
|
sceneFunctionView = new VerticalScrolViewLayout() {
|
Y = floorChangeView.Bottom,
|
Height = Application.GetRealHeight(667 - 64 - 49 - 52 + 30),
|
};
|
scenePageView.AddChidren(sceneFunctionView);
|
LoadSceneFunctionControlZone();
|
}
|
|
/// <summary>
|
/// 加载场景功能显示区域
|
/// </summary>
|
void LoadSceneFunctionControlZone()
|
{
|
sceneFunctionView.RemoveAll();
|
var rowView = new FrameLayout();
|
try
|
{
|
int index = 0;
|
foreach (var function in DB_ResidenceData.functionList.scenes)
|
{
|
if (function.roomIdList.Count == 0)//如何在房间已经移除了这个功能,则收藏界面也不会再显示
|
{
|
function.collection = false;
|
continue;
|
}
|
if (index % 2 == 0)
|
{
|
sceneFunctionView.AddChidren(new Button() { Height = Application.GetRealHeight(7) });
|
rowView = new FrameLayout()
|
{
|
Height = Application.GetRealWidth(122),
|
};
|
sceneFunctionView.AddChidren(rowView);
|
sceneFunctionView.AddChidren(new Button() { Height = Application.GetRealHeight(7) });
|
}
|
var functionView_X = Application.GetRealWidth((16 + 164) * (index % 2) + 16);
|
|
var functionView = new FrameLayout()
|
{
|
X = functionView_X,
|
Width = Application.GetRealWidth(164),
|
Height = Application.GetRealWidth(122),
|
Tag = function.sid,
|
BackgroundImagePath = (function as Scene).ImagePath,
|
};
|
rowView.AddChidren(functionView);
|
|
LoadSceneFunctionDiv(functionView, function);
|
index++;
|
}
|
|
if (index == 0)
|
{
|
var view = new FrameLayout();
|
sceneFunctionView.AddChidren(view);
|
|
var btnNoCollectionBg = new Button()
|
{
|
Y = Application.GetRealHeight(120),
|
Gravity = Gravity.CenterHorizontal,
|
Width = Application.GetRealWidth(180),
|
Height = Application.GetRealWidth(180),
|
UnSelectedImagePath = "Collection/NoCollectionBg.png",
|
};
|
view.AddChidren(btnNoCollectionBg);
|
|
var btnNoCollectionTip = new Button()
|
{
|
Height = Application.GetRealHeight(42),
|
Y = btnNoCollectionBg.Bottom,
|
TextAlignment = TextAlignment.Center,
|
TextColor = CSS_Color.PromptingColor1,
|
TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
|
TextID = StringId.TipNoScene,
|
};
|
view.AddChidren(btnNoCollectionTip);
|
}
|
}
|
catch (Exception ex)
|
{
|
MainPage.Log("homepage erorr : " + ex.Message);
|
}
|
sceneFunctionView.AddChidren(new Button { Height = Application.GetRealHeight(30) });
|
|
}
|
|
/// <summary>
|
/// 加载场景控制卡片
|
/// </summary>
|
void LoadSceneFunctionDiv(FrameLayout view, Function function)
|
{
|
try
|
{
|
Button btnCoverd = new Button()
|
{
|
UnSelectedImagePath = "Collection/SceneCovered.png",
|
};
|
view.AddChidren(btnCoverd);
|
|
Button btnName;
|
btnName = new Button()
|
{
|
X = Application.GetRealWidth(12),
|
Y = Application.GetRealWidth(68),
|
Width = Application.GetRealWidth(150),
|
Height = Application.GetRealHeight(24),
|
Text = function.name,
|
TextSize = CSS_FontSize.TextFontSize,
|
TextColor = CSS_Color.MainBackgroundColor,
|
TextAlignment = TextAlignment.CenterLeft,
|
};
|
view.AddChidren(btnName);
|
|
Button btnZone;
|
btnZone = new Button()
|
{
|
X = Application.GetRealWidth(12),
|
Y = btnName.Bottom,
|
Height = Application.GetRealWidth(18),
|
Width = Application.GetRealWidth(113),
|
TextColor = CSS_Color.MainBackgroundColor,
|
TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
|
TextAlignment = TextAlignment.CenterLeft,
|
SelectedTextColor = CSS_Color.MainBackgroundColor,
|
Text = function.GetRoomListName(),
|
};
|
view.AddChidren(btnZone);
|
|
|
Button btnSettingIcon;
|
btnSettingIcon = new Button()
|
{
|
X = Application.GetRealWidth(4),
|
Y = Application.GetRealWidth(4),
|
Height = Application.GetRealWidth(32),
|
Width = Application.GetRealWidth(32),
|
UnSelectedImagePath = "Public/FuncInfoSetIcon_white.png",
|
};
|
view.AddChidren(btnSettingIcon);
|
|
Button btnCollection;
|
btnCollection = new Button()
|
{
|
X = Application.GetRealWidth(116),
|
Y = Application.GetRealWidth(8),
|
Width = Application.GetMinRealAverage(32),
|
Height = Application.GetMinRealAverage(32),
|
UnSelectedImagePath = "Collection/CollectionWhiteIcon.png",
|
SelectedImagePath = "Collection/CollectionIcon.png",
|
IsSelected = function.collection,
|
};
|
view.AddChidren(btnCollection);
|
btnCollection.MouseUpEventHandler = (sender, e) => {
|
function.collection = btnCollection.IsSelected = !btnCollection.IsSelected;
|
function.SaveFunctionData();
|
};
|
LoadEvent_ControlScene(btnCoverd,btnName,btnZone, function);
|
btnSettingIcon.MouseUpEventHandler = (sender, e) => {
|
Action backAction = () => {
|
LoadSceneFunctionControlZone();
|
};
|
Action refreshAction = () => {
|
btnName.Text = function.name;
|
btnZone.Text = function.GetRoomListName();
|
view.BackgroundImagePath = (function as Scene).ImagePath;
|
};
|
var aep = new SceneEditPage(function as Scene, backAction);
|
MainPage.BasePageView.AddChidren(aep);
|
aep.LoadPage(StringId.EditScene, refreshAction);
|
MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
|
};
|
}
|
catch (Exception ex)
|
{
|
MainPage.Log("homepage LoadControlView error : " + ex.Message);
|
}
|
}
|
|
}
|
|
|
//-------------
|
public partial class IntelligencePage
|
{
|
void LoadEventList()
|
{
|
LoadEvent_SkipAddScenePage();
|
}
|
/// <summary>
|
/// 跳转至添加场景的界面
|
/// </summary>
|
void LoadEvent_SkipAddScenePage()
|
{
|
btnAddIcon.MouseUpEventHandler = (sender, e) =>
|
{
|
Action action = () => {
|
LoadSceneFunctionControlZone();
|
};
|
var aep = new NewSceneMenuListPage(action);
|
MainPage.BasePageView.AddChidren(aep);
|
aep.LoadPage();
|
MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
|
};
|
}
|
|
|
/// <summary>
|
/// 加载场景控制事件
|
/// </summary>
|
void LoadEvent_ControlScene(Button btnCoverd, Button btnName, Button btnZone, Function function)
|
{
|
|
EventHandler<MouseEventArgs> eventHandler = (sender, e) =>
|
{
|
string msg = function.name + Language.StringByID(StringId.AlreadyOpened);
|
new PublicAssmebly().TipMsgAutoClose(msg, true);
|
Control.Send(function);
|
};
|
btnCoverd.MouseUpEventHandler = eventHandler;
|
btnName.MouseUpEventHandler = eventHandler;
|
btnZone.MouseUpEventHandler = eventHandler;
|
}
|
}
|
|
}
|