From 6d73bf6e816570291865674bef8bce8972e4de3f Mon Sep 17 00:00:00 2001 From: xm <1271024303@qq.com> Date: 星期三, 01 十二月 2021 16:32:57 +0800 Subject: [PATCH] 2021-12-01-01 --- HDL_ON/UI/UI2/2-Classification/FunctionPage.cs | 304 ++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 240 insertions(+), 64 deletions(-) diff --git a/HDL_ON/UI/UI2/2-Classification/FunctionPage.cs b/HDL_ON/UI/UI2/2-Classification/FunctionPage.cs index a30b951..3db5ac0 100644 --- a/HDL_ON/UI/UI2/2-Classification/FunctionPage.cs +++ b/HDL_ON/UI/UI2/2-Classification/FunctionPage.cs @@ -1,5 +1,6 @@ 锘縰sing System; using System.Collections.Generic; +using System.Linq; using HDL_ON.Entity; using HDL_ON.UI.CSS; using Shared; @@ -13,21 +14,57 @@ /// </summary> static FrameLayout bodyView; /// <summary> + /// 妤煎眰閫夋嫨涓嬫媺鍥炬爣 + /// </summary> + Button btnFloorDownIcon; + /// <summary> + /// 妤煎眰鏄剧ず + /// </summary> + Button btnFloor; + /// <summary> /// 鍔熻兘鍒楄〃闆嗗悎鏄剧ず鍖哄煙 /// </summary> static VerticalScrolViewLayout functionListView; #endregion + List<Function> functionList; + public FunctionPage() { bodyView = this; + functionList = new List<Function>(); } public void LoadPage(int titleId) { bodyView.BackgroundColor = CSS_Color.BackgroundColor; - new TopViewDiv(bodyView, Language.StringByID(titleId)).LoadTopView(); + if (titleId == StringId.Lights) + { + Action action = () => + { + Action<Scene > refreshAction = (outScene) => { + if (outScene != null) + { + functionListView.AddChidren(new Button() { Height = Application.GetRealHeight(12) }); + + var sceneRow = new SceneControlZone(outScene); + functionListView.AddChidren(sceneRow); + sceneRow.LoadView(); + } + }; + + var skipView = new AddLightScene(new List<Function>(), new Scene() { sceneType = SceneType.LightScene }, refreshAction); + MainPage.BasePageView.AddChidren(skipView); + skipView.LoadPage(); + MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + }; + new TopViewDiv(bodyView, Language.StringByID(titleId)).LoadTopView_LightFunction(action); + } + else + { + new TopViewDiv(bodyView, Language.StringByID(titleId)).LoadTopView(); + } /// <summary> /// 鎴块棿鍐呭鏄剧ず鍖哄煙 /// </summary> @@ -38,10 +75,7 @@ }; bodyView.AddChidren(roomFloorChangeView); #region 鎴块棿椤堕儴鍒囨崲鏄剧ず鍖哄煙 - /// <summary> - /// 妤煎眰閫夋嫨涓嬫媺鍥炬爣 - /// </summary> - var btnFoorDownIcon = new Button() + btnFloorDownIcon = new Button() { Width = Application.GetMinRealAverage(16), Height = Application.GetMinRealAverage(16), @@ -49,22 +83,20 @@ Y = Application.GetRealHeight(18), UnSelectedImagePath = "Public/DownIcon.png", }; - roomFloorChangeView.AddChidren(btnFoorDownIcon); - /// <summary> - /// 妤煎眰鏄剧ず - /// </summary> - var btnFoor = new Button() + roomFloorChangeView.AddChidren(btnFloorDownIcon); + + btnFloor = new Button() { - X = btnFoorDownIcon.Right, + 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 = OnAppConfig.Instance.CurFoor, + Text = DB_ResidenceData.Instance.CurFloor.roomName, }; - roomFloorChangeView.AddChidren(btnFoor); + roomFloorChangeView.AddChidren(btnFloor); #endregion functionListView = new VerticalScrolViewLayout() @@ -74,58 +106,69 @@ }; bodyView.AddChidren(functionListView); - foreach (var function in DB_ResidenceData.functionList.GetAllFunction()) + if (titleId == StringId.Lights) { - if (titleId == StringId.Lights) - { - if (function.functionCategory != FunctionCategory.Light) - { - continue; - } - } - if (titleId == StringId.AC) - { - if (function.functionType != FunctionType.AC) - { - continue; - } - } - if (titleId == StringId.Curtain) - { - if (function.functionCategory != FunctionCategory.Curtain) - { - continue; - } - } - if(titleId == StringId.FloorHeating) - { - if(function.functionType != FunctionType.FloorHeating ) - { - continue; - } - } - if(titleId == StringId.Electric) - { - if(function.functionType != FunctionType.Socket && - function.functionType != FunctionType.TV && - function.functionType != FunctionType.Fan) - { - continue; - } - } - if (titleId == StringId.EnvironmentalScience) - { + functionList.AddRange(FunctionList.List.GetLightList()); + var lightScene = FunctionList.List.scenes.FindAll((obj) => obj.sceneType == SceneType.LightScene); - if (function.functionType != FunctionType.PM25 || - function.functionType != FunctionType.CO2 || - function.functionType != FunctionType.Temp || - function.functionType != FunctionType.TVOC || - function.functionType != FunctionType.Humidity) - { - continue; - } + foreach (var scene in lightScene) + { + functionListView.AddChidren(new Button() { Height = Application.GetRealHeight(12) }); + + var sceneRow = new SceneControlZone(scene); + functionListView.AddChidren(sceneRow); + sceneRow.LoadView(); } - if (function.functionType == FunctionType.RGB || function.functionType == FunctionType.Dimmer) + + } + else if (titleId == StringId.AC) + { + functionList.AddRange(FunctionList.List.GetAcList()); + } + else if (titleId == StringId.Curtain) + { + functionList.AddRange(FunctionList.List.GetCurtainList()); + } + else if (titleId == StringId.FloorHeating) + { + functionList.AddRange(FunctionList.List.GetFloorHeatingList()); + } + else if (titleId == StringId.Electric) + { + functionList.AddRange(FunctionList.List.GetElectricals()); + } + else if (titleId == StringId.EnvironmentalScience) + { + functionList.AddRange(FunctionList.List.GetEnvirSensorsList()); + } + else if (titleId == StringId.Sensor) + { + functionList.AddRange(FunctionList.List.GetArmSensorList()); + } + else if (titleId == StringId.FreshAir) + { + functionList.AddRange(FunctionList.List.GetAirFreshList()); + } + functionList.OrderByDescending(o => o.controlCounter).ToList(); + + ShowFunctionRow(functionList); + + LoadDialog_ChangeFloor(); + } + + /// <summary> + /// 鍔犺浇鍔熻兘row + /// </summary> + void ShowFunctionRow(List<Function> showList) + { + functionListView.RemoveAll(); + foreach (var function in showList) + { + if(function.spk == SPK.SensorDryContact|| function.spk == SPK.SensorDryContact2) + { + continue; + } + if (function.spk == SPK.LightRGB || function.spk == SPK.LightDimming) { var functionDiv = new FunctionControlZone(function) { @@ -136,7 +179,7 @@ BorderColor = 0x00FFFFFF, BorderWidth = 1, BackgroundColor = CSS_Color.MainBackgroundColor, - Tag = function.functionCategory.ToString() + "-" + function.functionType + Tag = function.spk + function.sid }; functionDiv.LoadFunctionDiv(); functionListView.AddChidren(functionDiv); @@ -152,14 +195,147 @@ BorderColor = 0x00FFFFFF, BorderWidth = 1, BackgroundColor = CSS_Color.MainBackgroundColor, - Tag = function.functionCategory.ToString() + "-" + function.functionType + Tag = function.spk + function.sid }; functionDiv.LoadFunctionDiv(); functionListView.AddChidren(functionDiv); } functionListView.AddChidren(new Button() { Height = Application.GetRealHeight(10) }); } + } + + ///// <summary> + ///// 鍔犺浇鍔熻兘绫诲瀷鎺у埗鍗$墖 + ///// </summary> + //public void LoadSceneRow(Scene scene) + //{ + // var bodyDiv = new FrameLayout() + // { + // 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 = "Scene-" + scene.sid + // }; + // functionListView.AddChidren(bodyDiv); + + // var btnIcon = new Button() + // { + // X = Application.GetRealWidth(10), + // Y = Application.GetRealHeight(15), + // Width = Application.GetRealWidth(32), + // Height = Application.GetRealWidth(32), + // }; + // bodyDiv.AddChidren(btnIcon); + + // var btnName = new Button() + // { + // X = Application.GetRealWidth(8 + 10 + 32), + // Y = Application.GetRealHeight(10), + // Width = Application.GetRealWidth(200), + // Height = Application.GetRealHeight(24), + // Text = scene.name, + // TextAlignment = TextAlignment.CenterLeft, + // TextColor = CSS_Color.FirstLevelTitleColor, + // TextSize = CSS_FontSize.TextFontSize, + // }; + // bodyDiv.AddChidren(btnName); + + // var btnFromFloor = new Button() + // { + // X = Application.GetRealWidth(8 + 10 + 32), + // Y = Application.GetRealHeight(10 + 24), + // Width = Application.GetRealWidth(200), + // Height = Application.GetRealHeight(18), + // Text = scene.GetRoomListName(), + // TextAlignment = TextAlignment.CenterLeft, + // TextColor = CSS_Color.PromptingColor1, + // TextSize = CSS_FontSize.PromptFontSize_FirstLevel, + // }; + // bodyDiv.AddChidren(btnFromFloor); + + // var btnCollectionIcon = new Button() + // { + // X = Application.GetRealWidth(299), + // Y = Application.GetRealHeight(10), + // Width = Application.GetMinRealAverage(40), + // Height = Application.GetMinRealAverage(40), + // SelectedImagePath = "Collection/CollectionIcon.png", + // UnSelectedImagePath = "Collection/CollectionGrayIcon.png", + // IsSelected = scene.collect + // }; + // bodyDiv.AddChidren(btnCollectionIcon); + + // btnIcon.UnSelectedImagePath = "FunctionIcon/Scene/SceneIcon.png"; + // if (scene.sceneType == SceneType.MovieScene) + // { + // var movieIcon = new Button() + // { + // X = Application.GetRealWidth(52), + // Y = Application.GetRealHeight(14), + // Width = Application.GetRealWidth(16), + // Height = Application.GetRealWidth(16), + // UnSelectedImagePath = "FunctionIcon/Scene/MovieMark.png", + // }; + // bodyDiv.AddChidren(movieIcon); + // btnName.X = Application.GetRealWidth(52 + 16); + // } + // //鍔犺浇鍦烘櫙鎺у埗浜嬩欢 + // LoadEvent_ControlScene(btnName, btnFromFloor, bodyDiv, scene); + + // LoadEvent_FunctionCollection(btnCollectionIcon, scene); + //} + + + ///// <summary> + ///// 鍔犺浇鍔熻兘鏀惰棌鎸夐挳浜嬩欢 + ///// </summary> + //void LoadEvent_FunctionCollection(Button btnCollectionIcon, Scene scene) + //{ + // btnCollectionIcon.MouseUpEventHandler += (sender, e) => + // { + // btnCollectionIcon.IsSelected = scene.collect = !btnCollectionIcon.IsSelected; + // scene.CollectScene(); + // }; + //} + ///// <summary> + ///// 鍔犺浇鍦烘櫙鎺у埗浜嬩欢 + ///// </summary> + //void LoadEvent_ControlScene(Button btnName, Button btnFromFloor, FrameLayout bodyDiv, Scene scene) + //{ + // EventHandler<MouseEventArgs> upEvent = (sender, e) => { + // DriverLayer.Control.Ins.ControlScene(scene); + // string msg = scene.name + Language.StringByID(StringId.AlreadyOpened); + // new PublicAssmebly().TipMsgAutoClose(msg, false); + // }; + // btnName.MouseUpEventHandler = upEvent; + // btnFromFloor.MouseUpEventHandler = upEvent; + // bodyDiv.MouseUpEventHandler = upEvent; + //} + + + + /// <summary> + /// 浣忓畢鍒楄〃鐐瑰嚮浜嬩欢 + /// </summary> + 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); + }; } } } \ No newline at end of file -- Gitblit v1.8.0