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 窗体列表 /// /// 当前窗体 /// FrameLayout bodyView; /// /// 功能列表显示区域 /// VerticalScrolViewLayout functionListView; /// /// 显示功能的类型切换区域 /// FrameLayout showdFunctionTypeRow; /// /// 未分配功能类型切换显示 /// Button btnUnallocated; /// /// 已分配功能类型切换 /// Button btnAllocated; /// /// 保存数据按钮 /// Button btnConfrim; /// /// 当前显示的房间按钮 /// Button btnChoosedRoom; /// /// 切换显示房间的按钮 /// Button btnChooseRoomIcon; #endregion #region 区域变量 /// /// 需要显示的功能总数,影响到界面显示 /// int showdFunctionCount = 0; Room room; string showedFunctionRoomId = "0"; List unallocatedList = new List(); List allocatedList = new List(); /// /// 被修改数据的功能列表,在需要保存的时候再保存数据 /// List changeList = new List(); /// /// 新增的房间绑定功能事件,用户确定生成房间之后,再将功能绑定到房间 /// Action> newRoomAddFunction; #endregion /// /// 编辑现有房间的构造函数 /// /// public RoomEditFunctionPage(Room r) { bodyView = this; room = r; } public RoomEditFunctionPage(Room r, Action> action) { bodyView = this; room = r; newRoomAddFunction = action; } /// /// 加载界面 /// public void LoadPage() { bodyView.BackgroundColor = CSS_Color.BackgroundColor; new TopViewDiv(bodyView, Language.StringByID(StringId.AddFunction)).LoadTopView(); #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); if(Language.CurrentLanguage != "Chinese") { btnUnallocated.Width = Application.GetRealWidth(130); } 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 FunctionList.List.GetDeviceFunctionList()) { function.roomIds.Remove(null); if (function.roomIds.Count > 0 ) { allocatedList.Add(function); } else { unallocatedList.Add(function); } } LoadFunctionListRow(unallocatedList); var bottomView = new FrameLayout() { Y = Application.GetRealHeight(591), Height = Application.GetRealHeight(76) + Application.GetRealWidth(44), Radius = (uint)Application.GetRealWidth(22), BackgroundColor = CSS_Color.MainBackgroundColor, }; bodyView.AddChidren(bottomView); btnConfrim = new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(603), Width = Application.GetRealWidth(220), Height = Application.GetRealWidth(44), Radius = (uint)Application.GetRealWidth(22), BackgroundColor = CSS_Color.MainColor, TextColor = CSS_Color.MainBackgroundColor, TextSize = CSS_FontSize.SubheadingFontSize, TextAlignment = TextAlignment.Center, IsBold = true, TextID = StringId.ConfirmAdd, }; bodyView.AddChidren(btnConfrim); LoadEventList(); } /// /// 显示功能Row /// /// 是否是显示未分配 void LoadFunctionListRow(List functions) { showdFunctionCount = 0; functionListView.RemoveAll(); bool isFrist = true; foreach (var function in functions) { if (isFrist) { isFrist = false; } else { 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); btnFunctionIcon.UnSelectedImagePath = $"FunctionIcon/Icon/{function.IconName}.png"; 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(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() { 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.roomIds.Contains(room.roomId) }; 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); } } /// /// 显示房间选选择弹窗 /// void LoadPage_LoadChooseRoomDialog() { Action action = (key, value) => { if (lastButton != null) { lastButton.IsSelected = false; } showedFunctionRoomId = key; if (showedFunctionRoomId == "0") { LoadFunctionListRow(allocatedList); } else { LoadFunctionListRow(allocatedList.FindAll((obj) => obj.roomIds.Contains(showedFunctionRoomId))); } btnChoosedRoom.Text = value; }; Dictionary items = new Dictionary(); items.Add("0",Language.StringByID(StringId.All)); foreach(var room in SpatialInfo.CurrentSpatial.RoomList) { items.Add(room.roomId,room.roomName); } var chooseDialog = new ListCellDialog(items,showedFunctionRoomId,action); chooseDialog.ShowRightDialog(); //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 SpatialInfo.CurrentSpatial.RoomList) //{ // Button btnRoom = new Button() // { // X = Application.GetRealWidth(16), // Width = Application.GetRealWidth(128), // Height = Application.GetRealHeight(50), // Text = tempRoom.roomName, // TextColor = CSS_Color.FirstLevelTitleColor, // SelectedTextColor = CSS_Color.MainColor, // TextSize = CSS_FontSize.SubheadingFontSize, // TextAlignment = TextAlignment.CenterLeft, // IsSelected = showedFunctionRoomId == tempRoom.roomId, // Tag = tempRoom.roomId, // }; // roomListView.AddChidren(btnRoom); // LoadEvent_ChangeShowedFunctionList(btnRoom, dialog, tempRoom.roomName); // 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(); } } }