using System; using System.Collections.Generic; using System.Linq; using HDL_ON.Entity; using HDL_ON.UI.CSS; using Shared; namespace HDL_ON.UI { public partial class FunctionPage : FrameLayout { #region 控件列表 /// /// 当前窗体 /// static FrameLayout bodyView; /// /// 楼层选择下拉图标 /// Button btnFloorDownIcon; /// /// 楼层显示 /// Button btnFloor; /// /// 功能列表集合显示区域 /// static VerticalScrolViewLayout functionListView; #endregion List functionList; public FunctionPage() { bodyView = this; functionList = new List(); } public void LoadPage(int titleId) { bodyView.BackgroundColor = CSS_Color.BackgroundColor; new TopViewDiv(bodyView, Language.StringByID(titleId)).LoadTopView(); /// /// 房间内容显示区域 /// var roomFloorChangeView = new FrameLayout() { Y = Application.GetRealHeight(64), Height = Application.GetRealHeight(52), }; bodyView.AddChidren(roomFloorChangeView); #region 房间顶部切换显示区域 btnFloorDownIcon = new Button() { Width = Application.GetMinRealAverage(16), Height = Application.GetMinRealAverage(16), X = Application.GetRealWidth(16), Y = Application.GetRealHeight(18), UnSelectedImagePath = "Public/DownIcon.png", }; roomFloorChangeView.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, }; roomFloorChangeView.AddChidren(btnFloor); #endregion functionListView = new VerticalScrolViewLayout() { Y = Application.GetRealHeight(64 + 52), Height = Application.GetRealHeight(603 - 12 - 52), }; bodyView.AddChidren(functionListView); if (titleId == StringId.Lights) { functionList.AddRange(FunctionList.List.lights); } else if (titleId == StringId.AC) { functionList.AddRange(FunctionList.List.aCs); } else if (titleId == StringId.Curtain) { functionList.AddRange(FunctionList.List.curtains); } else if (titleId == StringId.FloorHeating) { functionList.AddRange(FunctionList.List.floorHeatings); } else if (titleId == StringId.Electric) { functionList.AddRange(FunctionList.List.electricals); } else if (titleId == StringId.EnvironmentalScience) { functionList.AddRange(FunctionList.List.sensorsEnvironmentalScience); } functionList.OrderByDescending(o => o.controlCounter).ToList(); ShowFunctionRow(functionList); LoadDialog_ChangeFloor(); } /// /// 加载功能row /// void ShowFunctionRow(List showList) { functionListView.RemoveAll(); foreach (var function in showList) { if (function.functionType == FunctionType.RGB || function.functionType == FunctionType.Dimmer) { 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); } functionListView.AddChidren(new Button() { Height = Application.GetRealHeight(10) }); } } /// /// 住宅列表点击事件 /// void LoadDialog_ChangeFloor() { string nowSelectId = null; btnFloor.MouseUpEventHandler += (sender, e) => { //显示下拉列表 var form = new FloorRoomSelectPopupView(); form.ShowDeviceFunctionView(btnFloor, this.functionList, (selectId, listFunc) => { nowSelectId = selectId; //重新加载界面 ShowFunctionRow(listFunc); }, nowSelectId); }; } } }