Skip to content
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

Dark mode - amended concept for SystemColors issue. #2

Draft
wants to merge 38 commits into
base: DarkMode
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
9d3ce22
First draft of DarkMode implementation.
KlausLoeffelmann Aug 23, 2022
7a9e211
First draft of Darkmode for ToolStrips.
KlausLoeffelmann Aug 30, 2022
004cf35
Fix merge issues.
KlausLoeffelmann Jul 17, 2023
9588909
Implement Form title bar coloring and
KlausLoeffelmann Mar 2, 2024
5211d8f
Implement DarkMode color table and replace SystemColors by dynamic co…
KlausLoeffelmann Mar 3, 2024
bd7a4d1
Correct Formatting/Merge issues.
KlausLoeffelmann Mar 4, 2024
d4c6a8b
Fix rendering ListView ColumnHeaders in wrong text color in dark mode.
KlausLoeffelmann Mar 3, 2024
810b7bb
Added more XML comments and refactored the IsDarkModeEnabled logic a …
KlausLoeffelmann Mar 5, 2024
974463d
Update unshipped API list.
KlausLoeffelmann Mar 5, 2024
bab9030
* Enable GroupBox...
KlausLoeffelmann Mar 6, 2024
01841a9
Handle DarkMode ProgressBar.
KlausLoeffelmann Mar 18, 2024
0970fb9
Ensure that IsDarkModeEnabled always returns a valid result.
KlausLoeffelmann Mar 26, 2024
f0bde1d
Fixing merge issues.
KlausLoeffelmann Jun 22, 2024
0f0cf64
Introduce DefaultVisualStyleMode.
KlausLoeffelmann Jun 22, 2024
974a2e7
Introduce VisualStylesMode as ambient property on Control.
KlausLoeffelmann Jun 23, 2024
a62187c
Update XML comments and Description attribute resources for new prope…
KlausLoeffelmann Jun 23, 2024
cca5111
Introduce VisualStylesModeCore.
KlausLoeffelmann Jun 24, 2024
586845e
Revert "Introduce VisualStylesModeCore."
KlausLoeffelmann Jun 24, 2024
f27de2c
Fix usage of DefaultVisualStylesMode.
KlausLoeffelmann Jun 24, 2024
9dc06fa
Update PublicAPI.
KlausLoeffelmann Jun 24, 2024
0b3b145
First implementation of setting new NCClient area in TextBox for taki…
KlausLoeffelmann Jun 24, 2024
e06994b
Add better VisualStylesMode validation.
KlausLoeffelmann Jun 25, 2024
481ba2e
Rename Application.SystemColors to Application.ApplicationColors.
KlausLoeffelmann Jun 25, 2024
3a61e41
Minimize exceptions for control dark mode theming.
KlausLoeffelmann Jun 25, 2024
296a117
First draft of non-client painting of TextBoxBase adorners.
KlausLoeffelmann Jun 26, 2024
65b421d
Update logic for vertically aligning a single line TextBox and taking…
KlausLoeffelmann Jun 27, 2024
09440e6
Update TextBox adorner rendering.
KlausLoeffelmann Jun 29, 2024
dff3dcd
Address additional property combination for rendering.
KlausLoeffelmann Jul 8, 2024
156f2eb
Add first version of modern CheckBox renderer.
KlausLoeffelmann Jul 9, 2024
81392d2
Fix some renderer issues.
KlausLoeffelmann Jul 9, 2024
566ee2e
Add ToggleSwitch animation.
KlausLoeffelmann Jul 11, 2024
b626afb
Introduce Experimental feature WFO9000 - VisualStylesMode.
KlausLoeffelmann Jul 12, 2024
285a322
Introduce Experimental Feature WFO9001 - DarkMode.
KlausLoeffelmann Jul 12, 2024
2a9d9dc
Edge case bugfixing:
KlausLoeffelmann Jul 12, 2024
0bb3a0c
Fix CheckBox ToggleSwitch animation issue.
KlausLoeffelmann Jul 15, 2024
79915c3
Introduce APIs for customizing TextBoxBase adorner painting.
KlausLoeffelmann Jul 16, 2024
ed54d97
Address freview feedback.
KlausLoeffelmann Jul 17, 2024
6fdbf1f
First draft of new concept.
KlausLoeffelmann Jul 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case
dotnet_sort_system_directives_first = true

# Expression-level preferences
dotnet_style_object_initializer = true:warning
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_null_propagation = true:warning
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:error
dotnet_style_null_propagation = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_prefer_auto_properties = true:silent
dotnet_style_prefer_simplified_boolean_expressions = true:warning
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_compound_assignment = true:suggestion
Expand Down Expand Up @@ -319,6 +319,9 @@ dotnet_diagnostic.CA5397.severity = warning

# RS0041: Public members should not use oblivious types
dotnet_diagnostic.RS0041.severity = warning
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
dotnet_style_prefer_conditional_expression_over_return = true:silent

# C# files

Expand Down Expand Up @@ -497,6 +500,12 @@ dotnet_diagnostic.CA2016.severity = warning
# CA2020: Prevent behavioral change caused by built-in operators of IntPtr/UIntPtr
dotnet_diagnostic.CA2020.severity = warning

