Skip to content

Commit

Permalink
Fix DataGridView's DarkMode text color for non-Windows version
Browse files Browse the repository at this point in the history
  • Loading branch information
topeterk committed Oct 29, 2022
1 parent 8eee8a0 commit 3433cd9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Sources/Main.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//MIT License

//Copyright (c) 2016-2020 Peter Kirmeier
//Copyright (c) 2016-2022 Peter Kirmeier

//Permission is hereby granted, free of charge, to any person obtaining a copy
//of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -124,7 +124,7 @@ public static bool DarkMode
public static void UpdateDarkMode(this Control ctrl)
{
// Workaround: Mono has several different "KnownColors", so there a two or more "Controls"
// Therefore, instead of checkin if the color matches a specific one, we have to check the name.
// Therefore, instead of checking if the color matches a specific one, we have to check the name.
try
{
if (DarkMode)
Expand All @@ -144,8 +144,8 @@ public static void UpdateDarkMode(this Control ctrl)
if (OsLayer.Name != "Win") // required for Mono
{
#pragma warning disable CS0162 // unreachable code.
if (dcs.ForeColor.Name == ControlText_Light.Name) dcs.ForeColor = ControlText_Dark;
if (dcs.SelectionForeColor.Name == ControlText_Light.Name) dcs.SelectionForeColor = ControlText_Dark;
if (dcs.ForeColor.Name != ControlText_Dark.Name) dcs.ForeColor = ControlText_Dark;
if (dcs.SelectionForeColor.Name != ControlText_Dark.Name) dcs.SelectionForeColor = ControlText_Dark;
#pragma warning restore CS0162 // unreachable code.
}
if (dgv.RowHeadersDefaultCellStyle.BackColor.Name == Control_Light.Name) dgv.RowHeadersDefaultCellStyle.BackColor = Control_Dark;
Expand Down Expand Up @@ -200,8 +200,8 @@ public static void UpdateDarkMode(this Control ctrl)
if (OsLayer.Name != "Win") // required for Mono
{
#pragma warning disable CS0162 // unreachable code
if (dcs.ForeColor.Name == ControlText_Dark.Name) dcs.ForeColor = ControlText_Light;
if (dcs.SelectionForeColor.Name == ControlText_Dark.Name) dcs.SelectionForeColor = ControlText_Light;
if (dcs.ForeColor.Name != ControlText_Light.Name) dcs.ForeColor = ControlText_Light;
if (dcs.SelectionForeColor.Name != ControlText_Light.Name) dcs.SelectionForeColor = ControlText_Light;
#pragma warning restore CS0162 // unreachable code.
}
if (dgv.RowHeadersDefaultCellStyle.BackColor.Name == Control_Dark.Name) dgv.RowHeadersDefaultCellStyle.BackColor = Control_Light;
Expand Down

0 comments on commit 3433cd9

Please sign in to comment.