-
Notifications
You must be signed in to change notification settings - Fork 1k
Add judgement "IsDarkModeEnabled" for FocusForeColor of the CheckedListBox and PropertyGrid #13771
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
base: main
Are you sure you want to change the base?
Conversation
…stBox and PropertyGrid
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.
Pull Request Overview
This PR improves the visual accessibility of CheckedListBox and PropertyGrid controls in dark mode by adjusting their focus foreground colors to provide better contrast.
- Updates focus foreground color logic to be dark mode-aware
- Changes color selection from always using SystemColors.HighlightText to conditionally using SystemColors.ControlText in dark mode
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
PropertyGrid.cs | Updates _selectedItemWithFocusForeColor field initialization to use dark mode-aware color selection |
CheckedListBox.cs | Updates foreColor assignment in OnDrawItem method to use dark mode-aware color selection |
@@ -74,7 +74,9 @@ public partial class PropertyGrid : ContainerControl, IComPropertyBrowser, IProp | |||
private Color _categoryForegroundColor = SystemColors.ControlText; | |||
private Color _categorySplitterColor = SystemColors.Control; | |||
private Color _viewBorderColor = SystemColors.ControlDark; | |||
private Color _selectedItemWithFocusForeColor = SystemColors.HighlightText; | |||
#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 Color _selectedItemWithFocusForeColor = Application.IsDarkModeEnabled ? SystemColors.ControlText : SystemColors.HighlightText; |
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.
The Application.IsDarkModeEnabled property is evaluated at field initialization time, which means the color won't update if dark mode is toggled during runtime. Consider evaluating this condition when the color is actually used instead of at initialization.
private Color _selectedItemWithFocusForeColor = Application.IsDarkModeEnabled ? SystemColors.ControlText : SystemColors.HighlightText; | |
private Color SelectedItemWithFocusForeColor | |
{ | |
get => Application.IsDarkModeEnabled ? SystemColors.ControlText : SystemColors.HighlightText; | |
} |
Copilot uses AI. Check for mistakes.
@@ -596,7 +596,9 @@ protected override void OnDrawItem(DrawItemEventArgs e) | |||
if (Enabled) | |||
{ | |||
backColor = SystemColors.Highlight; | |||
foreColor = SystemColors.HighlightText; | |||
#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. | |||
foreColor = Application.IsDarkModeEnabled ? SystemColors.ControlText : SystemColors.HighlightText; |
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.
The Application.IsDarkModeEnabled property is evaluated on every draw operation, which could impact performance. Consider caching this value or evaluating it only when the theme changes.
Copilot uses AI. Check for mistakes.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #13771 +/- ##
===================================================
+ Coverage 75.81239% 76.97766% +1.16527%
===================================================
Files 3266 3266
Lines 644057 644057
Branches 47638 47640 +2
===================================================
+ Hits 488275 495780 +7505
+ Misses 146556 144599 -1957
+ Partials 9226 3678 -5548
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
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.
All LGTM!
Fixes #13767
Proposed changes
IsDarkModeEnabled
forFocusForeColor
of the CheckedListBox and PropertyGridCustomer Impact
Regression?
Risk
Screenshots
Before
When the application is in Dark Mode, the contrast of focusing items in CheckedListBox/PropertyGrid is insufficient.
After
The contrast of focusing items in CheckedListBox/PropertyGrid is sufficient
Test methodology
Test environment(s)
Microsoft Reviewers: Open in CodeFlow