using CefSharp; using CefSharp.WinForms; namespace MintHTML { public partial class Form1 : Form { ChromiumWebBrowser chromiumWebBrowser1; 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 csssuffix = @" div{ font-family: monospace; background-color: #F3F3F3; border: solid; border-width: 1px } "; string css; // Custom functions private void convert() { htmlfile = ""; using (StringReader reader = new StringReader(markfile)) { string line; while ((line = reader.ReadLine()) != null) { // Header 1 if (line.Contains("# ")) { line = "

" + line[1..] + "

"; } // Header 2 else if (line.Contains("## ")) { line = "

" + line[1..] + "

"; } // Header 3 else if (line.Contains("### ")) { line = "

" + line[1..] + "

"; } // Header 4 else if (line.Contains("#### ")) { line = "

" + line[1..] + "

"; } // Header 5 else if (line.Contains("##### ")) { line = "
" + line[1..] + "
"; } // Header 6 else if (line.Contains("###### ")) { line = "
" + line[1..] + "
"; } // Code block else if (line.Contains("`")) { line = "
" + line[1..^1] + "
"; } // Everything else (Possibly paragraph or HTML code) else { line = line + "
"; } htmlfile += line; } } } // Custom functions end public Form1() { if (File.Exists(appdata + "/SweeZero/MintHTML/RootCache/lockfile")) { if (MessageBox.Show("There is another instance of MintHTML running. If there isn't, press Yes to try opening anyways.","Cef Warning",MessageBoxButtons.YesNo,MessageBoxIcon.Warning) == DialogResult.Yes) { try { File.Delete(appdata + "/SweeZero/MintHTML/RootCache/lockfile"); } catch (Exception ex) { MessageBox.Show(ex.Message, "Cef Error (fatal)", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } var settings = new CefSettings() { RootCachePath = appdata + "/SweeZero/MintHTML/RootCache", LogFile = appdata + "/SweeZero/MintHTML/CefSharp.log", LogSeverity = LogSeverity.Default }; Cef.Initialize(settings); chromiumWebBrowser1 = new ChromiumWebBrowser(); chromiumWebBrowser1.LoadingStateChanged += chromiumWebBrowser1_LoadingStateChanged; chromiumWebBrowser1.Dock = DockStyle.Fill; InitializeComponent(); groupBox4.Controls.Add(chromiumWebBrowser1); chromiumWebBrowser1.BringToFront(); css = @"