mirror of
https://github.com/FroggMaster/CreamInstaller.git
synced 2026-06-12 11:01:23 -07:00
Change Dark Mode Toggle to Checkbox
- Changed dark mode toggle to Checkbox instead of button > better aligns with other settings in the top panel. (Gee, sure is getting crowded up there)
This commit is contained in:
+33
-16
@@ -31,6 +31,8 @@ namespace CreamInstaller.Forms
|
||||
useSmokeAPILayoutPanel = new FlowLayoutPanel();
|
||||
useSmokeAPICheckBox = new CheckBox();
|
||||
useSmokeAPIHelpButton = new Button();
|
||||
darkModeFlowPanel = new FlowLayoutPanel();
|
||||
darkModeCheckBox = new CheckBox();
|
||||
allCheckBoxLayoutPanel = new FlowLayoutPanel();
|
||||
allCheckBox = new CheckBox();
|
||||
progressBar = new ProgressBar();
|
||||
@@ -46,11 +48,11 @@ namespace CreamInstaller.Forms
|
||||
saveFlowPanel = new FlowLayoutPanel();
|
||||
selectionTreeView = new CustomTreeView();
|
||||
topOptionsTable = new TableLayoutPanel();
|
||||
darkModeButton = new Button();
|
||||
programsGroupBox.SuspendLayout();
|
||||
proxyFlowPanel.SuspendLayout();
|
||||
blockedGamesFlowPanel.SuspendLayout();
|
||||
useSmokeAPILayoutPanel.SuspendLayout();
|
||||
darkModeFlowPanel.SuspendLayout();
|
||||
allCheckBoxLayoutPanel.SuspendLayout();
|
||||
saveFlowPanel.SuspendLayout();
|
||||
SuspendLayout();
|
||||
@@ -210,6 +212,30 @@ namespace CreamInstaller.Forms
|
||||
useSmokeAPIHelpButton.UseVisualStyleBackColor = true;
|
||||
useSmokeAPIHelpButton.Click += OnUseSmokeAPIHelpButtonClicked;
|
||||
//
|
||||
// darkModeFlowPanel
|
||||
//
|
||||
darkModeFlowPanel.AutoSize = true;
|
||||
darkModeFlowPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink;
|
||||
darkModeFlowPanel.Margin = new Padding(12, 0, 0, 0);
|
||||
darkModeFlowPanel.Name = "darkModeFlowPanel";
|
||||
darkModeFlowPanel.Size = new System.Drawing.Size(98, 19);
|
||||
darkModeFlowPanel.TabIndex = 10011;
|
||||
darkModeFlowPanel.WrapContents = false;
|
||||
//
|
||||
// darkModeCheckBox
|
||||
//
|
||||
darkModeCheckBox.AutoSize = true;
|
||||
darkModeCheckBox.Enabled = true;
|
||||
darkModeCheckBox.Location = new System.Drawing.Point(2, 0);
|
||||
darkModeCheckBox.Margin = new Padding(2, 0, 0, 0);
|
||||
darkModeCheckBox.Name = "darkModeCheckBox";
|
||||
darkModeCheckBox.Size = new System.Drawing.Size(96, 19);
|
||||
darkModeCheckBox.TabIndex = 1;
|
||||
darkModeCheckBox.Text = "Enable Dark Mode";
|
||||
darkModeCheckBox.UseVisualStyleBackColor = true;
|
||||
darkModeCheckBox.CheckedChanged += OnDarkModeCheckBoxChanged;
|
||||
darkModeFlowPanel.Controls.Add(darkModeCheckBox);
|
||||
//
|
||||
// allCheckBoxLayoutPanel
|
||||
//
|
||||
allCheckBoxLayoutPanel.AutoSize = true;
|
||||
@@ -249,19 +275,6 @@ namespace CreamInstaller.Forms
|
||||
selectionTreeView.Size = new System.Drawing.Size(604, 230);
|
||||
selectionTreeView.TabIndex = 1001;
|
||||
//
|
||||
// darkModeButton
|
||||
//
|
||||
darkModeButton.AutoSize = true;
|
||||
darkModeButton.AutoSizeMode = AutoSizeMode.GrowAndShrink;
|
||||
darkModeButton.Location = new System.Drawing.Point(0, 0);
|
||||
darkModeButton.Margin = new Padding(12, 0, 0, 0);
|
||||
darkModeButton.Name = "darkModeButton";
|
||||
darkModeButton.Size = new System.Drawing.Size(73, 25);
|
||||
darkModeButton.TabIndex = 10010;
|
||||
darkModeButton.Text = "Dark Mode";
|
||||
darkModeButton.UseVisualStyleBackColor = true;
|
||||
darkModeButton.Click += OnDarkModeToggle;
|
||||
//
|
||||
// progressBar
|
||||
//
|
||||
progressBar.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
@@ -419,9 +432,10 @@ namespace CreamInstaller.Forms
|
||||
topOptionsTable.RowStyles.Add(new RowStyle(SizeType.AutoSize));
|
||||
topOptionsTable.Size = new System.Drawing.Size(610, 25);
|
||||
topOptionsTable.TabIndex = 10009;
|
||||
topOptionsTable.Controls.Clear();
|
||||
topOptionsTable.Controls.Add(blockedGamesFlowPanel, 0, 0);
|
||||
topOptionsTable.Controls.Add(useSmokeAPILayoutPanel, 1, 0);
|
||||
topOptionsTable.Controls.Add(darkModeButton, 2, 0);
|
||||
topOptionsTable.Controls.Add(darkModeFlowPanel, 2, 0);
|
||||
topOptionsTable.Controls.Add(proxyFlowPanel, 4, 0);
|
||||
topOptionsTable.Controls.Add(allCheckBoxLayoutPanel, 5, 0);
|
||||
//
|
||||
@@ -458,6 +472,8 @@ namespace CreamInstaller.Forms
|
||||
blockedGamesFlowPanel.PerformLayout();
|
||||
useSmokeAPILayoutPanel.ResumeLayout(false);
|
||||
useSmokeAPILayoutPanel.PerformLayout();
|
||||
darkModeFlowPanel.ResumeLayout(false);
|
||||
darkModeFlowPanel.PerformLayout();
|
||||
allCheckBoxLayoutPanel.ResumeLayout(false);
|
||||
allCheckBoxLayoutPanel.PerformLayout();
|
||||
saveFlowPanel.ResumeLayout(false);
|
||||
@@ -483,6 +499,7 @@ namespace CreamInstaller.Forms
|
||||
private Button useSmokeAPIHelpButton;
|
||||
private FlowLayoutPanel blockedGamesFlowPanel;
|
||||
private FlowLayoutPanel useSmokeAPILayoutPanel;
|
||||
private FlowLayoutPanel darkModeFlowPanel;
|
||||
private FlowLayoutPanel allCheckBoxLayoutPanel;
|
||||
private Button uninstallButton;
|
||||
private Label progressLabelGames;
|
||||
@@ -495,7 +512,7 @@ namespace CreamInstaller.Forms
|
||||
private Button resetButton;
|
||||
private FlowLayoutPanel saveFlowPanel;
|
||||
private TableLayoutPanel topOptionsTable;
|
||||
private Button darkModeButton;
|
||||
private CheckBox darkModeCheckBox;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1240,15 +1240,23 @@ internal sealed partial class SelectForm : CustomForm
|
||||
|
||||
}
|
||||
|
||||
private void OnDarkModeToggle(object sender, EventArgs e)
|
||||
private void OnDarkModeCheckBoxChanged(object sender, EventArgs e)
|
||||
{
|
||||
ThemeManager.ToggleDarkMode(this);
|
||||
darkModeButton.Text = Program.DarkModeEnabled ? "Light Mode" : "Dark Mode";
|
||||
bool requestedDark = darkModeCheckBox.Checked;
|
||||
if (Program.DarkModeEnabled != requestedDark)
|
||||
{
|
||||
Program.DarkModeEnabled = requestedDark;
|
||||
ThemeManager.Apply(this);
|
||||
}
|
||||
else
|
||||
ThemeManager.Apply(this);
|
||||
}
|
||||
|
||||
protected override void OnShown(EventArgs e)
|
||||
{
|
||||
base.OnShown(e);
|
||||
ThemeManager.Apply(this); // ensure controls after dynamic operations get themed
|
||||
ThemeManager.Apply(this);
|
||||
if (darkModeCheckBox is not null)
|
||||
darkModeCheckBox.Checked = Program.DarkModeEnabled;
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ internal static class ThemeManager
|
||||
private static readonly Color DarkFore = ColorTranslator.FromHtml("#D4D4D4");
|
||||
private static readonly Color DarkForeDim = ColorTranslator.FromHtml("#9CA3AF");
|
||||
private static readonly Color Accent = ColorTranslator.FromHtml("#0E639C");
|
||||
private static readonly Color DarkLink = ColorTranslator.FromHtml("#64B5F6"); // Pastel light blue for hyperlinks (improved readability)
|
||||
private static readonly Color DarkLink = ColorTranslator.FromHtml("#64B5F6");
|
||||
private static readonly Color LightBack = SystemColors.Control;
|
||||
private static readonly Color LightBackAlt = SystemColors.ControlLightLight;
|
||||
private static readonly Color LightFore = SystemColors.ControlText;
|
||||
@@ -49,7 +49,6 @@ internal static class ThemeManager
|
||||
private static void ApplyControlTheme(Control control, bool dark)
|
||||
{
|
||||
if (control is null) return;
|
||||
// recurse first to avoid overwriting multi-level backgrounds incorrectly
|
||||
foreach (Control child in control.Controls)
|
||||
ApplyControlTheme(child, dark);
|
||||
if (dark)
|
||||
@@ -198,7 +197,7 @@ internal static class ThemeManager
|
||||
|
||||
internal static class NativeMethods
|
||||
{
|
||||
private const int DWMWA_USE_IMMERSIVE_DARK_MODE =20; // Windows102004+ /11
|
||||
private const int DWMWA_USE_IMMERSIVE_DARK_MODE =20;
|
||||
|
||||
[System.Runtime.InteropServices.DllImport("dwmapi.dll")]
|
||||
private static extern int DwmSetWindowAttribute(System.IntPtr hwnd, int attr, ref int attrValue, int attrSize);
|
||||
|
||||
Reference in New Issue
Block a user