# WFO9000:
dotnet_diagnostic.WFO9000.severity = silent

# WFO9001:
dotnet_diagnostic.WFO9001.severity = silent

# .NET diagnostic
dotnet_diagnostic.RS0041.severity = none
dotnet_diagnostic.IDE0005.severity = error
Expand Down Expand Up @@ -532,9 +541,9 @@ csharp_preserve_single_line_blocks = true
csharp_preserve_single_line_statements = false

# Expression-bodied members
csharp_style_expression_bodied_methods = true:silent
csharp_style_expression_bodied_constructors = true:silent
csharp_style_expression_bodied_operators = true:silent
csharp_style_expression_bodied_methods = false:silent
csharp_style_expression_bodied_constructors = false:silent
csharp_style_expression_bodied_operators = false:silent
csharp_style_expression_bodied_properties = true:silent
csharp_style_expression_bodied_indexers = true:silent
csharp_style_expression_bodied_accessors = true:silent
Expand Down Expand Up @@ -572,12 +581,12 @@ csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses = false
csharp_space_between_square_brackets = false
csharp_using_directive_placement = outside_namespace:silent
csharp_prefer_simple_using_statement = true:warning
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_braces = true:silent
csharp_style_namespace_declarations = file_scoped:silent
csharp_style_namespace_declarations = block_scoped:silent
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_prefer_primary_constructors = true:silent
csharp_style_prefer_primary_constructors = true:suggestion
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent
csharp_style_allow_embedded_statements_on_same_line_experimental = true:silent
Expand All @@ -586,6 +595,7 @@ csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimenta
csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true:silent
csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true:silent
csharp_style_deconstructed_variable_declaration = true:suggestion
csharp_prefer_system_threading_lock = true:suggestion

# Visual Basic files

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AssemblyName>Microsoft.VisualBasic.Forms</AssemblyName>
<Deterministic>true</Deterministic>
<RootNamespace></RootNamespace>
<LangVersion>15.0</LangVersion>
<LangVersion>15.5</LangVersion>
<VBRuntime>None</VBRuntime>
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
<UsePublicApiAnalyzers>true</UsePublicApiAnalyzers>
Expand Down
5 changes: 5 additions & 0 deletions src/System.Private.Windows.Core/src/NativeMethods.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ CreateDIBSection
CreateFontIndirect
CreateICW
CreateRectRgn
CreateRoundRectRgn
DeleteDC
DeleteObject
DestroyIcon
Expand Down Expand Up @@ -57,6 +58,7 @@ E_OUTOFMEMORY
E_POINTER
E_UNEXPECTED
EncoderParameters
ExtSelectClipRgn
fdex*
FDEX_PROP_FLAGS
FILETIME
Expand Down Expand Up @@ -94,6 +96,7 @@ GetSystemMetrics
GetThreadLocale
GetViewportExtEx
GetViewportOrgEx
GetWindowDC
GlobalAlloc
GlobalFree
GlobalLock
Expand Down Expand Up @@ -142,7 +145,9 @@ MonitorFromWindow
MONITORINFOEXW
MONITORINFOF_*
NONCLIENTMETRICSW
NCCALCSIZE_PARAMS
OBJ_TYPE
OffsetClipRgn
OffsetViewportOrgEx
OLE_E_ADVISENOTSUPPORTED
OLE_E_INVALIDRECT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private unsafe void ActivateDropDown()

