Skip to content

Commit 35e3ebf

Browse files
Revert "Add Dark Mode theme to rows/columns and ColumnHeader/RowHeader in the DataGridView"
This reverts commit 8cd6f2b.
1 parent 8cd6f2b commit 35e3ebf

8 files changed

+11
-64
lines changed

src/System.Windows.Forms/System/Windows/Forms/Controls/DataGridView/DataGridViewButtonCell.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@ public partial class DataGridViewButtonCell : DataGridViewCell
1717
private static readonly int s_propButtonCellFlatStyle = PropertyStore.CreateKey();
1818
private static readonly int s_propButtonCellState = PropertyStore.CreateKey();
1919
private static readonly int s_propButtonCellUseColumnTextForButtonValue = PropertyStore.CreateKey();
20-
#pragma warning disable WFO5001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
21-
private static readonly VisualStyleElement s_darkButtonElement = VisualStyleElement.CreateElement("DarkMode_Explorer::BUTTON", 1, 1);
22-
private static readonly VisualStyleElement s_lightButtonElement = VisualStyleElement.Button.PushButton.Normal;
23-
private static readonly VisualStyleElement s_buttonElement = Application.IsDarkModeEnabled ? s_darkButtonElement : s_lightButtonElement;
24-
#pragma warning restore WFO5001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
20+
private static readonly VisualStyleElement s_buttonElement = VisualStyleElement.Button.PushButton.Normal;
2521

2622
private const byte DATAGRIDVIEWBUTTONCELL_themeMargin = 100; // Used to calculate the margins required for theming rendering
2723
private const byte DATAGRIDVIEWBUTTONCELL_horizontalTextMargin = 2;

src/System.Windows.Forms/System/Windows/Forms/Controls/DataGridView/DataGridViewCheckBoxCell.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,7 @@ public partial class DataGridViewCheckBoxCell : DataGridViewCell, IDataGridViewE
2020
private const DataGridViewContentAlignment AnyBottom = DataGridViewContentAlignment.BottomRight | DataGridViewContentAlignment.BottomCenter | DataGridViewContentAlignment.BottomLeft;
2121
private const DataGridViewContentAlignment AnyMiddle = DataGridViewContentAlignment.MiddleRight | DataGridViewContentAlignment.MiddleCenter | DataGridViewContentAlignment.MiddleLeft;
2222

23-
#pragma warning disable WFO5001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
24-
private static readonly VisualStyleElement s_darkCheckBoxElement = VisualStyleElement.CreateElement("DarkMode_Explorer::BUTTON", 3, 1);
25-
private static readonly VisualStyleElement s_lightCheckBoxElement = VisualStyleElement.Button.CheckBox.UncheckedNormal;
26-
private static readonly VisualStyleElement s_checkBoxElement = Application.IsDarkModeEnabled ? s_darkCheckBoxElement : s_lightCheckBoxElement;
27-
#pragma warning restore WFO5001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
28-
23+
private static readonly VisualStyleElement s_checkBoxElement = VisualStyleElement.Button.CheckBox.UncheckedNormal;
2924
private static readonly int s_propButtonCellState = PropertyStore.CreateKey();
3025
private static readonly int s_propTrueValue = PropertyStore.CreateKey();
3126
private static readonly int s_propFalseValue = PropertyStore.CreateKey();

