using CefSharp; using CefSharp.WinForms; using Markdig; using System.Diagnostics; using System.Drawing.Drawing2D; namespace MintHTML { public partial class Form1 : Form { string appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); string markfile; string htmlfile = "

Welcome to MintHTML

Open a markdown file and press \"Render preview\" to see the output here.

"; string logo = @" M "; string css2 = "\n"; string css; bool extraInstance = false; int extraNum = 0; // Custom functions private void convert() { htmlfile = Markdown.ToHtml(markfile); } private void cssreload() { chromiumWebBrowser1.LoadHtml(css + css2 + "" + htmlfile); } private void darkui() { BackColor = Color.FromArgb(18,18,18); ForeColor = Color.White; button4.FlatStyle = FlatStyle.Flat; button4.BackColor = BackColor; button4.ForeColor = ForeColor; button3.FlatStyle = FlatStyle.Flat; button3.BackColor = BackColor; button3.ForeColor = ForeColor; button2.FlatStyle = FlatStyle.Flat; button2.BackColor = BackColor; button2.ForeColor = ForeColor; textBox2.BackColor = BackColor; textBox2.ForeColor = ForeColor; menuStrip1.BackColor = BackColor; menuStrip1.ForeColor = ForeColor; menuStrip1.RenderMode = ToolStripRenderMode.Professional; aboutToolStripMenuItem.BackColor = BackColor; aboutToolStripMenuItem.ForeColor = ForeColor; openDevToolsToolStripMenuItem.BackColor = BackColor; openDevToolsToolStripMenuItem.ForeColor = ForeColor; exitToolStripMenuItem.BackColor = BackColor; exitToolStripMenuItem.ForeColor = ForeColor; fontFamilyToolStripMenuItem.BackColor = BackColor; fontFamilyToolStripMenuItem.ForeColor = ForeColor; colorThemeToolStripMenuItem.BackColor = BackColor; colorThemeToolStripMenuItem.ForeColor = ForeColor; fullUIToolStripMenuItem.BackColor = BackColor; fullUIToolStripMenuItem.ForeColor = ForeColor; systemToolStripMenuItem.BackColor = BackColor; systemToolStripMenuItem.ForeColor = ForeColor; lightToolStripMenuItem.BackColor = BackColor; lightToolStripMenuItem.ForeColor = ForeColor; darkToolStripMenuItem.BackColor = BackColor; darkToolStripMenuItem.ForeColor = ForeColor; serifToolStripMenuItem.BackColor = BackColor; serifToolStripMenuItem.ForeColor = ForeColor; sansSerifToolStripMenuItem.BackColor = BackColor; sansSerifToolStripMenuItem.ForeColor = ForeColor; forceMonospaceToolStripMenuItem.BackColor = BackColor; forceMonospaceToolStripMenuItem.ForeColor = ForeColor; } // Custom functions end public Form1() { if (File.Exists(appdata + "/SweeZero/MintHTML/Caches/Instance/lockfile")) { extraInstance = true; extraNum = 1; while (File.Exists(appdata + "/SweeZero/MintHTML/Caches/Instance" + extraNum.ToString() + "/lockfile")) { extraNum++; } var settings = new CefSettings() { RootCachePath = appdata + "/SweeZero/MintHTML/Caches/Instance" + extraNum.ToString(), WindowlessRenderingEnabled = true, }; Cef.Initialize(settings); } else { var settings = new CefSettings() { RootCachePath = appdata + "/SweeZero/MintHTML/Caches/Instance", WindowlessRenderingEnabled = true, }; Cef.Initialize(settings); } InitializeComponent(); css = @"" + htmlfile); } else { convert(); File.WriteAllText(Saver.FileName, htmlfile); } MessageBox.Show("Save complete.", "Converter", MessageBoxButtons.OK, MessageBoxIcon.Information); cssreload(); } } private void Form1_FormClosed(object sender, FormClosedEventArgs e) { Cef.Shutdown(); } private void openDevToolsToolStripMenuItem_Click_1(object sender, EventArgs e) { chromiumWebBrowser1.ShowDevTools(); } private void button4_Click(object sender, EventArgs e) { try { markfile = File.ReadAllText(textBox2.Text); convert(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } cssreload(); } private void textBox2_TextChanged(object sender, EventArgs e) { button3.Enabled = textBox2.Text.Length > 0; button4.Enabled = textBox2.Text.Length > 0; } private void serifToolStripMenuItem_Click(object sender, EventArgs e) { css = @""; lightToolStripMenuItem.Checked = false; systemToolStripMenuItem.Checked = false; darkToolStripMenuItem.Checked = true; darkui(); cssreload(); } } }