/// <summary> /// Saves the configuration. /// </summary> /// <param name="config">The configuration.</param> /// <param name="strHelpDirectory">The string help directory.</param> /// <exception cref="NotImplementedException"></exception> public static void SaveConfig(HelpConfig config, string strHelpDirectory) { //string strConfigFilenameJSON = string.Format("{0}\\{1}", strHelpDirectory, CONFGIG_FILE_JSON); //string strJsonContent = JsonConvert.SerializeObject(config, Formatting.Indented); //File.WriteAllText(strConfigFilenameJSON, strJsonContent, Encoding.Default); string strConfigFilenameYAML = string.Format("{0}\\{1}", strHelpDirectory, CONFGIG_FILE_YAML); string strYamlContent = new SerializerBuilder().Build().Serialize(config); File.WriteAllText(strConfigFilenameYAML, strYamlContent, Encoding.Default); }
private void CreateHelp() { this.sdHelpPages.Clear(); if (Path.IsEmpty()) { //TODO: Warning or Error ? return; } if (Path.StartsWith(".\\")) { Path = string.Format("{0}\\{1}", Tools.Tool.StartupPath, Path); } if (Directory.Exists(Path) == false) { //TODO: Warning or Error ? return; } HelpConfig hc = HelpConfigFactory.LoadConfig(Path); if (hc == null) { //TODO: Warning or Error ? return; } if (hc.MainPage.Validate() == false) { //TODO: Warning or Error ? return; } AddMainPage(hc); }
/// <summary> /// Creates the template. /// </summary> /// <param name="strHelpDirectory">The string help directory.</param> public static void CreateTemplate(string strHelpDirectory) { HelpConfig config = new HelpConfig { MainPage = new HelpPage { Caption = "Home", Document = "Home.md" } }; config.Pages.Add(new HelpPage { /*Caption = "Download", */ Document = "Download.md" }); config.Pages.Add(new HelpPage { Caption = "Install" /*, Document = "Install.md"*/ }); config.Pages.Add(new HelpPage { Caption = "Screenshots" /*, Document = "Screenshots.md"*/ }); config.Pages.Add(new HelpPage { Caption = "Third Party Libraries", Document = "ThirdPartyLibraries.md" }); SaveConfig(config, strHelpDirectory); }
/// <summary> /// Adds the main page. /// </summary> /// <param name="hc">The hc.</param> private void AddMainPage(HelpConfig hc) { //string strMarkdownFilename = $"{Path}\\{hc.MainPage.Document}"; //string strMarkdownContent = File.Exists(strMarkdownFilename) ? File.ReadAllText(strMarkdownFilename, Encoding.Default) : LoremIpsum.GetLoremIpsum(); string strTemplateContent = File.ReadAllText(@"O:\SIGENCE-Scenario-Tool\Documentation\Help\main.html", Encoding.Default); //--------------------------------------------------------------------------------------------------------- StringBuilder sbBTN = new StringBuilder(8192); StringBuilder sbTAB = new StringBuilder(8192); sbBTN.Append($"<button class=\"tablink\" onclick=\"openPage('{hc.MainPage.Caption}', this, 'gray')\" id=\"defaultOpen\">{hc.MainPage.Caption}</button>\n"); sbTAB.Append($"<div id=\"Home\" class=\"tabcontent\">{CreateHTMLFromMarkdown(hc.MainPage)}</div>\n"); foreach (HelpPage hp in hc.Pages) { // Wenn beide leer sind können wir nix weiter machen if (hp.Validate() == false) { continue; } sbBTN.Append($"<button class=\"tablink\" onclick=\"openPage('{hp.Caption}', this, 'gray')\">{hp.Caption}</button>\n"); //sbTAB.Append($"<div id=\"{hp.Caption}\" class=\"tabcontent\"><iframe src=\"./{hp.Document}\" /></div>\n"); sbTAB.Append($"<div id=\"{hp.Caption}\" class=\"tabcontent\">{CreateHTMLFromMarkdown(hp)}</div>\n"); } //--------------------------------------------------------------------------------------------------------- try { StringBuilder sbDependencies = new StringBuilder(8192); sbDependencies.AppendLine("# Dependencies"); sbDependencies.AppendLine(); sbDependencies.AppendLine("|Package|Version|Link|"); sbDependencies.AppendLine("|:------|:------|:---|"); string strDependencyFile = @"O:\SIGENCE-Scenario-Tool\Source\SIGENCEScenarioTool.Library\packages.config"; XDocument xdoc = XDocument.Load(strDependencyFile); foreach (XElement package in xdoc.Root.Elements("package")) { string strPackageName = package.Attribute("id").Value; string strPackageVersion = package.Attribute("version").Value; sbDependencies.AppendLine($"|{strPackageName}|{strPackageVersion}|https://www.nuget.org/packages/{strPackageName}/|"); } sbBTN.Append($"<button class=\"tablink\" onclick=\"openPage('dependencies', this, 'gray')\" id=\"defaultOpen\">Dependencies</button>\n"); sbTAB.Append($"<div id=\"dependencies\" class=\"tabcontent\">{CreateHTMLFromMarkdown(sbDependencies.ToString())}</div>\n"); } catch (Exception) { } //--------------------------------------------------------------------------------------------------------- try { string strReleaseNotes = ".\\ReleaseNotes\\ReleaseNotes.Markdown.md"; string strMarkdownContent = File.ReadAllText(strReleaseNotes); sbBTN.Append($"<button class=\"tablink\" onclick=\"openPage('ReleaseNotes', this, 'gray')\" id=\"defaultOpen\">Release Notes</button>\n"); sbTAB.Append($"<div id=\"ReleaseNotes\" class=\"tabcontent\">{CreateHTMLFromMarkdown(strMarkdownContent)}</div>\n"); } catch (Exception) { } //--------------------------------------------------------------------------------------------------------- hc.MainPage.HtmlContent = strTemplateContent.Replace("$BUTTONS$", sbBTN.ToString()).Replace("$TABS$", sbTAB.ToString()); this.sdHelpPages.Add("/", hc.MainPage); }