diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.EditorPropertyLine.FlyoutDialog.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.EditorPropertyLine.FlyoutDialog.cs
index 1afbf4052eb..daa3ed8a5d7 100644
--- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.EditorPropertyLine.FlyoutDialog.cs
+++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.EditorPropertyLine.FlyoutDialog.cs
@@ -15,12 +15,11 @@ internal class FlyoutDialog : Form
private readonly Control _hostedControl;
private readonly Control _parentControl;
-#pragma warning disable WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
public FlyoutDialog(Control hostedControl, Control parentControl, Color borderColor, Font font)
{
_hostedControl = hostedControl;
_parentControl = parentControl;
- BackColor = ControlSystemColors.Current.Window;
+ BackColor = SystemColors.Window;
ControlBox = false;
Font = font;
FormBorderStyle = FormBorderStyle.None;
@@ -54,7 +53,6 @@ public FlyoutDialog(Control hostedControl, Control parentControl, Color borderCo
ResumeLayout();
}
}
-#pragma warning restore WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
protected override CreateParams CreateParams
{
diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.EditorPropertyLine.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.EditorPropertyLine.cs
index dc3bc5ed6a3..d667c15f31e 100644
--- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.EditorPropertyLine.cs
+++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.EditorPropertyLine.cs
@@ -11,7 +11,6 @@ namespace System.ComponentModel.Design;
internal sealed partial class DesignerActionPanel
{
-#pragma warning disable WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
private sealed partial class EditorPropertyLine : TextBoxPropertyLine, IWindowsFormsEditorService, IServiceProvider
{
private readonly EditorButton _button;
@@ -109,7 +108,7 @@ private unsafe void ActivateDropDown()
try
{
- ShowDropDown(listBox, ControlSystemColors.Current.ControlDark);
+ ShowDropDown(listBox, SystemColors.ControlDark);
}
finally
{
@@ -483,5 +482,4 @@ public override Line CreateLine(IServiceProvider serviceProvider, DesignerAction
public override Type LineType => typeof(EditorPropertyLine);
}
}
-#pragma warning restore WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
}
diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.TextBoxPropertyLine.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.TextBoxPropertyLine.cs
index d916dc1469e..cb9d0644f29 100644
--- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.TextBoxPropertyLine.cs
+++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.TextBoxPropertyLine.cs
@@ -8,7 +8,6 @@ namespace System.ComponentModel.Design;
internal sealed partial class DesignerActionPanel
{
-#pragma warning disable WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
private class TextBoxPropertyLine : PropertyLine
{
private readonly TextBox _textBox;
@@ -33,9 +32,7 @@ protected TextBoxPropertyLine(IServiceProvider serviceProvider, DesignerActionPa
_readOnlyTextBoxLabel = new EditorLabel
{
BackColor = Color.Transparent,
-#pragma warning disable WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
- ForeColor = ControlSystemColors.Current.WindowText,
-#pragma warning restore WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
+ ForeColor = SystemColors.WindowText,
TabStop = true,
TextAlign = ContentAlignment.TopLeft,
UseMnemonic = false,
@@ -160,19 +157,17 @@ protected virtual void OnReadOnlyTextBoxLabelClick(object? sender, MouseEventArg
}
}
-#pragma warning disable WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
private void OnReadOnlyTextBoxLabelEnter(object? sender, EventArgs e)
{
- _readOnlyTextBoxLabel.ForeColor = ControlSystemColors.Current.HighlightText;
- _readOnlyTextBoxLabel.BackColor = ControlSystemColors.Current.Highlight;
+ _readOnlyTextBoxLabel.ForeColor = SystemColors.HighlightText;
+ _readOnlyTextBoxLabel.BackColor = SystemColors.Highlight;
}
private void OnReadOnlyTextBoxLabelLeave(object? sender, EventArgs e)
{
- _readOnlyTextBoxLabel.ForeColor = ControlSystemColors.Current.WindowText;
- _readOnlyTextBoxLabel.BackColor = ControlSystemColors.Current.Window;
+ _readOnlyTextBoxLabel.ForeColor = SystemColors.WindowText;
+ _readOnlyTextBoxLabel.BackColor = SystemColors.Window;
}
-#pragma warning restore WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
protected TypeConverter.StandardValuesCollection? GetStandardValues()
{
@@ -371,5 +366,4 @@ public override Line CreateLine(IServiceProvider serviceProvider, DesignerAction
public override Type LineType => typeof(TextBoxPropertyLine);
}
}
-#pragma warning restore WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
}
diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.cs
index b816e21c55d..f6e7d691b09 100644
--- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.cs
+++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionPanel.cs
@@ -13,7 +13,6 @@ namespace System.ComponentModel.Design;
internal sealed partial class DesignerActionPanel : ContainerControl
{
-#pragma warning disable WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
private static readonly object s_eventFormActivated = new();
private static readonly object s_eventFormDeactivate = new();
@@ -118,9 +117,9 @@ public DesignerActionPanel(IServiceProvider serviceProvider)
MinimumSize = new Size(150, 0);
}
- public Color ActiveLinkColor { get; } = ControlSystemColors.Current.HotTrack;
+ public Color ActiveLinkColor { get; } = SystemColors.HotTrack;
- public Color BorderColor { get; } = ControlSystemColors.Current.ActiveBorder;
+ public Color BorderColor { get; } = SystemColors.ActiveBorder;
///
/// Returns the list of commands that should be filtered by the form that hosts this panel. This is done so that these specific commands will not get passed on to VS, and can instead be handled by the panel itself.
@@ -168,23 +167,23 @@ public DesignerActionPanel(IServiceProvider serviceProvider)
///
private Line? FocusedLine => ActiveControl?.Tag as Line;
- public Color GradientDarkColor { get; } = ControlSystemColors.Current.Control;
+ public Color GradientDarkColor { get; } = SystemColors.Control;
- public Color GradientLightColor { get; } = ControlSystemColors.Current.Control;
+ public Color GradientLightColor { get; } = SystemColors.Control;
public bool InMethodInvoke { get; internal set; }
- public Color LinkColor { get; } = ControlSystemColors.Current.HotTrack;
+ public Color LinkColor { get; } = SystemColors.HotTrack;
- public Color SeparatorColor { get; } = ControlSystemColors.Current.ControlDark;
+ public Color SeparatorColor { get; } = SystemColors.ControlDark;
- public Color TitleBarColor { get; } = ControlSystemColors.Current.ActiveCaption;
+ public Color TitleBarColor { get; } = SystemColors.ActiveCaption;
- public Color TitleBarTextColor { get; } = ControlSystemColors.Current.ActiveCaptionText;
+ public Color TitleBarTextColor { get; } = SystemColors.ActiveCaptionText;
- public Color TitleBarUnselectedColor { get; } = ControlSystemColors.Current.InactiveCaption;
+ public Color TitleBarUnselectedColor { get; } = SystemColors.InactiveCaption;
- public Color LabelForeColor { get; } = ControlSystemColors.Current.ControlText;
+ public Color LabelForeColor { get; } = SystemColors.ControlText;
///
/// Helper event so that Lines can be notified of this event.
@@ -909,5 +908,4 @@ public void UpdateTasks(DesignerActionListCollection actionLists, DesignerAction
Invalidate();
}
-#pragma warning restore WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
}
diff --git a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIService.SelectionUIItem.cs b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIService.SelectionUIItem.cs
index 5535afc853d..b3373c7e963 100644
--- a/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIService.SelectionUIItem.cs
+++ b/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/SelectionUIService.SelectionUIItem.cs
@@ -135,9 +135,8 @@ public virtual void DoPaint(Graphics graphics)
Rectangle inner = _innerRect;
Rectangle outer = _outerRect;
Region oldClip = graphics.Clip;
-#pragma warning disable WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
- Color borderColor = ControlSystemColors.Current.Control;
-#pragma warning restore WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
+ Color borderColor = SystemColors.Control;
+
if (_control is not null && _control.Parent is not null)
{
Control parent = _control.Parent;
diff --git a/src/System.Windows.Forms/src/PublicAPI.Unshipped.txt b/src/System.Windows.Forms/src/PublicAPI.Unshipped.txt
index 1be282acf39..2ccf2313984 100644
--- a/src/System.Windows.Forms/src/PublicAPI.Unshipped.txt
+++ b/src/System.Windows.Forms/src/PublicAPI.Unshipped.txt
@@ -2,8 +2,6 @@ override System.Windows.Forms.CheckBox.OnPaint(System.Windows.Forms.PaintEventAr
static System.Windows.Forms.Application.ColorMode.get -> System.Windows.Forms.SystemColorMode
static System.Windows.Forms.Application.SetColorMode(System.Windows.Forms.SystemColorMode systemColorMode) -> void
static System.Windows.Forms.Application.SystemColorMode.get -> System.Windows.Forms.SystemColorMode
-static System.Windows.Forms.Control.ControlSystemColors.Current.get -> System.Windows.Forms.Control.ControlSystemColors!
-static System.Windows.Forms.Control.ControlSystemColors.GetAdaptedDarkModeColorFromKnownColor(System.Drawing.KnownColor knownColor, bool darkMode) -> System.Drawing.Color
System.Windows.Forms.Form.FormBorderColor.get -> System.Drawing.Color
System.Windows.Forms.Form.FormBorderColor.set -> void
System.Windows.Forms.Form.FormBorderColorChanged -> System.EventHandler?
@@ -25,8 +23,6 @@ System.Windows.Forms.SystemColorMode
System.Windows.Forms.SystemColorMode.Classic = 0 -> System.Windows.Forms.SystemColorMode
System.Windows.Forms.SystemColorMode.Dark = 2 -> System.Windows.Forms.SystemColorMode
System.Windows.Forms.SystemColorMode.System = 1 -> System.Windows.Forms.SystemColorMode
-System.Windows.Forms.Control.ControlSystemColors
-System.Windows.Forms.Control.SystemColors.get -> System.Windows.Forms.Control.ControlSystemColors!
System.Windows.Forms.Control.VisualStylesModeChanged -> System.EventHandler?
System.Windows.Forms.ControlStyles.ApplyThemingImplicitly = 524288 -> System.Windows.Forms.ControlStyles
override System.Windows.Forms.ProgressBar.OnCreateControl() -> void
@@ -47,39 +43,6 @@ virtual System.Windows.Forms.Control.DefaultVisualStylesMode.get -> System.Windo
virtual System.Windows.Forms.Control.OnDebuggerBreak(string! ticket) -> bool
virtual System.Windows.Forms.Control.OnParentVisualStylesModeChanged(System.EventArgs! e) -> void
virtual System.Windows.Forms.Control.OnVisualStylesModeChanged(System.EventArgs! e) -> void
-System.Windows.Forms.Control.ControlSystemColors.ActiveBorder.get -> System.Drawing.Color
-System.Windows.Forms.Control.ControlSystemColors.ActiveCaption.get -> System.Drawing.Color
-System.Windows.Forms.Control.ControlSystemColors.ActiveCaptionText.get -> System.Drawing.Color
-System.Windows.Forms.Control.ControlSystemColors.AppWorkspace.get -> System.Drawing.Color
-System.Windows.Forms.Control.ControlSystemColors.ButtonFace.get -> System.Drawing.Color
-System.Windows.Forms.Control.ControlSystemColors.ButtonHighlight.get -> System.Drawing.Color
-System.Windows.Forms.Control.ControlSystemColors.ButtonShadow.get -> System.Drawing.Color
-System.Windows.Forms.Control.ControlSystemColors.Control.get -> System.Drawing.Color
-System.Windows.Forms.Control.ControlSystemColors.ControlDark.get -> System.Drawing.Color
-System.Windows.Forms.Control.ControlSystemColors.ControlDarkDark.get -> System.Drawing.Color
-System.Windows.Forms.Control.ControlSystemColors.ControlLight.get -> System.Drawing.Color
-System.Windows.Forms.Control.ControlSystemColors.ControlLightLight.get -> System.Drawing.Color
-System.Windows.Forms.Control.ControlSystemColors.ControlText.get -> System.Drawing.Color
-System.Windows.Forms.Control.ControlSystemColors.Desktop.get -> System.Drawing.Color
-System.Windows.Forms.Control.ControlSystemColors.GradientActiveCaption.get -> System.Drawing.Color
-System.Windows.Forms.Control.ControlSystemColors.GradientInactiveCaption.get -> System.Drawing.Color
-System.Windows.Forms.Control.ControlSystemColors.GrayText.get -> System.Drawing.Color
-System.Windows.Forms.Control.ControlSystemColors.Highlight.get -> System.Drawing.Color
-System.Windows.Forms.Control.ControlSystemColors.HighlightText.get -> System.Drawing.Color
-System.Windows.Forms.Control.ControlSystemColors.HotTrack.get -> System.Drawing.Color
-System.Windows.Forms.Control.ControlSystemColors.InactiveBorder.get -> System.Drawing.Color
-System.Windows.Forms.Control.ControlSystemColors.InactiveCaption.get -> System.Drawing.Color
-System.Windows.Forms.Control.ControlSystemColors.InactiveCaptionText.get -> System.Drawing.Color
-System.Windows.Forms.Control.ControlSystemColors.Info.get -> System.Drawing.Color
-System.Windows.Forms.Control.ControlSystemColors.InfoText.get -> System.Drawing.Color
-System.Windows.Forms.Control.ControlSystemColors.Menu.get -> System.Drawing.Color
-System.Windows.Forms.Control.ControlSystemColors.MenuBar.get -> System.Drawing.Color
-System.Windows.Forms.Control.ControlSystemColors.MenuHighlight.get -> System.Drawing.Color
-System.Windows.Forms.Control.ControlSystemColors.MenuText.get -> System.Drawing.Color
-System.Windows.Forms.Control.ControlSystemColors.ScrollBar.get -> System.Drawing.Color
-System.Windows.Forms.Control.ControlSystemColors.Window.get -> System.Drawing.Color
-System.Windows.Forms.Control.ControlSystemColors.WindowFrame.get -> System.Drawing.Color
-System.Windows.Forms.Control.ControlSystemColors.WindowText.get -> System.Drawing.Color
virtual System.Windows.Forms.Form.OnFormBorderColorChanged(System.EventArgs! e) -> void
virtual System.Windows.Forms.Form.OnFormCaptionBackColorChanged(System.EventArgs! e) -> void
virtual System.Windows.Forms.Form.OnFormCaptionTextColorChanged(System.EventArgs! e) -> void
diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ActiveX/AxHost.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ActiveX/AxHost.cs
index f54ed24d193..d9b1249e73d 100644
--- a/src/System.Windows.Forms/src/System/Windows/Forms/ActiveX/AxHost.cs
+++ b/src/System.Windows.Forms/src/System/Windows/Forms/ActiveX/AxHost.cs
@@ -3361,10 +3361,8 @@ private unsafe bool QuickActivate()
}
else
{
-#pragma warning disable WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates.
- qaContainer.colorFore = GetOleColorFromColor(ControlSystemColors.Current.WindowText);
- qaContainer.colorBack = GetOleColorFromColor(ControlSystemColors.Current.Window);
-#pragma warning restore WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates.
+ qaContainer.colorFore = GetOleColorFromColor(SystemColors.WindowText);
+ qaContainer.colorBack = GetOleColorFromColor(SystemColors.Window);
}
qaContainer.dwAmbientFlags = QACONTAINERFLAGS.QACONTAINER_AUTOCLIP
diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Application.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Application.cs
index 5516d038c66..7881db0e345 100644
--- a/src/System.Windows.Forms/src/System/Windows/Forms/Application.cs
+++ b/src/System.Windows.Forms/src/System/Windows/Forms/Application.cs
@@ -266,13 +266,20 @@ internal static bool CustomThreadExceptionHandlerAttached
[Experimental("WFO9001")]
public static void SetColorMode(SystemColorMode systemColorMode)
{
- if (GetSystemColorModeInternal() > -1)
+ try
{
- s_systemColorMode = systemColorMode;
- return;
- }
+ if (GetSystemColorModeInternal() > -1)
+ {
+ s_systemColorMode = systemColorMode;
+ return;
+ }
- s_systemColorMode = SystemColorMode.Classic;
+ s_systemColorMode = SystemColorMode.Classic;
+ }
+ finally
+ {
+ SystemColors.UseAlternativeColorSet = IsDarkModeEnabled;
+ }
}
///
diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Control.ControlSystemColors.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Control.ControlSystemColors.cs
deleted file mode 100644
index 5e4185bdb02..00000000000
--- a/src/System.Windows.Forms/src/System/Windows/Forms/Control.ControlSystemColors.cs
+++ /dev/null
@@ -1,358 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-using System.Drawing;
-using System.Runtime.CompilerServices;
-
-namespace System.Windows.Forms;
-
-public unsafe partial class Control
-{
- [Experimental("WFO9001")]
- public class ControlSystemColors
- {
- private readonly Color[] _mappedSystemColors;
-
- private static readonly Color[] s_systemColors =
- [
- Drawing.SystemColors.ActiveBorder,
- Drawing.SystemColors.ActiveCaption,
- Drawing.SystemColors.ActiveCaptionText,
- Drawing.SystemColors.AppWorkspace,
- Drawing.SystemColors.Control,
- Drawing.SystemColors.ControlDark,
- Drawing.SystemColors.ControlDarkDark,
- Drawing.SystemColors.ControlLight,
- Drawing.SystemColors.ControlLightLight,
- Drawing.SystemColors.ControlText,
- Drawing.SystemColors.Desktop,
- Drawing.SystemColors.GrayText,
- Drawing.SystemColors.Highlight,
- Drawing.SystemColors.HighlightText,
- Drawing.SystemColors.HotTrack,
- Drawing.SystemColors.InactiveBorder,
- Drawing.SystemColors.InactiveCaption,
- Drawing.SystemColors.InactiveCaptionText,
- Drawing.SystemColors.Info,
- Drawing.SystemColors.InfoText,
- Drawing.SystemColors.Menu,
- Drawing.SystemColors.MenuText,
- Drawing.SystemColors.ScrollBar,
- Drawing.SystemColors.Window,
- Drawing.SystemColors.WindowFrame,
- Drawing.SystemColors.WindowText,
- Drawing.SystemColors.ButtonFace,
- Drawing.SystemColors.ButtonHighlight,
- Drawing.SystemColors.ButtonShadow,
- Drawing.SystemColors.GradientActiveCaption,
- Drawing.SystemColors.GradientInactiveCaption,
- Drawing.SystemColors.MenuBar,
- Drawing.SystemColors.MenuHighlight
- ];
-
- private static readonly Color[] s_darkSystemColors =
- [
- unchecked(Color.FromArgb((int)0xFF464646)), // FFD4D0C8 - FF464646: ActiveBorder - Dark gray
- unchecked(Color.FromArgb((int)0xFF3C5F78)), // FF0054E3 - FF3C5F78: ActiveCaption - Highlighted Text Background
- unchecked(Color.FromArgb((int)0xFFFFFFFF)), // FFFFFFFF - FF000000: ActiveCaptionText - White
- unchecked(Color.FromArgb((int)0xFF3C3C3C)), // FF808080 - FF3C3C3C: AppWorkspace - Panel Background
- unchecked(Color.FromArgb((int)0xFF202020)), // FFECE9D8 - FF373737: Control - Normal Panel/Windows Background
- unchecked(Color.FromArgb((int)0xFF4A4A4A)), // FFA0A0A0 - FF464646: ControlDark - A lighter gray for dark mode
- unchecked(Color.FromArgb((int)0xFF5A5A5A)), // FF696969 - FF5A5A5A: ControlDarkDark - An even lighter gray for dark mode
- unchecked(Color.FromArgb((int)0xFF2E2E2E)), // FF716F64 - FF2E2E2E: ControlLight - Unfocused Textbox Background
- unchecked(Color.FromArgb((int)0xFF1F1F1F)), // FFFFFFFF - FF1F1F1F: ControlLightLight - Focused Textbox Background
- unchecked(Color.FromArgb((int)0xFFFFFFFF)), // FF000000 - FFFFFFFF: ControlText - Control Forecolor and Text Color
- unchecked(Color.FromArgb((int)0xFF101010)), // FF004E98 - FF101010: Desktop - Black
- unchecked(Color.FromArgb((int)0xFF969696)), // FFACA899 - FF969696: GrayText - Prompt Text Focused TextBox
- unchecked(Color.FromArgb((int)0xFF2864B4)), // FF316AC5 - FF2864B4: Highlight - Highlighted Panel in ColorMode
- unchecked(Color.FromArgb((int)0xFFF0F0F0)), // FFFFFFFF - FF000000: HighlightText - White
- unchecked(Color.FromArgb((int)0xFF2D5FAF)), // FF0066CC - FF2D5FAF: HotTrack - Background of the ToggleSwitch
- unchecked(Color.FromArgb((int)0xFF3C3F41)), // FFD4D0C8 - FF3C3F41: InactiveBorder - Dark gray
- unchecked(Color.FromArgb((int)0xFF374B5A)), // FF7A96DF - FF374B5A: InactiveCaption - Highlighted Panel in ColorMode
- unchecked(Color.FromArgb((int)0xFFBEBEBE)), // FFD8E4F8 - FFBEBEBE: InactiveCaptionText - Middle Dark Panel
- unchecked(Color.FromArgb((int)0xFF50503C)), // FFFFFFE1 - FF50503C: Info - Link Label
- unchecked(Color.FromArgb((int)0xFFBEBEBE)), // FF000000 - FFBEBEBE: InfoText - Prompt Text Color
- unchecked(Color.FromArgb((int)0xFF373737)), // FFFFFFFF - FF373737: Menu - Normal Menu Background
- unchecked(Color.FromArgb((int)0xFFF0F0F0)), // FF000000 - FFF0F0F0: MenuText - White
- unchecked(Color.FromArgb((int)0xFF505050)), // FFD4D0C8 - FF505050: ScrollBar - Scrollbars and Scrollbar Arrows
- unchecked(Color.FromArgb((int)0xFF323232)), // FFFFFFFF - FF323232: Window - Window Background
- unchecked(Color.FromArgb((int)0xFF282828)), // FF000000 - FF282828: WindowFrame - White/Accent color
- unchecked(Color.FromArgb((int)0xFFF0F0F0)), // FF000000 - FFF0F0F0: WindowText - White
-
- unchecked(Color.FromArgb((int)0xFF202020)), // FFF0F0F0 - FF373737: ButtonFace - Same as Window Background
- unchecked(Color.FromArgb((int)0xFF101010)), // FFFFFFFF - FF101010: ButtonHighlight - White
- unchecked(Color.FromArgb((int)0xFF464646)), // FFA0A0A0 - FF464646: ButtonShadow - Same as Scrollbar Elements
- unchecked(Color.FromArgb((int)0XFF416482)), // FFB9D1EA - FF416482: GradientActiveCaption - Same as Highlighted Text Background
- unchecked(Color.FromArgb((int)0xFF557396)), // FFD7E4F2 - FF557396: GradientInactiveCaption - Same as Highlighted Panel in SystemColorMode
- unchecked(Color.FromArgb((int)0xFF373737)), // FFF0F0F0 - FF373737: MenuBar - Same as Normal Menu Background
- unchecked(Color.FromArgb((int)0xFF2A80D2)) // FF3399FF - FF2A80D2: MenuHighlight - Same as Highlighted Menu Background
- ];
-
- internal ControlSystemColors(bool isDarkMode = false)
- {
- var sourceColors = isDarkMode ? s_darkSystemColors : s_systemColors;
- _mappedSystemColors = new Color[sourceColors.Length];
-
- var sourceSpan = sourceColors.AsSpan();
- var targetSpan = _mappedSystemColors.AsSpan();
-
- for (int i = 0; i < sourceSpan.Length; i++)
- {
- targetSpan[i] = sourceSpan[i];
- }
-
- ActiveBorder = _mappedSystemColors[GetSystemColorLookupIndex(KnownColor.ActiveBorder)];
- ActiveCaption = _mappedSystemColors[GetSystemColorLookupIndex(KnownColor.ActiveCaption)];
- ActiveCaptionText = _mappedSystemColors[GetSystemColorLookupIndex(KnownColor.ActiveCaptionText)];
- AppWorkspace = _mappedSystemColors[GetSystemColorLookupIndex(KnownColor.AppWorkspace)];
- Control = _mappedSystemColors[GetSystemColorLookupIndex(KnownColor.Control)];
- ControlDark = _mappedSystemColors[GetSystemColorLookupIndex(KnownColor.ControlDark)];
- ControlDarkDark = _mappedSystemColors[GetSystemColorLookupIndex(KnownColor.ControlDarkDark)];
- ControlLight = _mappedSystemColors[GetSystemColorLookupIndex(KnownColor.ControlLight)];
- ControlLightLight = _mappedSystemColors[GetSystemColorLookupIndex(KnownColor.ControlLightLight)];
- ControlText = _mappedSystemColors[GetSystemColorLookupIndex(KnownColor.ControlText)];
- Desktop = _mappedSystemColors[GetSystemColorLookupIndex(KnownColor.Desktop)];
- GrayText = _mappedSystemColors[GetSystemColorLookupIndex(KnownColor.GrayText)];
- Highlight = _mappedSystemColors[GetSystemColorLookupIndex(KnownColor.Highlight)];
- HighlightText = _mappedSystemColors[GetSystemColorLookupIndex(KnownColor.HighlightText)];
- HotTrack = _mappedSystemColors[GetSystemColorLookupIndex(KnownColor.HotTrack)];
- InactiveBorder = _mappedSystemColors[GetSystemColorLookupIndex(KnownColor.InactiveBorder)];
- InactiveCaption = _mappedSystemColors[GetSystemColorLookupIndex(KnownColor.InactiveCaption)];
- InactiveCaptionText = _mappedSystemColors[GetSystemColorLookupIndex(KnownColor.InactiveCaptionText)];
- Info = _mappedSystemColors[GetSystemColorLookupIndex(KnownColor.Info)];
- InfoText = _mappedSystemColors[GetSystemColorLookupIndex(KnownColor.InfoText)];
- Menu = _mappedSystemColors[GetSystemColorLookupIndex(KnownColor.Menu)];
- MenuText = _mappedSystemColors[GetSystemColorLookupIndex(KnownColor.MenuText)];
- ScrollBar = _mappedSystemColors[GetSystemColorLookupIndex(KnownColor.ScrollBar)];
- Window = _mappedSystemColors[GetSystemColorLookupIndex(KnownColor.Window)];
- WindowFrame = _mappedSystemColors[GetSystemColorLookupIndex(KnownColor.WindowFrame)];
- WindowText = _mappedSystemColors[GetSystemColorLookupIndex(KnownColor.WindowText)];
- ButtonFace = _mappedSystemColors[GetSystemColorLookupIndex(KnownColor.ButtonFace)];
- ButtonHighlight = _mappedSystemColors[GetSystemColorLookupIndex(KnownColor.ButtonHighlight)];
- ButtonShadow = _mappedSystemColors[GetSystemColorLookupIndex(KnownColor.ButtonShadow)];
- GradientActiveCaption = _mappedSystemColors[GetSystemColorLookupIndex(KnownColor.GradientActiveCaption)];
- GradientInactiveCaption = _mappedSystemColors[GetSystemColorLookupIndex(KnownColor.GradientInactiveCaption)];
- MenuBar = _mappedSystemColors[GetSystemColorLookupIndex(KnownColor.MenuBar)];
- MenuHighlight = _mappedSystemColors[GetSystemColorLookupIndex(KnownColor.MenuHighlight)];
- }
-
- ///
- /// Returns the default system colors. This reflects the actual current system colors.
- ///
- internal static ControlSystemColors Default { get; } = new();
-
- ///
- /// Returns the default system colors for dark mode. This is a hard-coded set of colors intended to use for the WinForms dark mode.
- ///
- internal static ControlSystemColors DefaultDarkMode { get; } = new(true);
-
- ///
- /// Gets the current system colors depending on .
- ///
- public static ControlSystemColors Current =>
- Application.IsDarkModeEnabled ? DefaultDarkMode : Default;
-
- ///
- /// Gets the active border color.
- ///
- public Color ActiveBorder { get; }
-
- ///
- /// Gets the window color.
- ///
- public Color Window { get; }
-
- ///
- /// Gets the scroll bar color.
- ///
- public Color ScrollBar { get; }
-
- ///
- /// Gets the menu text color.
- ///
- public Color MenuText { get; }
-
- ///
- /// Gets the menu highlight color.
- ///
- public Color MenuHighlight { get; }
-
- ///
- /// Gets the menu bar color.
- ///
- public Color MenuBar { get; }
-
- ///
- /// Gets the menu color.
- ///
- public Color Menu { get; }
-
- ///
- /// Gets the info text color.
- ///
- public Color InfoText { get; }
-
- ///
- /// Gets the info color.
- ///
- public Color Info { get; }
-
- ///
- /// Gets the inactive caption text color.
- ///
- public Color InactiveCaptionText { get; }
-
- ///
- /// Gets the inactive caption color.
- ///
- public Color InactiveCaption { get; }
-
- ///
- /// Gets the inactive border color.
- ///
- public Color InactiveBorder { get; }
-
- ///
- /// Gets the hot track color.
- ///
- public Color HotTrack { get; }
-
- ///
- /// Gets the highlight text color.
- ///
- public Color HighlightText { get; }
-
- ///
- /// Gets the highlight color.
- ///
- public Color Highlight { get; }
-
- ///
- /// Gets the window frame color.
- ///
- public Color WindowFrame { get; }
-
- ///
- /// Gets the window frame color.
- ///
- public Color WindowText { get; }
-
- ///
- /// Gets the gray text color.
- ///
- public Color GrayText { get; }
-
- ///
- /// Gets the gradient active caption color.
- ///
- public Color GradientActiveCaption { get; }
-
- ///
- /// Gets the desktop color.
- ///
- public Color Desktop { get; }
-
- ///
- /// Gets the control text color.
- ///
- public Color ControlText { get; }
-
- ///
- /// Gets the control light light color.
- ///
- public Color ControlLightLight { get; }
-
- ///
- /// Gets the control light color.
- ///
- public Color ControlLight { get; }
-
- ///
- /// Gets the control dark dark color.
- ///
- public Color ControlDarkDark { get; }
-
- ///
- /// Gets the control dark color.
- ///
- public Color ControlDark { get; }
-
- ///
- /// Gets the control color.
- ///
- public Color Control { get; }
-
- ///
- /// Gets the button shadow color.
- ///
- public Color ButtonShadow { get; }
-
- ///
- /// Gets the button highlight color.
- ///
- public Color ButtonHighlight { get; }
-
- ///
- /// Gets the button face color.
- ///
- public Color ButtonFace { get; }
-
- ///
- /// Gets the application workspace color.
- ///
- public Color AppWorkspace { get; }
-
- ///
- /// Gets the active caption text color.
- ///
- public Color ActiveCaptionText { get; }
-
- ///
- /// Gets the active caption color.
- ///
- public Color ActiveCaption { get; }
-
- ///
- /// Gets the gradient inactive caption color.
- ///
- public Color GradientInactiveCaption { get; }
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- private static int GetSystemColorLookupIndex(KnownColor color)
- {
- int index;
- if (color >= KnownColor.YellowGreen)
- {
- index = (int)color - (int)KnownColor.YellowGreen + (int)KnownColor.WindowText;
- }
- else
- {
- index = (int)color;
- }
-
- index--;
- return index;
- }
-
- ///
- /// Get the system color index for the specified known color.
- ///
- /// The known color for the given system color.
- /// The 0-based index.
- /// If the known color does not reflect a system color.
- public static Color GetAdaptedDarkModeColorFromKnownColor(KnownColor knownColor, bool darkMode)
- {
- int index = GetSystemColorLookupIndex(knownColor);
-
- if (index < 0 || index >= s_systemColors.Length)
- {
- throw new ArgumentOutOfRangeException(
- nameof(knownColor),
- knownColor,
- $"{knownColor} is not a System Color.");
- }
-
- return darkMode ? s_darkSystemColors[index] : s_systemColors[index];
- }
- }
-}
diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Control.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Control.cs
index 64d4c02f4ae..8e36a2237f0 100644
--- a/src/System.Windows.Forms/src/System/Windows/Forms/Control.cs
+++ b/src/System.Windows.Forms/src/System/Windows/Forms/Control.cs
@@ -1622,9 +1622,7 @@ public ControlBindingsCollection DataBindings
/// The default BackColor of a generic top-level Control. Subclasses may have
/// different defaults.
///
-#pragma warning disable WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
- public static Color DefaultBackColor => ControlSystemColors.Current.Control;
-#pragma warning restore WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
+ public static Color DefaultBackColor => SystemColors.Control;
///
/// Deriving classes can override this to configure a default cursor for their control.
@@ -1655,9 +1653,7 @@ public static Font DefaultFont
/// The default ForeColor of a generic top-level Control. Subclasses may have
/// different defaults.
///
-#pragma warning disable WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
- public static Color DefaultForeColor => ControlSystemColors.Current.ControlText;
-#pragma warning restore WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
+ public static Color DefaultForeColor => SystemColors.ControlText;
protected virtual Padding DefaultMargin => CommonProperties.DefaultMargin;
@@ -1707,9 +1703,7 @@ internal Color DisabledColor
if (control is null)
{
// Don't know what to do, this seems good as anything
-#pragma warning disable WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
color = SystemColors.Control;
-#pragma warning restore WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
break;
}
@@ -3187,12 +3181,6 @@ public event EventHandler? SizeChanged
remove => Events.RemoveHandler(s_sizeEvent, value);
}
- [Experimental("WFO9001")]
- public ControlSystemColors SystemColors =>
- Application.IsDarkModeEnabled
- ? ControlSystemColors.DefaultDarkMode
- : ControlSystemColors.Default;
-
///
/// The tab index of this control.
///
@@ -8622,9 +8610,7 @@ internal unsafe void PaintTransparentBackground(PaintEventArgs e, Rectangle rect
// For whatever reason, our parent can't paint our background, but we need some kind of background
// since we're transparent.
using DeviceContextHdcScope hdcNoParent = new(e);
-#pragma warning disable WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
using CreateBrushScope hbrush = new(SystemColors.Control);
-#pragma warning restore WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
hdcNoParent.FillRectangle(rectangle, hbrush);
return;
}
diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ComboBox/ComboBox.FlatComboAdapter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ComboBox/ComboBox.FlatComboAdapter.cs
index 9609c4130a0..75d96c937e5 100644
--- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ComboBox/ComboBox.FlatComboAdapter.cs
+++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ComboBox/ComboBox.FlatComboAdapter.cs
@@ -186,22 +186,20 @@ protected virtual void DrawFlatComboDropDown(ComboBox comboBox, Graphics g, Rect
});
}
-#pragma warning disable WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
protected virtual Color GetOuterBorderColor(ComboBox comboBox)
- => comboBox.Enabled ? ControlSystemColors.Current.Window : ControlSystemColors.Current.ControlDark;
+ => comboBox.Enabled ? SystemColors.Window : SystemColors.ControlDark;
protected virtual Color GetPopupOuterBorderColor(ComboBox comboBox, bool focused)
{
if (!comboBox.Enabled)
{
- return ControlSystemColors.Current.ControlDark;
+ return SystemColors.ControlDark;
}
- return focused ? ControlSystemColors.Current.ControlDark : ControlSystemColors.Current.Window;
+ return focused ? SystemColors.ControlDark : SystemColors.Window;
}
protected virtual Color GetInnerBorderColor(ComboBox comboBox)
- => comboBox.Enabled ? comboBox.BackColor : ControlSystemColors.Current.Control;
-#pragma warning restore WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
+ => comboBox.Enabled ? comboBox.BackColor : SystemColors.Control;
}
}
diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/DataGridView/DataGridView.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/DataGridView/DataGridView.cs
index 07c2188cd6b..feeb97ffb9f 100644
--- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/DataGridView/DataGridView.cs
+++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/DataGridView/DataGridView.cs
@@ -354,10 +354,8 @@ private const DataGridViewAutoSizeRowCriteriaInternal InvalidDataGridViewAutoSiz
private readonly Dictionary _converters;
-#pragma warning disable WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
- private static readonly Color s_defaultBackColor = ControlSystemColors.Current.Window;
- private static readonly Color s_defaultBackgroundColor = ControlSystemColors.Current.ControlDark;
-#pragma warning restore WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
+ private static readonly Color s_defaultBackColor = SystemColors.Window;
+ private static readonly Color s_defaultBackgroundColor = SystemColors.ControlDark;
private Color _backgroundColor = s_defaultBackgroundColor;
@@ -2081,9 +2079,7 @@ public event EventHandler? DefaultCellStyleChanged
private static SolidBrush DefaultForeBrush => (SolidBrush)SystemBrushes.WindowText;
-#pragma warning disable WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
- private static Color DefaultGridColor => ControlSystemColors.Current.WindowFrame;
-#pragma warning restore WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
+ private static Color DefaultGridColor => SystemColors.WindowFrame;
private static SolidBrush DefaultHeadersBackBrush => (SolidBrush)SystemBrushes.Control;
diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/DateTimePicker/DateTimePicker.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/DateTimePicker/DateTimePicker.cs
index cdfd7bd8828..bf84d656761 100644
--- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/DateTimePicker/DateTimePicker.cs
+++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/DateTimePicker/DateTimePicker.cs
@@ -25,24 +25,22 @@ public partial class DateTimePicker : Control
///
/// Specifies the default title back color. This field is read-only.
///
-#pragma warning disable WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
- protected static readonly Color DefaultTitleBackColor = ControlSystemColors.Current.ActiveCaption;
+ protected static readonly Color DefaultTitleBackColor = SystemColors.ActiveCaption;
///
/// Specifies the default foreground color. This field is read-only.
///
- protected static readonly Color DefaultTitleForeColor = ControlSystemColors.Current.ActiveCaptionText;
+ protected static readonly Color DefaultTitleForeColor = SystemColors.ActiveCaptionText;
///
/// Specifies the default month background color. This field is read-only.
///
- protected static readonly Color DefaultMonthBackColor = ControlSystemColors.Current.Window;
+ protected static readonly Color DefaultMonthBackColor = SystemColors.Window;
///
/// Specifies the default trailing foreground color. This field is read-only.
///
- protected static readonly Color DefaultTrailingForeColor = ControlSystemColors.Current.GrayText;
-#pragma warning restore WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
+ protected static readonly Color DefaultTrailingForeColor = SystemColors.GrayText;
private static readonly object s_formatChangedEvent = new();
diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ListView/ListView.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ListView/ListView.cs
index 77c00b186c6..b31d65c23a2 100644
--- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ListView/ListView.cs
+++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ListView/ListView.cs
@@ -103,10 +103,8 @@ public partial class ListView : Control
// Owner draw data caches... Only valid inside WM_PAINT.
-#pragma warning disable WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
- private Color _odCacheForeColor = ControlSystemColors.Current.WindowText;
- private Color _odCacheBackColor = ControlSystemColors.Current.Window;
-#pragma warning restore WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
+ private Color _odCacheForeColor = SystemColors.WindowText;
+ private Color _odCacheBackColor = SystemColors.Window;
private Font _odCacheFont;
private HFONT _odCacheFontHandle;
private FontHandleWrapper? _odCacheFontHandleWrapper;
@@ -355,9 +353,7 @@ public override Color BackColor
}
else
{
-#pragma warning disable WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
return SystemColors.Window;
-#pragma warning restore WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
}
}
set
@@ -857,9 +853,7 @@ public override Color ForeColor
}
else
{
-#pragma warning disable WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
return SystemColors.WindowText;
-#pragma warning restore WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
}
}
set
@@ -2896,7 +2890,6 @@ private unsafe void CustomDraw(ref Message m)
// (adding 1 will overflow), else add 1 to it. If the color component is 0,
// skip it and go to the next color (unless it is our last option).
-#pragma warning disable WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
if (nmcd->clrText == ColorTranslator.ToWin32(SystemColors.HotTrack))
{
int totalshift = 0;
@@ -2934,7 +2927,6 @@ private unsafe void CustomDraw(ref Message m)
}
while (!clrAdjusted);
}
-#pragma warning restore WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
if (!haveRenderInfo || riBack.IsEmpty)
{
diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/MonthCalendar/MonthCalendar.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/MonthCalendar/MonthCalendar.cs
index f90b273ea6b..1ec9bdd4f16 100644
--- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/MonthCalendar/MonthCalendar.cs
+++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/MonthCalendar/MonthCalendar.cs
@@ -59,12 +59,10 @@ namespace System.Windows.Forms;
[SRDescription(nameof(SR.DescriptionMonthCalendar))]
public partial class MonthCalendar : Control
{
-#pragma warning disable WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
- private static readonly Color s_defaultTitleBackColor = ControlSystemColors.Current.ActiveCaption;
- private static readonly Color s_defaultTitleForeColor = ControlSystemColors.Current.ActiveCaptionText;
- private static readonly Color s_trailingForeColor = ControlSystemColors.Current.GrayText;
+ private static readonly Color s_defaultTitleBackColor = SystemColors.ActiveCaption;
+ private static readonly Color s_defaultTitleForeColor = SystemColors.ActiveCaptionText;
+ private static readonly Color s_trailingForeColor = SystemColors.GrayText;
private const int MonthsInYear = 12;
-#pragma warning restore WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
///
/// This is the arbitrary number of pixels that the Win32 control
diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ProgressBar/ProgressBar.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ProgressBar/ProgressBar.cs
index 02cba39fa91..ee4d29bc2ec 100644
--- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ProgressBar/ProgressBar.cs
+++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ProgressBar/ProgressBar.cs
@@ -25,9 +25,7 @@ public partial class ProgressBar : Control
private int _marqueeAnimationSpeed = 100;
-#pragma warning disable WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
- private static readonly Color s_defaultForeColor = ControlSystemColors.Current.Highlight;
-#pragma warning restore WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
+ private static readonly Color s_defaultForeColor = SystemColors.Highlight;
private ProgressBarStyle _style = ProgressBarStyle.Blocks;
diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGrid.SnappableControl.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGrid.SnappableControl.cs
index ed3724a52c3..932e84aff75 100644
--- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGrid.SnappableControl.cs
+++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGrid.SnappableControl.cs
@@ -32,9 +32,7 @@ protected override void OnControlAdded(ControlEventArgs ce)
{
}
-#pragma warning disable WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
- public Color BorderColor { get; set; } = ControlSystemColors.Current.ControlDark;
-#pragma warning restore WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
+ public Color BorderColor { get; set; } = SystemColors.ControlDark;
protected override void OnPaint(PaintEventArgs e)
{
diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGrid.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGrid.cs
index a460f2e9cf5..7517f47c2d0 100644
--- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGrid.cs
+++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGrid.cs
@@ -71,18 +71,16 @@ public partial class PropertyGrid : ContainerControl, IComPropertyBrowser, IProp
private int _paintFrozen;
-#pragma warning disable WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
private Color _lineColor = SystemInformation.HighContrast
- ? ControlSystemColors.Current.ControlDarkDark
- : ControlSystemColors.Current.InactiveBorder;
-
- private Color _categoryForegroundColor = ControlSystemColors.Current.ControlText;
- private Color _categorySplitterColor = ControlSystemColors.Current.Control;
- private Color _viewBorderColor = ControlSystemColors.Current.ControlDark;
- private Color _selectedItemWithFocusForeColor = ControlSystemColors.Current.HighlightText;
- private Color _selectedItemWithFocusBackColor = ControlSystemColors.Current.Highlight;
+ ? SystemColors.ControlDarkDark
+ : SystemColors.InactiveBorder;
+
+ private Color _categoryForegroundColor = SystemColors.ControlText;
+ private Color _categorySplitterColor = SystemColors.Control;
+ private Color _viewBorderColor = SystemColors.ControlDark;
+ private Color _selectedItemWithFocusForeColor = SystemColors.HighlightText;
+ private Color _selectedItemWithFocusBackColor = SystemColors.Highlight;
private bool _canShowVisualStyleGlyphs = true;
-#pragma warning restore WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
private AttributeCollection? _browsableAttributes;
@@ -218,10 +216,8 @@ public PropertyGrid()
_helpPane.TabStop = false;
_helpPane.Dock = DockStyle.None;
-#pragma warning disable WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
_helpPane.BackColor = SystemColors.Control;
_helpPane.ForeColor = SystemColors.ControlText;
-#pragma warning restore WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
_helpPane.MouseMove += OnChildMouseMove;
_helpPane.MouseDown += OnChildMouseDown;
@@ -3704,10 +3700,8 @@ private bool TryGetSavedTabIndex(out int selectedTabIndex)
return true;
}
-#pragma warning disable WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
private void SetHotCommandColors()
=> _commandsPane.SetColors(SystemColors.Control, SystemColors.ControlText, Color.Empty, Color.Empty, Color.Empty, Color.Empty);
-#pragma warning restore WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
internal void SetStatusBox(string? title, string? description) => _helpPane.SetDescription(title, description);
diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/DropDownButton.DropDownButtonAdapter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/DropDownButton.DropDownButtonAdapter.cs
index df50e90eaee..52c7f2da1bf 100644
--- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/DropDownButton.DropDownButtonAdapter.cs
+++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/DropDownButton.DropDownButtonAdapter.cs
@@ -15,8 +15,7 @@ internal DropDownButtonAdapter(ButtonBase control) : base(control) { }
private void DDB_Draw3DBorder(PaintEventArgs e, Rectangle r, bool raised)
{
-#pragma warning disable WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
- if (Control.BackColor != ControlSystemColors.Current.Control && SystemInformation.HighContrast)
+ if (Control.BackColor != SystemColors.Control && SystemInformation.HighContrast)
{
if (raised)
{
@@ -62,7 +61,6 @@ private void DDB_Draw3DBorder(PaintEventArgs e, Rectangle r, bool raised)
ControlPaint.DrawBorderSimple(e, r, ControlPaint.Dark(Control.BackColor));
}
}
-#pragma warning restore WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
}
internal override void PaintUp(PaintEventArgs pevent, CheckState state)
@@ -74,9 +72,7 @@ internal override void PaintUp(PaintEventArgs pevent, CheckState state)
}
else
{
-#pragma warning disable WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
- Color c = (ARGB)ControlSystemColors.Current.Window;
-#pragma warning restore WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
+ Color c = (ARGB)SystemColors.Window;
Rectangle rect = Control.ClientRectangle;
rect.Inflate(0, -1);
ControlPaint.DrawBorder(
@@ -92,9 +88,7 @@ internal override void DrawImageCore(Graphics graphics, Image image, Rectangle i
{
bool isHighContrastHighlighted = !Control.MouseIsDown && IsHighContrastHighlighted();
-#pragma warning disable WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
- Color backgroundColor = isHighContrastHighlighted ? ControlSystemColors.Current.Highlight : Control.BackColor;
-#pragma warning restore WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
+ Color backgroundColor = isHighContrastHighlighted ? SystemColors.Highlight : Control.BackColor;
if (ControlPaint.IsDark(backgroundColor) && image is Bitmap bitmap)
{
diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/TabControl/TabControl.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/TabControl/TabControl.cs
index 9f81f0b676b..736949c70af 100644
--- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/TabControl/TabControl.cs
+++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/TabControl/TabControl.cs
@@ -83,6 +83,9 @@ public TabControl()
_tabCollection = new TabPageCollection(this);
SetStyle(ControlStyles.UserPaint, false);
+#pragma warning disable WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
+ SetStyle(ControlStyles.ApplyThemingImplicitly, true);
+#pragma warning restore WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
}
///
@@ -171,9 +174,7 @@ public override Color BackColor
// The tab control can only be rendered in 1 color: System's Control color.
// So, always return this value... otherwise, we're inheriting the forms BackColor
// and passing it on to the pab pages.
-#pragma warning disable WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
return SystemColors.Control;
-#pragma warning restore WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
}
set
{
diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/TabControl/TabPage.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/TabControl/TabPage.cs
index 8f4d9a7d944..d599441e755 100644
--- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/TabControl/TabPage.cs
+++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/TabControl/TabPage.cs
@@ -35,6 +35,9 @@ public partial class TabPage : Panel
public TabPage() : base()
{
SetStyle(ControlStyles.CacheText, true);
+#pragma warning disable WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
+ SetStyle(ControlStyles.ApplyThemingImplicitly, true);
+#pragma warning restore WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
Text = null;
}
@@ -102,6 +105,7 @@ public override Color BackColor
{
return color;
}
+
else if (!Application.IsDarkModeEnabled
&& Application.RenderWithVisualStyles
&& UseVisualStyleBackColor
diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ToolStrips/ToolStripComboBox.ToolStripComboBoxControl.ToolStripComboBoxFlatComboAdapter.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ToolStrips/ToolStripComboBox.ToolStripComboBoxControl.ToolStripComboBoxFlatComboAdapter.cs
index cef396a5ac2..da96be6fc91 100644
--- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ToolStrips/ToolStripComboBox.ToolStripComboBoxControl.ToolStripComboBoxFlatComboAdapter.cs
+++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ToolStrips/ToolStripComboBox.ToolStripComboBoxControl.ToolStripComboBoxFlatComboAdapter.cs
@@ -45,8 +45,7 @@ protected override Color GetOuterBorderColor(ComboBox comboBox)
return base.GetOuterBorderColor(comboBox);
}
-#pragma warning disable WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
- return (comboBox.Enabled) ? ControlSystemColors.Current.Window : GetColorTable(comboBox as ToolStripComboBoxControl).ComboBoxBorder;
+ return (comboBox.Enabled) ? SystemColors.Window : GetColorTable(comboBox as ToolStripComboBoxControl).ComboBoxBorder;
}
protected override Color GetPopupOuterBorderColor(ComboBox comboBox, bool focused)
@@ -58,14 +57,13 @@ protected override Color GetPopupOuterBorderColor(ComboBox comboBox, bool focuse
if (!comboBox.Enabled)
{
- return ControlSystemColors.Current.ControlDark;
+ return SystemColors.ControlDark;
}
return focused
? GetColorTable(comboBox as ToolStripComboBoxControl).ComboBoxBorder
- : ControlSystemColors.Current.Window;
+ : SystemColors.Window;
}
-#pragma warning restore WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
protected override void DrawFlatComboDropDown(ComboBox comboBox, Graphics g, Rectangle dropDownRect)
{
diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ToolStrips/ToolStripMenuItem.cs b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ToolStrips/ToolStripMenuItem.cs
index a543c205e75..f1488042327 100644
--- a/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ToolStrips/ToolStripMenuItem.cs
+++ b/src/System.Windows.Forms/src/System/Windows/Forms/Controls/ToolStrips/ToolStripMenuItem.cs
@@ -728,9 +728,7 @@ private unsafe bool GetNativeMenuItemEnabled()
g.DrawRectangle(SystemPens.Control, 0, 0, image.Width - 1, image.Height - 1);
}
-#pragma warning disable WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
- image.MakeTransparent(ControlSystemColors.Current.Control);
-#pragma warning restore WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
+ image.MakeTransparent(SystemColors.Control);
return image;
}
@@ -966,7 +964,6 @@ protected override void OnOwnerChanged(EventArgs e)
base.OnOwnerChanged(e);
}
-#pragma warning disable WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
protected override void OnPaint(PaintEventArgs e)
{
if (Owner is null)
@@ -978,7 +975,7 @@ protected override void OnPaint(PaintEventArgs e)
Graphics g = e.Graphics;
renderer.DrawMenuItemBackground(new ToolStripItemRenderEventArgs(g, this));
- Color textColor = ControlSystemColors.Current.MenuText;
+ Color textColor = SystemColors.MenuText;
if (IsForeColorSet)
{
textColor = ForeColor;
@@ -987,11 +984,11 @@ protected override void OnPaint(PaintEventArgs e)
{
if (Selected || Pressed)
{
- textColor = ControlSystemColors.Current.HighlightText;
+ textColor = SystemColors.HighlightText;
}
else
{
- textColor = ControlSystemColors.Current.MenuText;
+ textColor = SystemColors.MenuText;
}
}
@@ -1033,8 +1030,8 @@ protected override void OnPaint(PaintEventArgs e)
if (HasDropDownItems)
{
ArrowDirection arrowDir = (rightToLeft) ? ArrowDirection.Left : ArrowDirection.Right;
- Color arrowColor = (Selected || Pressed) ? ControlSystemColors.Current.HighlightText : ControlSystemColors.Current.MenuText;
- arrowColor = (Enabled) ? arrowColor : ControlSystemColors.Current.ControlDark;
+ Color arrowColor = (Selected || Pressed) ? SystemColors.HighlightText : SystemColors.MenuText;
+ arrowColor = (Enabled) ? arrowColor : SystemColors.ControlDark;
renderer.DrawArrow(new ToolStripArrowRenderEventArgs(g, this, menuItemInternalLayout.ArrowRectangle, arrowColor, arrowDir));
}
@@ -1057,7 +1054,6 @@ protected override void OnPaint(PaintEventArgs e)
}
}
}
-#pragma warning restore WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
protected internal override bool ProcessCmdKey(ref Message m, Keys keyData)
{
diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DarkProfessionalColors.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DarkProfessionalColors.cs
index d8eacc22b95..cc381f1df76 100644
--- a/src/System.Windows.Forms/src/System/Windows/Forms/DarkProfessionalColors.cs
+++ b/src/System.Windows.Forms/src/System/Windows/Forms/DarkProfessionalColors.cs
@@ -2,11 +2,9 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System.Drawing;
-using static System.Windows.Forms.Control;
namespace System.Windows.Forms
{
-#pragma warning disable WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
internal class DarkProfessionalColors : ProfessionalColorTable
{
public override Color MenuItemPressedGradientBegin
@@ -19,7 +17,7 @@ public override Color MenuItemPressedGradientEnd
=> Color.FromArgb(0xFF, 0x60, 0x60, 0x60);
public override Color MenuItemSelected
- => ControlSystemColors.Current.ControlText;
+ => SystemColors.ControlText;
public override Color MenuItemSelectedGradientBegin
=> Color.FromArgb(0xFF, 0x40, 0x40, 0x40);
@@ -28,28 +26,27 @@ public override Color MenuItemSelectedGradientEnd
=> Color.FromArgb(0xFF, 0x40, 0x40, 0x40);
public override Color MenuStripGradientBegin
- => ControlSystemColors.Current.Control;
+ => SystemColors.Control;
public override Color MenuStripGradientEnd
- => ControlSystemColors.Current.Control;
+ => SystemColors.Control;
public override Color StatusStripGradientBegin
- => ControlSystemColors.Current.Control;
+ => SystemColors.Control;
public override Color StatusStripGradientEnd
- => ControlSystemColors.Current.Control;
+ => SystemColors.Control;
public override Color ToolStripDropDownBackground
- => ControlSystemColors.Current.Control;
+ => SystemColors.Control;
public override Color ImageMarginGradientBegin
- => ControlSystemColors.Current.Control;
+ => SystemColors.Control;
public override Color ImageMarginGradientMiddle
- => ControlSystemColors.Current.Control;
+ => SystemColors.Control;
public override Color ImageMarginGradientEnd
- => ControlSystemColors.Current.Control;
+ => SystemColors.Control;
}
-#pragma warning restore WFO9001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
}
diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/FormCornerPreference.cs b/src/System.Windows.Forms/src/System/Windows/Forms/FormCornerPreference.cs
index 77edb3be1c2..b6b4228c41d 100644
--- a/src/System.Windows.Forms/src/System/Windows/Forms/FormCornerPreference.cs
+++ b/src/System.Windows.Forms/src/System/Windows/Forms/FormCornerPreference.cs
@@ -7,7 +7,7 @@ namespace System.Windows.Forms;
///
/// Specifies the corner preference for a which can be
-/// set using the property.
+/// set using the property.
///
public enum FormCornerPreference
{