-
Notifications
You must be signed in to change notification settings - Fork 984
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Dark Mode Visual Style Theme Subclass #11985
base: main
Are you sure you want to change the base?
Changes from all commits
2b3545c
7e309f4
e96baf5
cabfc15
9c93f8c
a0d17a3
fe55b13
3f9b434
4070e2c
2ac8c87
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,8 +48,6 @@ public sealed partial class Application | |
private static SystemColorMode? s_colorMode; | ||
#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. | ||
|
||
private const string DarkModeKeyPath = "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"; | ||
private const string DarkModeKey = "AppsUseLightTheme"; | ||
private const int SystemDarkModeDisabled = 1; | ||
|
||
/// <summary> | ||
|
@@ -379,21 +377,9 @@ private static int GetSystemColorModeInternal() | |
return SystemDarkModeDisabled; | ||
} | ||
|
||
int systemColorMode = SystemDarkModeDisabled; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're still discussing, if we can take this for .NET 9 RC2 (the bar is service, and we would need to consider this a bug fix). So, this particular change, we would probably not want to take. @merriemcgaw, @lonitra. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to be as it is, please revert this. |
||
|
||
try | ||
{ | ||
// 0 for dark mode and |1| for light mode. | ||
systemColorMode = Math.Abs((Registry.GetValue( | ||
keyName: DarkModeKeyPath, | ||
valueName: DarkModeKey, | ||
defaultValue: SystemDarkModeDisabled) as int?) ?? systemColorMode); | ||
} | ||
catch (Exception ex) when (!ex.IsCriticalException()) | ||
{ | ||
} | ||
|
||
return systemColorMode; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here - we need to keep this. |
||
#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. | ||
return VisualStyleRenderer.IsDarkModeSupported ? 0 : 1; | ||
#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. | ||
} | ||
|
||
private static bool IsSystemDarkModeAvailable => | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,11 @@ public static class ComboBoxRenderer | |
// Make this per-thread, so that different threads can safely use these methods. | ||
[ThreadStatic] | ||
private static VisualStyleRenderer? t_visualStyleRenderer; | ||
private static readonly VisualStyleElement s_comboBoxElement = VisualStyleElement.ComboBox.DropDownButton.Normal; | ||
#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. | ||
private static readonly VisualStyleElement s_comboBoxElement = Application.IsDarkModeEnabled | ||
? VisualStyleElement.CreateElement($"{Control.DarkModeIdentifier}_{Control.ComboBoxButtonThemeIdentifier}::COMBOBOX", 1, 1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you introduce a const for |
||
: VisualStyleElement.ComboBox.DropDownButton.Normal; | ||
#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. | ||
private static readonly VisualStyleElement s_textBoxElement = VisualStyleElement.TextBox.TextEdit.Normal; | ||
|
||
/// <summary> | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -17,7 +17,11 @@ public partial class DataGridViewButtonCell : DataGridViewCell | |||||||||||||
private static readonly int s_propButtonCellFlatStyle = PropertyStore.CreateKey(); | ||||||||||||||
private static readonly int s_propButtonCellState = PropertyStore.CreateKey(); | ||||||||||||||
private static readonly int s_propButtonCellUseColumnTextForButtonValue = PropertyStore.CreateKey(); | ||||||||||||||
private static readonly VisualStyleElement s_buttonElement = VisualStyleElement.Button.PushButton.Normal; | ||||||||||||||
#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. | ||||||||||||||
private static readonly VisualStyleElement s_darkButtonElement = VisualStyleElement.CreateElement("DarkMode_Explorer::BUTTON", 1, 1); | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think, instead of hardcoding "DarkMode_Explorer" it should be an interpolated const, e.g.: winforms/src/System.Windows.Forms/src/System/Windows/Forms/Control.cs Lines 162 to 165 in 14acefa
If any more consts need adding - they should be added here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done, does that look good now? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, I do not see that you changed anything. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this was missed
Suggested change
|
||||||||||||||
private static readonly VisualStyleElement s_lightButtonElement = VisualStyleElement.Button.PushButton.Normal; | ||||||||||||||
private static readonly VisualStyleElement s_buttonElement = Application.IsDarkModeEnabled ? s_darkButtonElement : s_lightButtonElement; | ||||||||||||||
#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. | ||||||||||||||
|
||||||||||||||
private const byte DATAGRIDVIEWBUTTONCELL_themeMargin = 100; // Used to calculate the margins required for theming rendering | ||||||||||||||
private const byte DATAGRIDVIEWBUTTONCELL_horizontalTextMargin = 2; | ||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,14 @@ public partial class DataGridViewCheckBoxCell : DataGridViewCell, IDataGridViewE | |
private const DataGridViewContentAlignment AnyBottom = DataGridViewContentAlignment.BottomRight | DataGridViewContentAlignment.BottomCenter | DataGridViewContentAlignment.BottomLeft; | ||
private const DataGridViewContentAlignment AnyMiddle = DataGridViewContentAlignment.MiddleRight | DataGridViewContentAlignment.MiddleCenter | DataGridViewContentAlignment.MiddleLeft; | ||
|
||
private static readonly VisualStyleElement s_checkBoxElement = VisualStyleElement.Button.CheckBox.UncheckedNormal; | ||
#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. | ||
private static readonly VisualStyleElement s_darkCheckBoxElement = VisualStyleElement.CreateElement($"{Control.DarkModeIdentifier}_{Control.ExplorerThemeIdentifier}::BUTTON", 3, 1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you introduce a const for the button part as well? |
||
private static readonly VisualStyleElement s_lightCheckBoxElement = VisualStyleElement.Button.CheckBox.UncheckedNormal; | ||
private static readonly VisualStyleElement s_checkBoxElement = Application.IsDarkModeEnabled | ||
? s_darkCheckBoxElement | ||
: s_lightCheckBoxElement; | ||
#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. | ||
|
||
private static readonly int s_propButtonCellState = PropertyStore.CreateKey(); | ||
private static readonly int s_propTrueValue = PropertyStore.CreateKey(); | ||
private static readonly int s_propFalseValue = PropertyStore.CreateKey(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,11 @@ public static VisualStyleRenderer VisualStyleRenderer | |
{ | ||
get | ||
{ | ||
s_visualStyleRenderer ??= new VisualStyleRenderer(s_headerElement); | ||
#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. | ||
s_visualStyleRenderer ??= new VisualStyleRenderer(Application.IsDarkModeEnabled | ||
? VisualStyleElement.CreateElement($"{Control.DarkModeIdentifier}_{Control.ItemsViewThemeIdentifier}::Header", 1, 1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you introduce a const for the Header part as well? |
||
: VisualStyleElement.Header.Item.Normal); | ||
#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. | ||
|
||
return s_visualStyleRenderer; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,11 @@ namespace System.Windows.Forms; | |
|
||
public partial class DataGridViewColumnHeaderCell : DataGridViewHeaderCell | ||
{ | ||
private static readonly VisualStyleElement s_headerElement = VisualStyleElement.Header.Item.Normal; | ||
#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. | ||
private static readonly VisualStyleElement s_headerElement = Application.IsDarkModeEnabled | ||
? VisualStyleElement.CreateElement($"{Control.DarkModeIdentifier}_{Control.ItemsViewThemeIdentifier}::Header", 1, 1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here? |
||
: VisualStyleElement.Header.Item.Normal; | ||
#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. | ||
|
||
private const byte SortGlyphSeparatorWidth = 2; // additional 2 pixels between caption and glyph | ||
private const byte SortGlyphHorizontalMargin = 4; // 4 pixels on left & right of glyph | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,10 +12,29 @@ private static class DataGridViewComboBoxCellRenderer | |
{ | ||
[ThreadStatic] | ||
private static VisualStyleRenderer? t_visualStyleRenderer; | ||
private static readonly VisualStyleElement s_comboBoxBorder = VisualStyleElement.ComboBox.Border.Normal; | ||
private static readonly VisualStyleElement s_comboBoxDropDownButtonRight = VisualStyleElement.ComboBox.DropDownButtonRight.Normal; | ||
private static readonly VisualStyleElement s_comboBoxDropDownButtonLeft = VisualStyleElement.ComboBox.DropDownButtonLeft.Normal; | ||
private static readonly VisualStyleElement s_comboBoxReadOnlyButton = VisualStyleElement.ComboBox.ReadOnlyButton.Normal; | ||
#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. | ||
private static readonly VisualStyleElement s_comboBoxBorder = Application.IsDarkModeEnabled | ||
? VisualStyleElement.CreateElement($"{Control.DarkModeIdentifier}_{Control.ComboBoxButtonThemeIdentifier}::COMBOBOX", 4, 1) | ||
: VisualStyleElement.ComboBox.Border.Normal; | ||
#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. | ||
|
||
#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. | ||
private static readonly VisualStyleElement s_comboBoxDropDownButtonRight = Application.IsDarkModeEnabled | ||
? VisualStyleElement.CreateElement($"{Control.DarkModeIdentifier}_{Control.ComboBoxButtonThemeIdentifier}::COMBOBOX", 6, 1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you address the Combox text as well (both spots)? Thanks! |
||
: VisualStyleElement.ComboBox.DropDownButtonRight.Normal; | ||
#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. | ||
|
||
#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. | ||
private static readonly VisualStyleElement s_comboBoxDropDownButtonLeft = Application.IsDarkModeEnabled | ||
? VisualStyleElement.CreateElement($"{Control.DarkModeIdentifier}_{Control.ComboBoxButtonThemeIdentifier}::COMBOBOX", 7, 1) | ||
: VisualStyleElement.ComboBox.DropDownButtonLeft.Normal; | ||
#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. | ||
|
||
#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. | ||
private static readonly VisualStyleElement s_comboBoxReadOnlyButton = Application.IsDarkModeEnabled | ||
? VisualStyleElement.CreateElement($"{Control.DarkModeIdentifier}_{Control.ComboBoxButtonThemeIdentifier}::COMBOBOX", 5, 1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And here! 😸 |
||
: VisualStyleElement.ComboBox.ReadOnlyButton.Normal; | ||
#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. | ||
|
||
public static VisualStyleRenderer VisualStyleRenderer | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,11 @@ namespace System.Windows.Forms; | |
|
||
public partial class DataGridViewRowHeaderCell : DataGridViewHeaderCell | ||
{ | ||
private static readonly VisualStyleElement s_headerElement = VisualStyleElement.Header.Item.Normal; | ||
#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. | ||
private static readonly VisualStyleElement s_headerElement = Application.IsDarkModeEnabled | ||
? VisualStyleElement.CreateElement($"{Control.DarkModeIdentifier}_{Control.ItemsViewThemeIdentifier}::Header", 1, 1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same for the "Header". |
||
: VisualStyleElement.Header.Item.Normal; | ||
#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. | ||
|
||
private static Bitmap? s_rightArrowBmp; | ||
private static Bitmap? s_leftArrowBmp; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,11 @@ namespace System.Windows.Forms; | |
|
||
public partial class DataGridViewTopLeftHeaderCell : DataGridViewColumnHeaderCell | ||
{ | ||
private static readonly VisualStyleElement s_headerElement = VisualStyleElement.Header.Item.Normal; | ||
#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. | ||
private static readonly VisualStyleElement s_headerElement = Application.IsDarkModeEnabled | ||
? VisualStyleElement.CreateElement($"{Control.DarkModeIdentifier}_{Control.ItemsViewThemeIdentifier}::Header", 1, 1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And here! 😺 |
||
: VisualStyleElement.Header.Item.Normal; | ||
#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. | ||
|
||
private const byte DATAGRIDVIEWTOPLEFTHEADERCELL_horizontalTextMarginLeft = 1; | ||
private const byte DATAGRIDVIEWTOPLEFTHEADERCELL_horizontalTextMarginRight = 2; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1259,6 +1259,13 @@ protected override void OnHandleCreated(EventArgs e) | |
0, 0, 0, 0, | ||
SET_WINDOW_POS_FLAGS.SWP_NOMOVE | SET_WINDOW_POS_FLAGS.SWP_NOSIZE | SET_WINDOW_POS_FLAGS.SWP_NOACTIVATE); | ||
} | ||
|
||
#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. | ||
if (Application.IsDarkModeEnabled) | ||
{ | ||
PInvoke.SendMessage(tooltipHwnd, PInvoke.TTM_SETWINDOWTHEME, default, "DarkMode_Explorer"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you use the existing const here? |
||
} | ||
#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. | ||
} | ||
|
||
// Add the pages | ||
|
@@ -1288,6 +1295,17 @@ protected override void OnHandleCreated(EventArgs e) | |
} | ||
|
||
UpdateTabSelection(false); | ||
// TabControl didn't have Tab Appearance in Dark mode theme to support Dark Mode Tab Appearance we need to draw The buttons in paint event. | ||
|
||
#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. | ||
if (Application.IsDarkModeEnabled && GetStyle(ControlStyles.ApplyThemingImplicitly)) | ||
{ | ||
_ = PInvoke.SetWindowTheme( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If not all tabs can be shown at once, the tab control will display an up-down control that will also need to be styled. |
||
hwnd: HWND, | ||
pszSubAppName: null, | ||
pszSubIdList: $"{DarkModeIdentifier}::{BannerContainerThemeIdentifier}"); | ||
} | ||
#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. | ||
} | ||
|
||
protected override void OnHandleDestroyed(EventArgs e) | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -3,6 +3,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
using System.Drawing; | ||||||||||||||||||||||||||||||||||||||||||||||
using System.Drawing.Interop; | ||||||||||||||||||||||||||||||||||||||||||||||
using System.Windows.Forms.Analyzers.Diagnostics; | ||||||||||||||||||||||||||||||||||||||||||||||
using Microsoft.Win32; | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
namespace System.Windows.Forms.VisualStyles; | ||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -65,6 +66,37 @@ public static bool IsSupported | |||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
/// <summary> | ||||||||||||||||||||||||||||||||||||||||||||||
/// <para> | ||||||||||||||||||||||||||||||||||||||||||||||
/// Gets a value specifying whether the operating system has Dark Mode visual styles subclass and the Application can use this subclass to draw controls with Dark Mode theme. | ||||||||||||||||||||||||||||||||||||||||||||||
///</para> | ||||||||||||||||||||||||||||||||||||||||||||||
///<para> | ||||||||||||||||||||||||||||||||||||||||||||||
///<return> | ||||||||||||||||||||||||||||||||||||||||||||||
///<para> Returns true if Visual Style Dark Mode subclass is: </para> | ||||||||||||||||||||||||||||||||||||||||||||||
/// <para> 1) Supported by the operating system.</para> | ||||||||||||||||||||||||||||||||||||||||||||||
/// <para> 2) Enabled in the client area.</para> | ||||||||||||||||||||||||||||||||||||||||||||||
/// <para> 3) operating system not ruining in high contrast mode</para> | ||||||||||||||||||||||||||||||||||||||||||||||
/// <para> Otherwise, returns false. Note that if false is returned, attempts to create/use objects of this class will throw exceptions.</para> | ||||||||||||||||||||||||||||||||||||||||||||||
///</return> | ||||||||||||||||||||||||||||||||||||||||||||||
///</para> | ||||||||||||||||||||||||||||||||||||||||||||||
/// </summary> | ||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+69
to
+82
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||
[Experimental(DiagnosticIDs.ExperimentalDarkMode, UrlFormat = DiagnosticIDs.UrlFormat)] | ||||||||||||||||||||||||||||||||||||||||||||||
public static bool IsDarkModeSupported | ||||||||||||||||||||||||||||||||||||||||||||||
memoarfaa marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At this point we cannot add new public API for net 9 RC2. Does this need to be public to fix rendering issues? |
||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||
get | ||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||
bool supported = AreClientAreaVisualStylesSupported; | ||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is too invasive a change this late in the game. |
||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
if (supported) | ||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||
HTHEME hTheme = GetHandle($"{Control.DarkModeIdentifier}_{Control.ExplorerThemeIdentifier}::BUTTON", false); // Button is an arbitrary choice. | ||||||||||||||||||||||||||||||||||||||||||||||
supported = !hTheme.IsNull && !SystemInformation.HighContrast; | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
return supported; | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
/// <summary> | ||||||||||||||||||||||||||||||||||||||||||||||
/// Returns true if the element is defined by the current visual style, else false. | ||||||||||||||||||||||||||||||||||||||||||||||
/// Note: | ||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cannot take new APIs at this point. So, this needs to be reverted.