From a271bf05d58253684074150a676352fa6ea2d667 Mon Sep 17 00:00:00 2001 From: Swee Date: Tue, 1 Oct 2024 16:37:03 -0700 Subject: [PATCH] Tweak CSS injector for darkmode --- Form1.Designer.cs | 22 ++++++++++++++++------ Form1.cs | 46 ++++++++++++++++++++++++++++------------------ 2 files changed, 44 insertions(+), 24 deletions(-) diff --git a/Form1.Designer.cs b/Form1.Designer.cs index 92b6182..c56656a 100644 --- a/Form1.Designer.cs +++ b/Form1.Designer.cs @@ -53,6 +53,7 @@ groupBox3 = new GroupBox(); button2 = new Button(); textBox2 = new TextBox(); + fullUIToolStripMenuItem = new ToolStripMenuItem(); menuStrip1.SuspendLayout(); groupBox4.SuspendLayout(); groupBox3.SuspendLayout(); @@ -78,30 +79,29 @@ // openDevToolsToolStripMenuItem // openDevToolsToolStripMenuItem.Name = "openDevToolsToolStripMenuItem"; - openDevToolsToolStripMenuItem.Size = new Size(180, 22); + openDevToolsToolStripMenuItem.Size = new Size(154, 22); openDevToolsToolStripMenuItem.Text = "Open DevTools"; openDevToolsToolStripMenuItem.Click += openDevToolsToolStripMenuItem_Click_1; // // exitToolStripMenuItem // exitToolStripMenuItem.Name = "exitToolStripMenuItem"; - exitToolStripMenuItem.Size = new Size(180, 22); + exitToolStripMenuItem.Size = new Size(154, 22); exitToolStripMenuItem.Text = "Exit"; exitToolStripMenuItem.Click += exitToolStripMenuItem_Click; // // renderToolStripMenuItem // - renderToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { fontFamilyToolStripMenuItem, colorThemeToolStripMenuItem }); + renderToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { fontFamilyToolStripMenuItem, colorThemeToolStripMenuItem, fullUIToolStripMenuItem }); renderToolStripMenuItem.Name = "renderToolStripMenuItem"; renderToolStripMenuItem.Size = new Size(56, 20); renderToolStripMenuItem.Text = "Render"; - renderToolStripMenuItem.Click += renderToolStripMenuItem_Click; // // fontFamilyToolStripMenuItem // fontFamilyToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { serifToolStripMenuItem, sansSerifToolStripMenuItem, forceMonospaceToolStripMenuItem }); fontFamilyToolStripMenuItem.Name = "fontFamilyToolStripMenuItem"; - fontFamilyToolStripMenuItem.Size = new Size(180, 22); + fontFamilyToolStripMenuItem.Size = new Size(140, 22); fontFamilyToolStripMenuItem.Text = "Font Family"; // // serifToolStripMenuItem @@ -131,7 +131,7 @@ // colorThemeToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { systemToolStripMenuItem, lightToolStripMenuItem, darkToolStripMenuItem }); colorThemeToolStripMenuItem.Name = "colorThemeToolStripMenuItem"; - colorThemeToolStripMenuItem.Size = new Size(180, 22); + colorThemeToolStripMenuItem.Size = new Size(140, 22); colorThemeToolStripMenuItem.Text = "Color theme"; // // systemToolStripMenuItem @@ -272,6 +272,15 @@ textBox2.TabIndex = 2; textBox2.TextChanged += textBox2_TextChanged; // + // fullUIToolStripMenuItem + // + fullUIToolStripMenuItem.Checked = true; + fullUIToolStripMenuItem.CheckOnClick = true; + fullUIToolStripMenuItem.CheckState = CheckState.Checked; + fullUIToolStripMenuItem.Name = "fullUIToolStripMenuItem"; + fullUIToolStripMenuItem.Size = new Size(140, 22); + fullUIToolStripMenuItem.Text = "Full UI"; + // // Form1 // AutoScaleDimensions = new SizeF(7F, 15F); @@ -322,5 +331,6 @@ private ToolStripMenuItem serifToolStripMenuItem; private ToolStripMenuItem sansSerifToolStripMenuItem; private ToolStripMenuItem forceMonospaceToolStripMenuItem; + private ToolStripMenuItem fullUIToolStripMenuItem; } } diff --git a/Form1.cs b/Form1.cs index 07d2773..81fc150 100644 --- a/Form1.cs +++ b/Form1.cs @@ -10,8 +10,6 @@ namespace MintHTML 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 = @" -"; string logo = @" "; + string css2 = "\n"; string css; bool extraInstance = false; int extraNum = 0; @@ -173,6 +172,10 @@ namespace MintHTML { htmlfile = Markdown.ToHtml(markfile); } + private void cssreload() + { + chromiumWebBrowser1.LoadHtml(css + css2 + htmlfile); + } // Custom functions end public Form1() @@ -205,9 +208,9 @@ namespace MintHTML css = @""; + lightToolStripMenuItem.Checked = false; + systemToolStripMenuItem.Checked = false; + darkToolStripMenuItem.Checked = true; + cssreload(); } } }