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(); #endregion public RoomEditFunctionPage(Room r) { bodyView = this; room = r; } /// /// 加载界面 /// 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); 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); 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 DB_ResidenceData.functionList.GetAllFunction()) { function.roomIdList.Remove(null); if (function.roomIdList.Count > 0 ) { allocatedList.Add(function); } else { unallocatedList.Add(function); } } LoadFunctionListRow(unallocatedList); btnConfrim = new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(582), Width = Application.GetRealWidth(220), Height = Application.GetRealHeight(44), Radius = (uint)Application.GetRealHeight(22), BackgroundColor = CSS_Color.MainColor, TextColor = CSS_Color.MainBackgroundColor, TextSize = CSS_FontSize.SubheadingFontSize, TextAlignment = TextAlignment.Center, IsBold = true, TextID = StringId.Confirm, }; bodyView.AddChidren(btnConfrim); LoadEventList(); } /// /// 显示功能Row /// /// 是否是显示未分配 void LoadFunctionListRow(List functions) { showdFunctionCount = 0; functionListView.RemoveAll(); foreach (var function in functions) { 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); switch (function.functionCategory) { case FunctionCategory.Thermostat: switch (function.functionType) { case FunctionType.AC: btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/AC/AcThinIcon1.png"; break; case FunctionType.FloorHeating: btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/FloorHeating/FloorHeatingThinIcon.png"; break; } break; case FunctionCategory.Curtain: btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/Curtain/CurtainThinIcon.png"; break; case FunctionCategory.Light: btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/Light/LightThinIcon.png"; break; case FunctionCategory.SwitchDevice: switch (function.functionType) { case FunctionType.Socket: btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/Socket/SocketThinIcon.png"; break; } break; case FunctionCategory.Electrical: switch (function.functionType) { case FunctionType.Fan: btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/Electrical/FanThinIcon.png"; break; case FunctionType.TV: btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/Electrical/TVThinIcon.png"; break; } break; case FunctionCategory.Scene: btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/Scene/SceneIcon.png"; break; case FunctionCategory.Music: btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/Music/MusicThinIcon.png"; break; case FunctionCategory.Sensor: switch(function.functionType) { case FunctionType.PM25: btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/EnvironmentalScience/FunctionIconPm25.png"; break; case FunctionType.CO2: btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/EnvironmentalScience/FunctionIconCO2.png"; break; case FunctionType.TVOC: btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/EnvironmentalScience/FunctionIconTVOC.png"; break; case FunctionType.Humidity: btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/EnvironmentalScience/FunctionIconHumidity.png"; break; case FunctionType.Temp: btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/EnvironmentalScience/FunctionIconTemp.png"; break; } break; } 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.roomIdList.Contains(room.sid) }; 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() { 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 DB_ResidenceData.rooms) { Button btnRoom = new Button() { X = Application.GetRealWidth(16), Width = Application.GetRealWidth(128), Height = Application.GetRealHeight(50), Text = tempRoom.name, TextColor = CSS_Color.FirstLevelTitleColor, SelectedTextColor = CSS_Color.MainColor, TextSize = CSS_FontSize.SubheadingFontSize, TextAlignment = TextAlignment.CenterLeft, IsSelected = showedFunctionRoomId == tempRoom.sid, Tag = tempRoom.sid, }; roomListView.AddChidren(btnRoom); LoadEvent_ChangeShowedFunctionList(btnRoom, dialog, tempRoom.name); 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(); } } }