From ff66b044360504e0b4a68222e6704d080e567dcc Mon Sep 17 00:00:00 2001 From: Swee Date: Tue, 1 Oct 2024 22:45:12 -0700 Subject: [PATCH] Make the UI change to darkmode, update NuGet packages --- Form1.Designer.cs | 88 +++++++++++++++-------------------------------- Form1.cs | 56 +++++++++++++++++++++++++++--- MintHTML.csproj | 19 +++++++--- 3 files changed, 93 insertions(+), 70 deletions(-) diff --git a/Form1.Designer.cs b/Form1.Designer.cs index c56656a..a5d10dd 100644 --- a/Form1.Designer.cs +++ b/Form1.Designer.cs @@ -42,21 +42,17 @@ systemToolStripMenuItem = new ToolStripMenuItem(); lightToolStripMenuItem = new ToolStripMenuItem(); darkToolStripMenuItem = new ToolStripMenuItem(); + fullUIToolStripMenuItem = new ToolStripMenuItem(); helpToolStripMenuItem = new ToolStripMenuItem(); aboutToolStripMenuItem = new ToolStripMenuItem(); Opener = new OpenFileDialog(); Saver = new SaveFileDialog(); - groupBox4 = new GroupBox(); chromiumWebBrowser1 = new CefSharp.WinForms.ChromiumWebBrowser(); button4 = new Button(); button3 = new Button(); - groupBox3 = new GroupBox(); button2 = new Button(); textBox2 = new TextBox(); - fullUIToolStripMenuItem = new ToolStripMenuItem(); menuStrip1.SuspendLayout(); - groupBox4.SuspendLayout(); - groupBox3.SuspendLayout(); SuspendLayout(); // // menuStrip1 @@ -141,23 +137,32 @@ systemToolStripMenuItem.CheckState = CheckState.Checked; systemToolStripMenuItem.ForeColor = SystemColors.ControlText; systemToolStripMenuItem.Name = "systemToolStripMenuItem"; - systemToolStripMenuItem.Size = new Size(180, 22); + systemToolStripMenuItem.Size = new Size(161, 22); systemToolStripMenuItem.Text = "System (Default)"; systemToolStripMenuItem.Click += systemToolStripMenuItem_Click; // // lightToolStripMenuItem // lightToolStripMenuItem.Name = "lightToolStripMenuItem"; - lightToolStripMenuItem.Size = new Size(180, 22); + lightToolStripMenuItem.Size = new Size(161, 22); lightToolStripMenuItem.Text = "Light"; // // darkToolStripMenuItem // darkToolStripMenuItem.Name = "darkToolStripMenuItem"; - darkToolStripMenuItem.Size = new Size(180, 22); + darkToolStripMenuItem.Size = new Size(161, 22); darkToolStripMenuItem.Text = "Dark"; darkToolStripMenuItem.Click += darkToolStripMenuItem_Click; // + // fullUIToolStripMenuItem + // + fullUIToolStripMenuItem.Checked = true; + fullUIToolStripMenuItem.CheckOnClick = true; + fullUIToolStripMenuItem.CheckState = CheckState.Checked; + fullUIToolStripMenuItem.Name = "fullUIToolStripMenuItem"; + fullUIToolStripMenuItem.Size = new Size(140, 22); + fullUIToolStripMenuItem.Text = "Full UI"; + // // helpToolStripMenuItem // helpToolStripMenuItem.Alignment = ToolStripItemAlignment.Right; @@ -185,28 +190,13 @@ Saver.DefaultExt = "html"; Saver.Filter = "HTML websites|*.html|All files|*.*"; // - // groupBox4 - // - groupBox4.Controls.Add(chromiumWebBrowser1); - groupBox4.Controls.Add(button4); - groupBox4.Dock = DockStyle.Fill; - groupBox4.FlatStyle = FlatStyle.System; - groupBox4.Location = new Point(0, 91); - groupBox4.Name = "groupBox4"; - groupBox4.Size = new Size(800, 378); - groupBox4.TabIndex = 3; - groupBox4.TabStop = false; - groupBox4.Text = "Preview"; - groupBox4.UseCompatibleTextRendering = true; - groupBox4.Enter += groupBox4_Enter; - // // chromiumWebBrowser1 // chromiumWebBrowser1.ActivateBrowserOnCreation = false; chromiumWebBrowser1.Dock = DockStyle.Fill; - chromiumWebBrowser1.Location = new Point(3, 42); + chromiumWebBrowser1.Location = new Point(0, 86); chromiumWebBrowser1.Name = "chromiumWebBrowser1"; - chromiumWebBrowser1.Size = new Size(794, 333); + chromiumWebBrowser1.Size = new Size(800, 383); chromiumWebBrowser1.TabIndex = 3; chromiumWebBrowser1.AddressChanged += chromiumWebBrowser1_AddressChanged; // @@ -215,9 +205,10 @@ button4.Dock = DockStyle.Top; button4.Enabled = false; button4.FlatStyle = FlatStyle.System; - button4.Location = new Point(3, 19); + button4.ForeColor = SystemColors.ControlText; + button4.Location = new Point(0, 63); button4.Name = "button4"; - button4.Size = new Size(794, 23); + button4.Size = new Size(800, 23); button4.TabIndex = 1; button4.Text = "Render preview"; button4.UseVisualStyleBackColor = true; @@ -236,26 +227,13 @@ button3.UseVisualStyleBackColor = false; button3.Click += button3_Click; // - // groupBox3 - // - groupBox3.Controls.Add(button2); - groupBox3.Controls.Add(textBox2); - groupBox3.Dock = DockStyle.Top; - groupBox3.FlatStyle = FlatStyle.System; - groupBox3.Location = new Point(0, 24); - groupBox3.Name = "groupBox3"; - groupBox3.Size = new Size(800, 67); - groupBox3.TabIndex = 2; - groupBox3.TabStop = false; - groupBox3.Text = "Input file"; - // // button2 // - button2.Dock = DockStyle.Fill; + button2.Dock = DockStyle.Top; button2.FlatStyle = FlatStyle.System; - button2.Location = new Point(3, 35); + button2.Location = new Point(0, 40); button2.Name = "button2"; - button2.Size = new Size(794, 29); + button2.Size = new Size(800, 23); button2.TabIndex = 3; button2.Text = "Select file"; button2.UseVisualStyleBackColor = true; @@ -265,29 +243,22 @@ // textBox2.BorderStyle = BorderStyle.None; textBox2.Dock = DockStyle.Top; - textBox2.Location = new Point(3, 19); + textBox2.Location = new Point(0, 24); textBox2.Name = "textBox2"; textBox2.PlaceholderText = "Type path or select file below. "; - textBox2.Size = new Size(794, 16); + textBox2.Size = new Size(800, 16); 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); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(800, 492); - Controls.Add(groupBox4); - Controls.Add(groupBox3); + Controls.Add(chromiumWebBrowser1); + Controls.Add(button4); + Controls.Add(button2); + Controls.Add(textBox2); Controls.Add(button3); Controls.Add(menuStrip1); Icon = (Icon)resources.GetObject("$this.Icon"); @@ -299,9 +270,6 @@ Load += Form1_Load; menuStrip1.ResumeLayout(false); menuStrip1.PerformLayout(); - groupBox4.ResumeLayout(false); - groupBox3.ResumeLayout(false); - groupBox3.PerformLayout(); ResumeLayout(false); PerformLayout(); } @@ -313,13 +281,11 @@ private ToolStripMenuItem aboutToolStripMenuItem; private OpenFileDialog Opener; private SaveFileDialog Saver; - private GroupBox groupBox4; private Button button3; private Button button4; private ToolStripMenuItem renderToolStripMenuItem; private ToolStripMenuItem openDevToolsToolStripMenuItem; private ToolStripMenuItem exitToolStripMenuItem; - private GroupBox groupBox3; private Button button2; private TextBox textBox2; private CefSharp.WinForms.ChromiumWebBrowser chromiumWebBrowser1; diff --git a/Form1.cs b/Form1.cs index 81fc150..c6ef467 100644 --- a/Form1.cs +++ b/Form1.cs @@ -2,6 +2,7 @@ using CefSharp; using CefSharp.WinForms; using Markdig; using System.Diagnostics; +using System.Drawing.Drawing2D; namespace MintHTML { @@ -9,7 +10,7 @@ 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 htmlfile = "

Welcome to MintHTML

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

"; string logo = @"" + 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 @@ -201,6 +245,7 @@ namespace MintHTML { RootCachePath = appdata + "/SweeZero/MintHTML/Caches/Instance", WindowlessRenderingEnabled = true, + }; Cef.Initialize(settings); } @@ -229,7 +274,7 @@ font-family: sans-serif cssreload(); } } - + private void Form1_Load(object sender, EventArgs e) { } @@ -243,7 +288,7 @@ font-family: sans-serif if (MessageBox.Show("Do you want to convert the rendering settings to CSS?", "Converter", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { convert(); - File.WriteAllText(Saver.FileName, "