using System; using Shared; using HDL_ON.UI.CSS; using HDL_ON.Entity; using System.Collections.Generic; namespace HDL_ON.UI { public partial class SceneFunctionListEditPage : FrameLayout { FrameLayout bodyView; FrameLayout showdFunctionTypeRow; /// /// 楼层选择下拉图标 /// Button btnFloorDownIcon; /// /// 楼层显示 /// Button btnFloor; /// /// 筛选选择下拉图标 /// Button btnScreenIcon; /// /// 筛选文本显示 /// Button btnScreenText; /// /// 筛选条件1 /// string screen1; /// /// 筛选条件2 /// string screen2; VerticalScrolViewLayout functionListView; List allocatedList; List unallocatedList; Scene scene; Action refreshAction; public SceneFunctionListEditPage(Scene function,Action action) { bodyView = this; scene = function; allocatedList = new List(); unallocatedList = new List(); refreshAction = () => { this.RemoveFromParent(); action(); }; } /// /// 加载界面 /// 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.residenceData.CurFoor, }; 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 DB_ResidenceData.functionList.GetAllDeviceFunctionList()) { if (function == null) { continue; } function.roomIdList.Remove(null); if (scene.sceneFunctionList.Find((obj) => obj.sid == function.sid) != null) { allocatedList.Add(function); } else { unallocatedList.Add(function); } } LoadFunctionListRow(); LoadEventList(); } /// /// 显示功能Row /// /// 是否是显示未分配 void LoadFunctionListRow() { functionListView.RemoveAll(); List functions = new List(); functions.AddRange(unallocatedList); functions.AddRange(allocatedList); foreach (var function in functions) { if (function.functionCategory != FunctionCategory.Light && function.functionCategory != FunctionCategory.Thermostat && function.functionCategory != FunctionCategory.Curtain ) { continue; } //按楼层筛选 if (!string.IsNullOrEmpty(screen1)) { if (!function.roomIdList.Contains(screen1)) { continue; } } //按类型筛选 if (!string.IsNullOrEmpty(screen2)) { //if (!function.functionType!= screen2) //{ // 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); 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; } 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); } } /// /// 住宅列表点击事件 /// void LoadDialog_ChangeFloor() { EventHandler eventHandler = (sender, e) => { var dialog = new Dialog(); var dialogBody = new FrameLayout(); dialog.AddChidren(dialogBody); dialogBody.MouseUpEventHandler += (sender1, e1) => { dialog.Close(); }; var dispalyView = new FrameLayout() { X = Application.GetRealWidth(10), Y = Application.GetRealHeight(100), Width = Application.GetRealWidth(160), Height = Application.GetRealHeight(110), BackgroundImagePath = "PersonalCenter/HomeList1bg.png", }; dialogBody.AddChidren(dispalyView); var contentView = new VerticalScrolViewLayout() { X = Application.GetRealWidth(8), Y = Application.GetRealHeight(15), Width = Application.GetRealWidth(150), Height = Application.GetRealHeight(45 * 2), ScrollEnabled = false }; dispalyView.AddChidren(contentView); if (DB_ResidenceData.residenceData.floors.Count < 2) { } else if (DB_ResidenceData.residenceData.floors.Count < 3) { dispalyView = new FrameLayout() { X = Application.GetRealWidth(10), Y = Application.GetRealHeight(100), Width = Application.GetRealWidth(160), Height = Application.GetRealHeight(155), BackgroundImagePath = "PersonalCenter/HomeList2bg.png", }; dialogBody.AddChidren(dispalyView); contentView.Height = Application.GetRealHeight(45 * 3); dispalyView.AddChidren(contentView); } else if (DB_ResidenceData.residenceData.floors.Count < 4) { dispalyView = new FrameLayout() { X = Application.GetRealWidth(10), Y = Application.GetRealHeight(100), Width = Application.GetRealWidth(160), Height = Application.GetRealHeight(200), BackgroundImagePath = "PersonalCenter/HomeList3bg.png", }; dialogBody.AddChidren(dispalyView); contentView.Height = Application.GetRealHeight(45 * 4); dispalyView.AddChidren(contentView); } else { dispalyView = new FrameLayout() { X = Application.GetRealWidth(10), Y = Application.GetRealHeight(100), Width = Application.GetRealWidth(160), Height = Application.GetRealHeight(245), BackgroundImagePath = "PersonalCenter/HomeList4bg.png", }; dialogBody.AddChidren(dispalyView); contentView.Height = Application.GetRealHeight(45 * 5); contentView.ScrollEnabled = true; dispalyView.AddChidren(contentView); } List chooseList = new List(); chooseList.Add(Language.StringByID(StringId.All)); foreach (var f in DB_ResidenceData.residenceData.floors) { chooseList.Add(f.name); } foreach (var floor in chooseList) { if (floor != Language.StringByID(StringId.All)) { contentView.AddChidren(new Button() { Gravity = Gravity.CenterHorizontal, Width = Application.GetRealWidth(112), Height = Application.GetRealHeight(1), BackgroundColor = CSS.CSS_Color.BackgroundColor }); } var btnHomeName = new Button() { Gravity = Gravity.CenterHorizontal, Width = Application.GetRealWidth(112), Height = Application.GetRealHeight(44), TextAlignment = TextAlignment.CenterLeft, TextColor = CSS.CSS_Color.FirstLevelTitleColor, SelectedTextColor = CSS.CSS_Color.MainColor, Text = floor, TextSize = CSS.CSS_FontSize.SubheadingFontSize, IsSelected = btnFloor.Text == floor, IsMoreLines = true, Tag = floor }; contentView.AddChidren(btnHomeName); btnHomeName.MouseUpEventHandler += (senderH, en) => { dialog.Close(); btnFloor.Text = floor; }; } dialog.Show(); }; btnFloor.MouseUpEventHandler = eventHandler; btnFloorDownIcon.MouseUpEventHandler = eventHandler; } } //--------------------------------------- public partial class SceneFunctionListEditPage { void LoadEventList() { LoadDialog_ChangeFloor(); } void LoadEvent_SkipEditFunctionInfo(FrameLayout view, Button btn1, Button btn2, Button btn3, Function function) { EventHandler eventHandler = (sender, e) => { var ssf = new SceneFunctionInfoEditPage(scene, function, 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; } } }