using System;
|
using Shared;
|
using HDL_ON.UI.CSS;
|
using HDL_ON.Entity;
|
using System.Collections.Generic;
|
|
namespace HDL_ON.UI
|
{
|
public partial class SceneFunctionListChoosePage : FrameLayout
|
{
|
FrameLayout bodyView;
|
|
FrameLayout showdFunctionTypeRow;
|
|
/// <summary>
|
/// 楼层选择下拉图标
|
/// </summary>
|
Button btnFloorDownIcon;
|
/// <summary>
|
/// 楼层显示
|
/// </summary>
|
Button btnFloor;
|
|
///// <summary>
|
///// 筛选选择下拉图标
|
///// </summary>
|
//Button btnScreenIcon;
|
/// <summary>
|
/// 筛选文本显示
|
/// </summary>
|
Button btnScreenText;
|
|
VerticalScrolViewLayout functionListView;
|
|
List<Function> allocatedList;
|
List<Function> unallocatedList;
|
|
Scene scene;
|
Action refreshAction;
|
public SceneFunctionListChoosePage(Scene function,Action action)
|
{
|
bodyView = this;
|
scene = function;
|
allocatedList = new List<Function>();
|
unallocatedList = new List<Function>();
|
refreshAction = () =>
|
{
|
this.RemoveFromParent();
|
action();
|
};
|
}
|
|
|
/// <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);
|
|
|
btnFloorDownIcon = new Button()
|
{
|
Width = Application.GetMinRealAverage(16),
|
Height = Application.GetMinRealAverage(16),
|
X = Application.GetRealWidth(16),
|
Y = Application.GetRealHeight(18),
|
UnSelectedImagePath = "Public/DownIcon.png",
|
};
|
showdFunctionTypeRow.AddChidren(btnFloorDownIcon);
|
|
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 = DB_ResidenceData.Instance.CurFloor.roomName,
|
};
|
showdFunctionTypeRow.AddChidren(btnFloor);
|
|
|
//btnScreenIcon = new Button()
|
//{
|
// Width = Application.GetMinRealAverage(16),
|
// Height = Application.GetMinRealAverage(16),
|
// X = Application.GetRealWidth(122),
|
// Y = Application.GetRealHeight(18),
|
// UnSelectedImagePath = "Public/DownIcon.png",
|
//};
|
//showdFunctionTypeRow.AddChidren(btnScreenIcon);
|
|
//btnScreenText = new Button()
|
//{
|
// X = btnScreenIcon.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,
|
// TextID = StringId.Screen
|
//};
|
//showdFunctionTypeRow.AddChidren(btnScreenText);
|
|
|
#endregion
|
|
functionListView = new VerticalScrolViewLayout()
|
{
|
Y = showdFunctionTypeRow.Bottom,
|
Height = Application.GetRealHeight(530),
|
BackgroundColor = CSS_Color.BackgroundColor,
|
};
|
bodyView.AddChidren(functionListView);
|
|
foreach (var function in FunctionList.List.Functions)
|
{
|
if (function == null)
|
{
|
continue;
|
}
|
function.roomIds.Remove(null);
|
if (scene.functions.Find((obj) => obj.sid == function.sid) != null)
|
{
|
allocatedList.Add(function);
|
}
|
else
|
{
|
unallocatedList.Add(function);
|
}
|
}
|
|
LoadFunctionListRow(null);
|
|
LoadEventList();
|
}
|
|
/// <summary>
|
/// 显示功能Row
|
/// </summary>
|
/// <param name="showUnallocated">是否是显示未分配</param>
|
void LoadFunctionListRow(List<Function> functions)
|
{
|
functionListView.RemoveAll();
|
if (functions == null)
|
{
|
//初始值
|
functions = new List<Function>();
|
functions.AddRange(unallocatedList);
|
functions.AddRange(allocatedList);
|
}
|
foreach (var function in functions)
|
{
|
if (function.Spk_Prefix != FunctionCategory.Light &&
|
function.Spk_Prefix != FunctionCategory.AC &&
|
function.Spk_Prefix != FunctionCategory.FloorHeat &&
|
function.Spk_Prefix != FunctionCategory.Curtain
|
)
|
{
|
continue;
|
}
|
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);
|
|
if (allocatedList.Contains(function))
|
{
|
var btnTipAdded = new Button()
|
{
|
Width = Application.GetRealWidth(327),
|
TextAlignment = TextAlignment.CenterRight,
|
TextColor = CSS_Color.MainColor,
|
TextSize = CSS_FontSize.TextFontSize,
|
TextID = StringId.Added
|
};
|
functionRow.AddChidren(btnTipAdded);
|
}
|
|
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";
|
|
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()
|
{
|
X = Application.GetRealWidth(339),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetMinRealAverage(16),
|
Height = Application.GetMinRealAverage(16),
|
UnSelectedImagePath = "Public/Right.png",
|
};
|
functionRow.AddChidren(btnChooseIcon);
|
LoadEvent_SkipEditFunctionInfo(functionRow, btnFunctionFloorName, btnChooseIcon, btnFunctionName, function);
|
}
|
|
}
|
|
|
/// <summary>
|
/// 住宅列表点击事件
|
/// </summary>
|
void LoadDialog_ChangeFloor()
|
{
|
string nowSelectId = null;
|
btnFloor.MouseUpEventHandler += (sender, e) =>
|
{
|
var listAllFun = new List<Function>();
|
listAllFun.AddRange(unallocatedList);
|
listAllFun.AddRange(allocatedList);
|
|
//显示下拉界面
|
var form = new FloorRoomSelectPopupView();
|
form.ShowDeviceFunctionView(btnFloor, listAllFun, (selectId, listFun) =>
|
{
|
nowSelectId = selectId;
|
//重新刷新设备列表
|
this.LoadFunctionListRow(listFun);
|
}, nowSelectId);
|
};
|
}
|
}
|
|
//---------------------------------------
|
public partial class SceneFunctionListChoosePage
|
{
|
|
void LoadEventList()
|
{
|
LoadDialog_ChangeFloor();
|
}
|
/// <summary>
|
/// 新增场景功能
|
/// </summary>
|
/// <param name="view"></param>
|
/// <param name="btn1"></param>
|
/// <param name="btn2"></param>
|
/// <param name="btn3"></param>
|
/// <param name="function"></param>
|
void LoadEvent_SkipEditFunctionInfo(FrameLayout view, Button btn1, Button btn2, Button btn3, Function function)
|
{
|
EventHandler<MouseEventArgs> eventHandler = (sender, e) =>
|
{
|
var ssf = new SceneFunctionInfoEditPage(scene, function.ConvertSceneFunction(), refreshAction);
|
MainPage.BasePageView.AddChidren(ssf);
|
ssf.LoadPage();
|
MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
|
};
|
view.MouseUpEventHandler = eventHandler;
|
btn1.MouseUpEventHandler = eventHandler;
|
btn2.MouseUpEventHandler = eventHandler;
|
btn3.MouseUpEventHandler = eventHandler;
|
|
}
|
}
|
}
|