From 9bfb038efd24b6ab90a27605ef476b8fa46f7a2a Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Mon, 7 Feb 2022 13:13:25 -0500 Subject: [PATCH] preliminary scaffolding to support project settings --- .../UniversalEditor.Essential/ProjectType.cs | 1 + .../EditorApplication.cs | 33 +++++++++++++++++++ .../Panels/SolutionExplorerPanel.cs | 6 ++-- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/Libraries/UniversalEditor.Essential/ProjectType.cs b/Libraries/UniversalEditor.Essential/ProjectType.cs index cb4669b5..b5e688a6 100644 --- a/Libraries/UniversalEditor.Essential/ProjectType.cs +++ b/Libraries/UniversalEditor.Essential/ProjectType.cs @@ -60,6 +60,7 @@ namespace UniversalEditor public Setting.SettingCollection Variables { get; } = new Setting.SettingCollection(); public string ProjectFileExtension { get; set; } = null; + public SettingsProvider SettingsProvider { get; set; } = null; } /// /// A shortcut placed in the "Add New Item" menu when the project is selected. When diff --git a/Libraries/UniversalEditor.UserInterface/EditorApplication.cs b/Libraries/UniversalEditor.UserInterface/EditorApplication.cs index 59fb74ef..2867dfbf 100644 --- a/Libraries/UniversalEditor.UserInterface/EditorApplication.cs +++ b/Libraries/UniversalEditor.UserInterface/EditorApplication.cs @@ -1414,5 +1414,38 @@ namespace UniversalEditor.UserInterface private Perspective.PerspectiveCollection mvarPerspectives = new Perspective.PerspectiveCollection(); public Perspective.PerspectiveCollection Perspectives { get { return mvarPerspectives; } } + + public void ShowProjectSettings(UniversalEditor.ObjectModels.Project.ProjectObjectModel project) + { + List list = new List(); + foreach (ProjectType projType in project.ProjectTypes) + { + if (projType.SettingsProvider != null) + { + list.Add(projType.SettingsProvider); + } + } + if (list.Count > 0) + { + SettingsDialog dlg = new SettingsDialog(); + dlg.SettingsProviders.Clear(); + foreach (SettingsProvider sp in list) + { + dlg.SettingsProviders.Add(sp); + } + + dlg.Text = String.Format("{0} Properties", project.Title); + if (dlg.ShowDialog() == DialogResult.OK) + { + // TODO: apply properties to project + } + return; + } + + Accessors.MemoryAccessor ma = new Accessors.MemoryAccessor(new byte[0], String.Format("{0} Properties", project.Title)); + Document d = new Document(project, null, ma); + d.Title = String.Format("{0} Properties", project.Title); + ((Application.Instance as UIApplication).CurrentWindow as IHostApplicationWindow).OpenFile(d); + } } } diff --git a/Libraries/UniversalEditor.UserInterface/Panels/SolutionExplorerPanel.cs b/Libraries/UniversalEditor.UserInterface/Panels/SolutionExplorerPanel.cs index 2ff009fe..28e7ca79 100644 --- a/Libraries/UniversalEditor.UserInterface/Panels/SolutionExplorerPanel.cs +++ b/Libraries/UniversalEditor.UserInterface/Panels/SolutionExplorerPanel.cs @@ -19,6 +19,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . using System; +using System.Collections.Generic; using MBS.Framework; using MBS.Framework.UserInterface; using MBS.Framework.UserInterface.Controls; @@ -300,10 +301,7 @@ namespace UniversalEditor.UserInterface.Panels ProjectFolder folder = e.Row.GetExtraData("folder"); if (project != null) { - Accessors.MemoryAccessor ma = new Accessors.MemoryAccessor(new byte[0], String.Format("{0} Properties", project.Title)); - Document d = new Document(project, null, ma); - d.Title = String.Format("{0} Properties", project.Title); - ((Application.Instance as UIApplication).CurrentWindow as IHostApplicationWindow).OpenFile(d); + ((EditorApplication)Application.Instance).ShowProjectSettings(project); } else if (file != null) {