[GUI] Some fixes for Dark mode

This commit is contained in:
VaDiM 2024-12-07 17:02:28 +03:00
parent 064f5cbe57
commit ff92d1784d
2 changed files with 23 additions and 4 deletions

View File

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

View File

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