Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

LeafShi1
Copy link
Member

@LeafShi1 LeafShi1 commented Aug 1, 2025

Fixes #13767

Proposed changes

  • Add judgement IsDarkModeEnabled for FocusForeColor of the CheckedListBox and PropertyGrid

Customer Impact

  • The selected item of the control CheckedListBox and PropertyGrid can be show clearly under DarkMode

Regression?

  • No

Risk

  • Minimal

Screenshots

Before

When the application is in Dark Mode, the contrast of focusing items in CheckedListBox/PropertyGrid is insufficient.

Image

After

The contrast of focusing items in CheckedListBox/PropertyGrid is sufficient

image

Test methodology

  • Manually

Test environment(s)

  • .net 10.0.0-preview.7.25373.104
Microsoft Reviewers: Open in CodeFlow

@LeafShi1 LeafShi1 requested a review from a team as a code owner August 1, 2025 09:30
@github-actions github-actions bot added the area-DarkMode Issues relating to Dark Mode feature label Aug 1, 2025
@LeafShi1 LeafShi1 requested review from Copilot and removed request for a team August 1, 2025 09:30
Copy link
Contributor

@Copilot Copilot AI left a 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;
Copy link
Preview

Copilot AI Aug 1, 2025

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.

Suggested change
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;
Copy link
Preview

Copilot AI Aug 1, 2025

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.

Copy link

codecov bot commented Aug 1, 2025

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.97766%. Comparing base (ad9d413) to head (9aac464).

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     
Flag Coverage Δ
Debug 76.97766% <0.00000%> (+1.16527%) ⬆️
integration 18.98862% <0.00000%> (?)
production 51.72165% <0.00000%> (+2.60476%) ⬆️
test 97.42226% <ø> (ø)
unit 49.13041% <0.00000%> (+0.01352%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@ricardobossan ricardobossan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-DarkMode Issues relating to Dark Mode feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dark Mode: Insufficient contrast for focusing items in CheckedListBox/PropertyGrid
2 participants