Revise help, rename type to match behavior

This commit is contained in:
John Lewin 2018-06-30 23:26:57 -07:00
parent 75e51a7183
commit 31a6bdc36e
8 changed files with 83 additions and 97 deletions

View file

@ -116,7 +116,7 @@ namespace MatterHackers.MatterControl
public class ApplicationController
{
public HelpContainer FeatureGuides { get; set; }
public HelpArticle HelpArticles { get; set; }
private Dictionary<Type, HashSet<IObject3DEditor>> 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<HelpContainer>(AggContext.StaticData.ReadAllText(helpGuidesPath));
helpArticle = JsonConvert.DeserializeObject<HelpArticle>(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"));
});
}

View file

@ -107,7 +107,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage
{
UiThread.RunOnIdle(() =>
{
DialogWindow.Show(new DesignSpaceGuide("AllGuides"));
DialogWindow.Show(new HelpPage("AllGuides"));
});
});

View file

@ -259,8 +259,8 @@
<Compile Include="PrinterControls\MovementSpeedsPage.cs" />
<Compile Include="PrinterControls\PrinterConnections\PrinterSetup.cs" />
<Compile Include="RootSystemWindow.cs" />
<Compile Include="SetupWizard\DesignSpaceHelp.cs" />
<Compile Include="SetupWizard\DialogWindow.cs" />
<Compile Include="SetupWizard\HelpPage.cs" />
<Compile Include="SlicerConfiguration\SettingsOrganizer.cs" />
<Compile Include="SlicerConfiguration\SettingsRow.cs" />
<Compile Include="SlicerConfiguration\UIFields\CharField.cs" />

View file

@ -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);

View file

@ -611,7 +611,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
{
UiThread.RunOnIdle(() =>
{
DialogWindow.Show(new DesignSpaceGuide());
DialogWindow.Show(new HelpPage());
});
}
}

View file

@ -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
{
/// <summary>
/// The name that is in the navigation list with categories
/// </summary>
public string MenuName;
public string Name;
/// <summary>
/// The markdown to show
/// </summary>
public string Description;
public string Path;
/// <summary>
/// This is the immutable key assigned to this guide. It can
/// be used to navigate to this guide while opening the control
/// </summary>
public string Key;
public List<HelpArticle> Children { get; set; } = new List<HelpArticle>();
}
public class HelpContainer
{
public List<HelpContainer> Containers { get; set; } = new List<HelpContainer>();
public List<GuideAsset> Items { get; set; } = new List<GuideAsset>();
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;

View file

@ -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"
}

View file

@ -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": []
}
]
}