src/System.Windows.Forms/System/Windows/Forms/Controls/DataGridView/DataGridViewColumnHeaderCell.DataGridViewColumnHeaderCellRenderer.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@ public static VisualStyleRenderer VisualStyleRenderer
1616
{
1717
get
1818
{
19-
#pragma warning disable WFO5001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
20-
s_visualStyleRenderer ??= new VisualStyleRenderer(Application.IsDarkModeEnabled ?
21-
VisualStyleElement.CreateElement("DarkMode_ItemsView::Header", 1, 1)
22-
: VisualStyleElement.Header.Item.Normal);
23-
#pragma warning restore WFO5001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
19+
s_visualStyleRenderer ??= new VisualStyleRenderer(s_headerElement);
2420

2521
return s_visualStyleRenderer;
2622
}

src/System.Windows.Forms/System/Windows/Forms/Controls/DataGridView/DataGridViewColumnHeaderCell.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ namespace System.Windows.Forms;
1111

1212
public partial class DataGridViewColumnHeaderCell : DataGridViewHeaderCell
1313
{
14-
#pragma warning disable WFO5001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
15-
private static readonly VisualStyleElement s_headerElement = Application.IsDarkModeEnabled ?
16-
VisualStyleElement.CreateElement("DarkMode_ItemsView::Header", 1, 1)
17-
: VisualStyleElement.Header.Item.Normal;
18-
#pragma warning restore WFO5001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
14+
private static readonly VisualStyleElement s_headerElement = VisualStyleElement.Header.Item.Normal;
1915

2016
private const byte SortGlyphSeparatorWidth = 2; // additional 2 pixels between caption and glyph
2117
private const byte SortGlyphHorizontalMargin = 4; // 4 pixels on left & right of glyph

src/System.Windows.Forms/System/Windows/Forms/Controls/DataGridView/DataGridViewComboBoxCell.DataGridViewComboBoxCellRenderer.cs

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,10 @@ private static class DataGridViewComboBoxCellRenderer
1212
{
1313
[ThreadStatic]
1414
private static VisualStyleRenderer? t_visualStyleRenderer;
15-
#pragma warning disable WFO5001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
16-
private static readonly VisualStyleElement s_comboBoxBorder = Application.IsDarkModeEnabled ?
17-
VisualStyleElement.CreateElement("DarkMode_CFD::COMBOBOX", 4, 1)
18-
: VisualStyleElement.ComboBox.Border.Normal;
19-
#pragma warning restore WFO5001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
20-
21-
#pragma warning disable WFO5001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
22-
private static readonly VisualStyleElement s_comboBoxDropDownButtonRight = Application.IsDarkModeEnabled ?
23-
VisualStyleElement.CreateElement("DarkMode_CFD::COMBOBOX", 6, 1)
24-
: VisualStyleElement.ComboBox.DropDownButtonRight.Normal;
25-
#pragma warning restore WFO5001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
26-
27-
#pragma warning disable WFO5001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
28-
private static readonly VisualStyleElement s_comboBoxDropDownButtonLeft = Application.IsDarkModeEnabled ?
29-
VisualStyleElement.CreateElement("DarkMode_CFD::COMBOBOX", 7, 1) :
30-
VisualStyleElement.ComboBox.DropDownButtonLeft.Normal;
31-
#pragma warning restore WFO5001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
32-
33-
#pragma warning disable WFO5001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
34-
private static readonly VisualStyleElement s_comboBoxReadOnlyButton = Application.IsDarkModeEnabled ?
35-
VisualStyleElement.CreateElement("DarkMode_CFD::COMBOBOX", 5, 1)
36-
: VisualStyleElement.ComboBox.ReadOnlyButton.Normal;
37-
#pragma warning restore WFO5001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
15+
private static readonly VisualStyleElement s_comboBoxBorder = VisualStyleElement.ComboBox.Border.Normal;
16+
private static readonly VisualStyleElement s_comboBoxDropDownButtonRight = VisualStyleElement.ComboBox.DropDownButtonRight.Normal;
17+
private static readonly VisualStyleElement s_comboBoxDropDownButtonLeft = VisualStyleElement.ComboBox.DropDownButtonLeft.Normal;
18+
private static readonly VisualStyleElement s_comboBoxReadOnlyButton = VisualStyleElement.ComboBox.ReadOnlyButton.Normal;
3819

3920
public static VisualStyleRenderer VisualStyleRenderer
4021
{

src/System.Windows.Forms/System/Windows/Forms/Controls/DataGridView/DataGridViewRowHeaderCell.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ namespace System.Windows.Forms;
1111

1212
public partial class DataGridViewRowHeaderCell : DataGridViewHeaderCell
1313
{
14-
#pragma warning disable WFO5001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
15-
private static readonly VisualStyleElement s_headerElement = Application.IsDarkModeEnabled ?
16-
VisualStyleElement.CreateElement("DarkMode_ItemsView::Header", 1, 1)
17-
: VisualStyleElement.Header.Item.Normal;
18-
#pragma warning restore WFO5001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
14+
private static readonly VisualStyleElement s_headerElement = VisualStyleElement.Header.Item.Normal;
1915

2016
private static Bitmap? s_rightArrowBmp;
2117
private static Bitmap? s_leftArrowBmp;

src/System.Windows.Forms/System/Windows/Forms/Controls/DataGridView/DataGridViewTopLeftHeaderCell.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@ namespace System.Windows.Forms;
88

99
public partial class DataGridViewTopLeftHeaderCell : DataGridViewColumnHeaderCell
1010
{
11-
#pragma warning disable WFO5001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
12-
private static readonly VisualStyleElement s_headerElement = Application.IsDarkModeEnabled ?
13-
VisualStyleElement.CreateElement("DarkMode_ItemsView::Header", 1, 1)
14-
: VisualStyleElement.Header.Item.Normal;
15-
#pragma warning restore WFO5001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
11+
private static readonly VisualStyleElement s_headerElement = VisualStyleElement.Header.Item.Normal;
1612

1713
private const byte DATAGRIDVIEWTOPLEFTHEADERCELL_horizontalTextMarginLeft = 1;
1814
private const byte DATAGRIDVIEWTOPLEFTHEADERCELL_horizontalTextMarginRight = 2;

src/System.Windows.Forms/System/Windows/Forms/Controls/TabControl/TabRenderer.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,7 @@ public static void DrawTabPage(Graphics g, Rectangle bounds)
144144

145145
internal static void DrawTabPage(IDeviceContext deviceContext, Rectangle bounds)
146146
{
147-
#pragma warning disable WFO5001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
148-
// Using DarkMode Theme Subclass.
149-
// see https://learn.microsoft.com/en-us/windows/win32/controls/theme-subclasses.
150-
VisualStyleElement darkTabPaneElement = VisualStyleElement.CreateElement("DarkMode::ExplorerNavPane", 0, 0);
151-
VisualStyleElement lightTabPaneElement = VisualStyleElement.Tab.Pane.Normal;
152-
VisualStyleElement tabPaneElement = Application.IsDarkModeEnabled
153-
? darkTabPaneElement
154-
: lightTabPaneElement;
155-
InitializeRenderer(tabPaneElement, 0);
156-
#pragma warning restore WFO5001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
147+
InitializeRenderer(VisualStyleElement.Tab.Pane.Normal, 0);
157148
t_visualStyleRenderer.DrawBackground(deviceContext, bounds);
158149
}
159150

0 commit comments

Comments
 (0)