Skip to content

Commit 3433cd9

Browse files
committed
Fix DataGridView's DarkMode text color for non-Windows version
1 parent 8eee8a0 commit 3433cd9

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

Sources/Main.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//MIT License
22

3-
//Copyright (c) 2016-2020 Peter Kirmeier
3+
//Copyright (c) 2016-2022 Peter Kirmeier
44

55
//Permission is hereby granted, free of charge, to any person obtaining a copy
66
//of this software and associated documentation files (the "Software"), to deal
@@ -124,7 +124,7 @@ public static bool DarkMode
124124
public static void UpdateDarkMode(this Control ctrl)
125125
{
126126
// Workaround: Mono has several different "KnownColors", so there a two or more "Controls"
127-
// Therefore, instead of checkin if the color matches a specific one, we have to check the name.
127+
// Therefore, instead of checking if the color matches a specific one, we have to check the name.
128128
try
129129
{
130130
if (DarkMode)
@@ -144,8 +144,8 @@ public static void UpdateDarkMode(this Control ctrl)
144144
if (OsLayer.Name != "Win") // required for Mono
145145
{
146146
#pragma warning disable CS0162 // unreachable code.
147-
if (dcs.ForeColor.Name == ControlText_Light.Name) dcs.ForeColor = ControlText_Dark;
148-
if (dcs.SelectionForeColor.Name == ControlText_Light.Name) dcs.SelectionForeColor = ControlText_Dark;
147+
if (dcs.ForeColor.Name != ControlText_Dark.Name) dcs.ForeColor = ControlText_Dark;
148+
if (dcs.SelectionForeColor.Name != ControlText_Dark.Name) dcs.SelectionForeColor = ControlText_Dark;
149149
#pragma warning restore CS0162 // unreachable code.
150150
}
151151
if (dgv.RowHeadersDefaultCellStyle.BackColor.Name == Control_Light.Name) dgv.RowHeadersDefaultCellStyle.BackColor = Control_Dark;
@@ -200,8 +200,8 @@ public static void UpdateDarkMode(this Control ctrl)
200200
if (OsLayer.Name != "Win") // required for Mono
201201
{
202202
#pragma warning disable CS0162 // unreachable code
203-
if (dcs.ForeColor.Name == ControlText_Dark.Name) dcs.ForeColor = ControlText_Light;
204-
if (dcs.SelectionForeColor.Name == ControlText_Dark.Name) dcs.SelectionForeColor = ControlText_Light;
203+
if (dcs.ForeColor.Name != ControlText_Light.Name) dcs.ForeColor = ControlText_Light;
204+
if (dcs.SelectionForeColor.Name != ControlText_Light.Name) dcs.SelectionForeColor = ControlText_Light;
205205
#pragma warning restore CS0162 // unreachable code.
206206
}
207207
if (dgv.RowHeadersDefaultCellStyle.BackColor.Name == Control_Dark.Name) dgv.RowHeadersDefaultCellStyle.BackColor = Control_Light;

0 commit comments

Comments
 (0)