try
{
ShowDropDown(listBox, SystemColors.ControlDark);
ShowDropDown(listBox, Drawing.SystemColors.ControlDark);
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected TextBoxPropertyLine(IServiceProvider serviceProvider, DesignerActionPa
_readOnlyTextBoxLabel = new EditorLabel
{
BackColor = Color.Transparent,
ForeColor = SystemColors.WindowText,
ForeColor = Drawing.SystemColors.WindowText,
TabStop = true,
TextAlign = ContentAlignment.TopLeft,
UseMnemonic = false,
Expand Down Expand Up @@ -159,14 +159,14 @@ protected virtual void OnReadOnlyTextBoxLabelClick(object? sender, MouseEventArg

private void OnReadOnlyTextBoxLabelEnter(object? sender, EventArgs e)
{
_readOnlyTextBoxLabel.ForeColor = SystemColors.HighlightText;
_readOnlyTextBoxLabel.BackColor = SystemColors.Highlight;
_readOnlyTextBoxLabel.ForeColor = Drawing.SystemColors.HighlightText;
_readOnlyTextBoxLabel.BackColor = Drawing.SystemColors.Highlight;
}

private void OnReadOnlyTextBoxLabelLeave(object? sender, EventArgs e)
{
_readOnlyTextBoxLabel.ForeColor = SystemColors.WindowText;
_readOnlyTextBoxLabel.BackColor = SystemColors.Window;
_readOnlyTextBoxLabel.ForeColor = Drawing.SystemColors.WindowText;
_readOnlyTextBoxLabel.BackColor = Drawing.SystemColors.Window;
}

protected TypeConverter.StandardValuesCollection? GetStandardValues()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ public DesignerActionPanel(IServiceProvider serviceProvider)
MinimumSize = new Size(150, 0);
}

public Color ActiveLinkColor { get; } = SystemColors.HotTrack;
public Color ActiveLinkColor { get; } = Drawing.SystemColors.HotTrack;

public Color BorderColor { get; } = SystemColors.ActiveBorder;
public Color BorderColor { get; } = Drawing.SystemColors.ActiveBorder;

/// <summary>
/// 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.
Expand Down Expand Up @@ -167,23 +167,23 @@ public DesignerActionPanel(IServiceProvider serviceProvider)
/// </summary>
private Line? FocusedLine => ActiveControl?.Tag as Line;

public Color GradientDarkColor { get; } = SystemColors.Control;
public Color GradientDarkColor { get; } = Drawing.SystemColors.Control;

public Color GradientLightColor { get; } = SystemColors.Control;
public Color GradientLightColor { get; } = Drawing.SystemColors.Control;

public bool InMethodInvoke { get; internal set; }

public Color LinkColor { get; } = SystemColors.HotTrack;
public Color LinkColor { get; } = Drawing.SystemColors.HotTrack;

public Color SeparatorColor { get; } = SystemColors.ControlDark;
public Color SeparatorColor { get; } = Drawing.SystemColors.ControlDark;

public Color TitleBarColor { get; } = SystemColors.ActiveCaption;
public Color TitleBarColor { get; } = Drawing.SystemColors.ActiveCaption;

public Color TitleBarTextColor { get; } = SystemColors.ActiveCaptionText;
public Color TitleBarTextColor { get; } = Drawing.SystemColors.ActiveCaptionText;

public Color TitleBarUnselectedColor { get; } = SystemColors.InactiveCaption;
public Color TitleBarUnselectedColor { get; } = Drawing.SystemColors.InactiveCaption;

public Color LabelForeColor { get; } = SystemColors.ControlText;
public Color LabelForeColor { get; } = Drawing.SystemColors.ControlText;

/// <summary>
/// Helper event so that Lines can be notified of this event.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private Color[] CustomColors
/// <summary>
/// Array of system colors.
/// </summary>
private Color[] SystemColorValues => _systemColorConstants ??= GetConstants(typeof(SystemColors));
private Color[] SystemColorValues => _systemColorConstants ??= GetConstants(typeof(ControlSystemColors));

public object? Value => _value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public virtual void DoPaint(Graphics graphics)
Rectangle inner = _innerRect;
Rectangle outer = _outerRect;
Region oldClip = graphics.Clip;
Color borderColor = SystemColors.Control;
Color borderColor = Drawing.SystemColors.Control;
if (_control is not null && _control.Parent is not null)
{
Control parent = _control.Parent;
Expand Down
5 changes: 5 additions & 0 deletions src/System.Windows.Forms.Primitives/src/NativeMethods.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ DSH_FLAGS
DTM_*
DTN_*
DTS_*
DwmSetWindowAttribute
DWM_WINDOW_CORNER_PREFERENCE
DuplicateHandle
EC_*
ECO_*
Expand Down Expand Up @@ -135,6 +137,7 @@ EXTLOGFONTW
ExtTextOut
FDAP
FillRect
FillRgn
FindExecutable
FINDREPLACE_FLAGS
FindWindow
Expand Down Expand Up @@ -164,6 +167,7 @@ GetClipboardFormatName
GetClipBox
GetClipCursor
GetClipRgn
GetComboBoxInfo
GetCurrentActCtx
GetCurrentObject
GetCurrentProcess
Expand Down Expand Up @@ -600,6 +604,7 @@ SetActiveWindow
SetBkColor
SetBkMode
SetCapture
SetCaretPos
SetCursor
SetCursorPos
SetFocus
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Windows.Win32;

internal static partial class PInvoke
{
/// <inheritdoc cref="FillRgn(HDC, HRGN, HBRUSH)"/>
public static int FillRgn<T>(T hDC, ref HRGN hRgn, HBRUSH hbr)
where T : IHandle<HDC>
{
int result = FillRgn(hDC.Handle, hRgn, hbr);
GC.KeepAlive(hDC.Wrapper);

return result;
}
}
2 changes: 0 additions & 2 deletions src/System.Windows.Forms/src/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9983,8 +9983,6 @@ System.Windows.Forms.TextBoxBase.Modified.set -> void
System.Windows.Forms.TextBoxBase.ModifiedChanged -> System.EventHandler?
System.Windows.Forms.TextBoxBase.MouseClick -> System.Windows.Forms.MouseEventHandler?
System.Windows.Forms.TextBoxBase.MultilineChanged -> System.EventHandler?
System.Windows.Forms.TextBoxBase.Padding.get -> System.Windows.Forms.Padding
System.Windows.Forms.TextBoxBase.Padding.set -> void
System.Windows.Forms.TextBoxBase.PaddingChanged -> System.EventHandler?
System.Windows.Forms.TextBoxBase.Paint -> System.Windows.Forms.PaintEventHandler?
System.Windows.Forms.TextBoxBase.Paste() -> void
Expand Down
Loading