Make the UI change to darkmode, update NuGet packages

This commit is contained in:
Swee 2024-10-01 22:45:12 -07:00
parent b790b588d4
commit ff66b04436
3 changed files with 93 additions and 70 deletions

88
Form1.Designer.cs generated
View file

@ -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;

View file

@ -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 = "<h1>Welcome to MintHTML</h1><p>Open a markdown file and press \"Render preview\" to see the output here.</p>";
string htmlfile = "<body oncontextmenu=\"return false;\"><h1>Welcome to MintHTML</h1><p>Open a markdown file and press \"Render preview\" to see the output here.</p>";
string logo = @"<svg
width=""25mm""
height=""25mm""
@ -174,7 +175,50 @@ namespace MintHTML
}
private void cssreload()
{
chromiumWebBrowser1.LoadHtml(css + css2 + htmlfile);
chromiumWebBrowser1.LoadHtml(css + css2 + "<body oncontextmenu=\"return false;\">" + 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, "<style>\n" + css + css2 + htmlfile);
File.WriteAllText(Saver.FileName, "<style>\n" + css + "</style>" + htmlfile);
}
else
{
@ -276,7 +321,7 @@ font-family: sans-serif
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
chromiumWebBrowser1.LoadHtml(css + htmlfile);
cssreload();
}
private void textBox2_TextChanged(object sender, EventArgs e)
@ -362,6 +407,7 @@ color-scheme: dark;
lightToolStripMenuItem.Checked = false;
systemToolStripMenuItem.Checked = false;
darkToolStripMenuItem.Checked = true;
darkui();
cssreload();
}
}

View file

@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows10.0.22000.0</TargetFramework>
<TargetFramework>net8.0-windows10.0.22000.0</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>True</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
@ -18,16 +18,27 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="CefSharp.WinForms.NETCore" Version="127.3.50" />
<PackageReference Include="CefSharp.WinForms.NETCore" Version="128.4.90" />
<PackageReference Include="Markdig" Version="0.37.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="chromiumembeddedframework.runtime.win-arm64" Version="127.3.5" />
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<PackageReference Update="chromiumembeddedframework.runtime.win-x64" Version="127.3.5" />
<PackageReference Update="chromiumembeddedframework.runtime.win-arm64" Version="128.4.9" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="chromiumembeddedframework.runtime.win-x64" Version="128.4.9" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="chromiumembeddedframework.runtime.win-x86" Version="128.4.9" />
</ItemGroup>
</Project>