From ff92d1784d549441c5e88d4ea6994d5927120578 Mon Sep 17 00:00:00 2001 From: VaDiM Date: Sat, 7 Dec 2024 17:02:28 +0300 Subject: [PATCH] [GUI] Some fixes for Dark mode --- AssetStudioGUI/AssetStudioGUIForm.cs | 21 ++++++++++++++++++--- AssetStudioGUI/ExportOptions.Designer.cs | 6 +++++- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/AssetStudioGUI/AssetStudioGUIForm.cs b/AssetStudioGUI/AssetStudioGUIForm.cs index 6c181b8..2d4bb34 100644 --- a/AssetStudioGUI/AssetStudioGUIForm.cs +++ b/AssetStudioGUI/AssetStudioGUIForm.cs @@ -46,6 +46,7 @@ namespace AssetStudioGUI private uint FMODloopstartms; private uint FMODloopendms; private float FMODVolume = 0.8f; + private bool isDarkMode; #region SpriteControl private SpriteMaskMode spriteMaskVisibleMode = SpriteMaskMode.On; @@ -125,7 +126,7 @@ namespace AssetStudioGUI Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); ConsoleWindow.RunConsole(Properties.Settings.Default.showConsole); InitializeComponent(); - ApplyColorTheme(); + ApplyColorTheme(out isDarkMode); var appAssembly = typeof(Program).Assembly.GetName(); guiTitle = $"{appAssembly.Name} v{appAssembly.Version}"; @@ -1909,12 +1910,14 @@ namespace AssetStudioGUI x.Text.IndexOf(listSearch.Text, StringComparison.OrdinalIgnoreCase) >= 0 || x.SubItems[1].Text.IndexOf(listSearch.Text, StringComparison.OrdinalIgnoreCase) >= 0 || x.SubItems[3].Text.IndexOf(listSearch.Text, StringComparison.OrdinalIgnoreCase) >= 0); + listSearch.ForeColor = SystemColors.WindowText; break; case ListSearchFilterMode.Exclude: visibleAssets = visibleAssets.FindAll(x => x.Text.IndexOf(listSearch.Text, StringComparison.OrdinalIgnoreCase) <= 0 && x.SubItems[1].Text.IndexOf(listSearch.Text, StringComparison.OrdinalIgnoreCase) <= 0 && x.SubItems[3].Text.IndexOf(listSearch.Text, StringComparison.OrdinalIgnoreCase) <= 0); + listSearch.ForeColor = SystemColors.WindowText; break; case ListSearchFilterMode.RegexName: case ListSearchFilterMode.RegexContainer: @@ -1932,15 +1935,18 @@ namespace AssetStudioGUI visibleAssets = visibleAssets.FindAll(x => Regex.IsMatch(x.SubItems[1].Text, pattern, regexOptions)); } listSearch.BackColor = SystemInformation.HighContrast ? listSearch.BackColor : System.Drawing.Color.PaleGreen; + listSearch.ForeColor = isDarkMode ? System.Drawing.Color.Black : listSearch.ForeColor; } catch (ArgumentException e) { listSearch.BackColor = SystemInformation.HighContrast ? listSearch.BackColor : System.Drawing.Color.FromArgb(255, 160, 160); + listSearch.ForeColor = isDarkMode ? System.Drawing.Color.Black : listSearch.ForeColor; StatusStripUpdate($"Regex error: {e.Message}"); } catch (RegexMatchTimeoutException) { listSearch.BackColor = SystemInformation.HighContrast ? listSearch.BackColor : System.Drawing.Color.FromArgb(255, 160, 160); + listSearch.ForeColor = isDarkMode ? System.Drawing.Color.Black : listSearch.ForeColor; StatusStripUpdate($"Timeout error"); } break; @@ -2365,8 +2371,12 @@ namespace AssetStudioGUI Properties.Settings.Default.Save(); } - private void ApplyColorTheme() + private void ApplyColorTheme(out bool isDarkMode) { + isDarkMode = false; + if (SystemInformation.HighContrast) + return; + #if NET9_0_OR_GREATER #pragma warning disable WFO5001 //for evaluation purposes only var currentTheme = Properties.Settings.Default.guiColorTheme; @@ -2378,6 +2388,7 @@ namespace AssetStudioGUI case GuiColorTheme.System: Application.SetColorMode(SystemColorMode.System); colorThemeAutoToolStripMenuItem.Checked = true; + isDarkMode = Application.IsDarkModeEnabled; break; case GuiColorTheme.Light: colorThemeLightToolStripMenuItem.Checked = true; @@ -2385,7 +2396,7 @@ namespace AssetStudioGUI case GuiColorTheme.Dark: Application.SetColorMode(SystemColorMode.Dark); colorThemeDarkToolStripMenuItem.Checked = true; - assetListView.GridLines = false; + isDarkMode = true; break; } } @@ -2393,6 +2404,10 @@ namespace AssetStudioGUI { //skip } + if (isDarkMode) + { + assetListView.GridLines = false; + } #pragma warning restore WFO5001 #endif } diff --git a/AssetStudioGUI/ExportOptions.Designer.cs b/AssetStudioGUI/ExportOptions.Designer.cs index 06686f8..b08bcfd 100644 --- a/AssetStudioGUI/ExportOptions.Designer.cs +++ b/AssetStudioGUI/ExportOptions.Designer.cs @@ -115,6 +115,7 @@ // groupBox1 // this.groupBox1.AutoSize = true; + this.groupBox1.BackColor = System.Drawing.SystemColors.Menu; this.groupBox1.Controls.Add(this.parallelExportMaxLabel); this.groupBox1.Controls.Add(this.parallelExportCheckBox); this.groupBox1.Controls.Add(this.parallelExportUpDown); @@ -138,7 +139,7 @@ // parallelExportMaxLabel // this.parallelExportMaxLabel.AutoSize = true; - this.parallelExportMaxLabel.ForeColor = System.Drawing.SystemColors.ControlDark; + this.parallelExportMaxLabel.ForeColor = System.Drawing.SystemColors.ControlDarkDark; this.parallelExportMaxLabel.Location = new System.Drawing.Point(260, 221); this.parallelExportMaxLabel.Name = "parallelExportMaxLabel"; this.parallelExportMaxLabel.Size = new System.Drawing.Size(33, 13); @@ -356,6 +357,7 @@ // // l2dGroupBox // + this.l2dGroupBox.BackColor = System.Drawing.SystemColors.Menu; this.l2dGroupBox.Controls.Add(this.l2dAssetSearchByFilenameCheckBox); this.l2dGroupBox.Controls.Add(this.l2dModelGroupComboBox); this.l2dGroupBox.Controls.Add(this.l2dModelGroupLabel); @@ -458,6 +460,7 @@ // groupBox2 // this.groupBox2.AutoSize = true; + this.groupBox2.BackColor = System.Drawing.SystemColors.Menu; this.groupBox2.Controls.Add(this.exportAllUvsAsDiffuseMaps); this.groupBox2.Controls.Add(this.exportBlendShape); this.groupBox2.Controls.Add(this.exportAnimations); @@ -692,6 +695,7 @@ this.AcceptButton = this.OKbutton; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.SystemColors.Menu; this.CancelButton = this.Cancel; this.ClientSize = new System.Drawing.Size(564, 461); this.Controls.Add(this.l2dGroupBox);