diff --git a/ApplicationView/ApplicationController.cs b/ApplicationView/ApplicationController.cs index 4990abc31..d0011eb65 100644 --- a/ApplicationView/ApplicationController.cs +++ b/ApplicationView/ApplicationController.cs @@ -116,7 +116,7 @@ namespace MatterHackers.MatterControl public class ApplicationController { - public HelpContainer FeatureGuides { get; set; } + public HelpArticle HelpArticles { get; set; } private Dictionary> objectEditorsByType; @@ -670,19 +670,19 @@ namespace MatterHackers.MatterControl this.Theme = new ThemeConfig(); this.MenuTheme = new ThemeConfig(); - HelpContainer helpGuides = null; + HelpArticle helpArticle = null; - string helpGuidesPath = Path.Combine("OEMSettings", "HelpGuides.json"); - if (AggContext.StaticData.FileExists(helpGuidesPath)) + string helpPath = Path.Combine("OEMSettings", "toc.json"); + if (AggContext.StaticData.FileExists(helpPath)) { try { - helpGuides = JsonConvert.DeserializeObject(AggContext.StaticData.ReadAllText(helpGuidesPath)); + helpArticle = JsonConvert.DeserializeObject(AggContext.StaticData.ReadAllText(helpPath)); } catch { } } - this.FeatureGuides = helpGuides ?? new HelpContainer(); + this.HelpArticles = helpArticle ?? new HelpArticle(); ActiveTheme.ThemeChanged.RegisterEvent((s, e) => { @@ -2335,7 +2335,7 @@ namespace MatterHackers.MatterControl { UiThread.RunOnIdle(() => { - DialogWindow.Show(new DesignSpaceGuide("AllGuides")); + DialogWindow.Show(new HelpPage("AllGuides")); }); } diff --git a/ConfigurationPage/ApplicationSettings/ApplicationSettingsView.cs b/ConfigurationPage/ApplicationSettings/ApplicationSettingsView.cs index 0c98631f0..cd061f26f 100644 --- a/ConfigurationPage/ApplicationSettings/ApplicationSettingsView.cs +++ b/ConfigurationPage/ApplicationSettings/ApplicationSettingsView.cs @@ -107,7 +107,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage { UiThread.RunOnIdle(() => { - DialogWindow.Show(new DesignSpaceGuide("AllGuides")); + DialogWindow.Show(new HelpPage("AllGuides")); }); }); diff --git a/MatterControl.csproj b/MatterControl.csproj index 3c503d7e5..eb45208fa 100644 --- a/MatterControl.csproj +++ b/MatterControl.csproj @@ -259,8 +259,8 @@ - + diff --git a/PartPreviewWindow/PartPreviewContent.cs b/PartPreviewWindow/PartPreviewContent.cs index df93b23f2..6c0d03cba 100644 --- a/PartPreviewWindow/PartPreviewContent.cs +++ b/PartPreviewWindow/PartPreviewContent.cs @@ -102,7 +102,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow seeWhatsNewButton.Click += (s, e) => UiThread.RunOnIdle(() => { UserSettings.Instance.set(UserSettingsKey.LastReadWhatsNew, JsonConvert.SerializeObject(DateTime.Now)); - DialogWindow.Show(new DesignSpaceGuide("What's New")); + DialogWindow.Show(new HelpPage("What's New")); }); tabControl.TabBar.ActionArea.AddChild(seeWhatsNewButton); diff --git a/PartPreviewWindow/ViewControls3D.cs b/PartPreviewWindow/ViewControls3D.cs index 6288e5850..fc68a70c0 100644 --- a/PartPreviewWindow/ViewControls3D.cs +++ b/PartPreviewWindow/ViewControls3D.cs @@ -611,7 +611,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { UiThread.RunOnIdle(() => { - DialogWindow.Show(new DesignSpaceGuide()); + DialogWindow.Show(new HelpPage()); }); } } diff --git a/SetupWizard/DesignSpaceHelp.cs b/SetupWizard/HelpPage.cs similarity index 87% rename from SetupWizard/DesignSpaceHelp.cs rename to SetupWizard/HelpPage.cs index 0b62cb767..fbcf447c4 100644 --- a/SetupWizard/DesignSpaceHelp.cs +++ b/SetupWizard/HelpPage.cs @@ -29,7 +29,6 @@ either expressed or implied, of the FreeBSD Project. using System; using System.Collections.Generic; -using System.IO; using System.Linq; #if !__ANDROID__ using Markdig.Agg; @@ -41,42 +40,24 @@ using MatterHackers.Localizations; using MatterHackers.MatterControl.CustomWidgets; using MatterHackers.MatterControl.PartPreviewWindow; using MatterHackers.VectorMath; -using Newtonsoft.Json; namespace MatterHackers.MatterControl { - public class GuideAsset + public class HelpArticle { - /// - /// The name that is in the navigation list with categories - /// - public string MenuName; + public string Name; - /// - /// The markdown to show - /// - public string Description; + public string Path; - /// - /// This is the immutable key assigned to this guide. It can - /// be used to navigate to this guide while opening the control - /// - public string Key; + public List Children { get; set; } = new List(); } - public class HelpContainer - { - public List Containers { get; set; } = new List(); - public List Items { get; set; } = new List(); - public string Name { get; set; } - } - - public class DesignSpaceGuide : DialogPage + public class HelpPage : DialogPage { private TreeView treeView; private string guideKey = null; - public DesignSpaceGuide(string guideKey = null) + public HelpPage(string guideKey = null) : base("Close".Localize()) { WindowSize = new Vector2(940, 700); @@ -268,15 +249,9 @@ namespace MatterHackers.MatterControl treeView.AfterSelect += (s, e) => { #if !__ANDROID__ - if (treeView.SelectedNode.Tag is GuideAsset guide) + if (treeView.SelectedNode.Tag is string path) { - markdownWidget.Markdown = guide.Description; - } - else if (treeView.SelectedNode.Tag is string key) - { - // TODO: Fix in generation when time permits - string filterHack = key.Replace("/docs", ""); - markdownWidget.Load(new Uri($"https://matterhackers.github.io/MatterControl-Help{filterHack}")); + markdownWidget.Load(new Uri($"https://matterhackers.github.io/MatterControl-Help/{path}")); } #endif }; @@ -309,7 +284,7 @@ namespace MatterHackers.MatterControl double maxMenuItemWidth = 0; - rootNode = ProcessTree(ApplicationController.Instance.FeatureGuides); + rootNode = ProcessTree(ApplicationController.Instance.HelpArticles); rootNode.Text = "Help"; rootNode.TreeView = treeView; treeView.AddChild(rootNode); @@ -328,25 +303,27 @@ namespace MatterHackers.MatterControl guideContainer.AddChild(splitter); } - private TreeNode ProcessTree(HelpContainer container) + private TreeNode ProcessTree(HelpArticle container) { var treeNode = new TreeNode(false) { Text = container.Name, }; - foreach(var child in container.Containers) + foreach (var item in container.Children) { - treeNode.Nodes.Add(ProcessTree(child)); - } - - foreach (var item in container.Items) - { - treeNode.Nodes.Add(new TreeNode() + if (item.Children.Count > 0) { - Text = item.MenuName, - Tag = item.Key - }); + treeNode.Nodes.Add(ProcessTree(item)); + } + else + { + treeNode.Nodes.Add(new TreeNode(false) + { + Text = item.Name, + Tag = item.Path + }); + } } return treeNode; diff --git a/StaticData/OEMSettings/HelpGuides.json b/StaticData/OEMSettings/HelpGuides.json deleted file mode 100644 index f8875d118..000000000 --- a/StaticData/OEMSettings/HelpGuides.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "Containers": [], - "Items": [ - { - "MenuName": "Adding Parts", - "Description": null, - "Key": "/docs/adding-parts.md" - }, - { - "MenuName": "Hotend Controls", - "Description": null, - "Key": "/docs/hotend-controls.md" - }, - { - "MenuName": "Rotate Controls", - "Description": null, - "Key": "/docs/rotate-controls.md" - }, - { - "MenuName": "Scale Controls", - "Description": null, - "Key": "/docs/scale-controls.md" - }, - { - "MenuName": "Starting A Print", - "Description": null, - "Key": "/docs/starting-a-print.md" - }, - { - "MenuName": "Support", - "Description": null, - "Key": "/docs/support.md" - }, - { - "MenuName": "Whats New", - "Description": null, - "Key": "/docs/whats-new.md" - } - ], - "Name": "docs" -} \ No newline at end of file diff --git a/StaticData/OEMSettings/toc.json b/StaticData/OEMSettings/toc.json new file mode 100644 index 000000000..e1ffb66d0 --- /dev/null +++ b/StaticData/OEMSettings/toc.json @@ -0,0 +1,50 @@ +{ + "Name": "Docs", + "Children": [ + { + "Name": "User Interface", + "Children": [ + { + "Name": "Gcode 3D", + "Path": "user-interface/gcode-3d.md", + "Children": [] + } + ] + }, + { + "Name": "Adding Parts", + "Path": "adding-parts.md", + "Children": [] + }, + { + "Name": "Hotend Controls", + "Path": "hotend-controls.md", + "Children": [] + }, + { + "Name": "Rotate Controls", + "Path": "rotate-controls.md", + "Children": [] + }, + { + "Name": "Scale Controls", + "Path": "scale-controls.md", + "Children": [] + }, + { + "Name": "Starting A Print", + "Path": "starting-a-print.md", + "Children": [] + }, + { + "Name": "Support", + "Path": "support.md", + "Children": [] + }, + { + "Name": "Whats New", + "Path": "whats-new.md", + "Children": [] + } + ] +} \ No newline at end of file