-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Scale errorProvider Icon to DeviceDPI #12947
Scale errorProvider Icon to DeviceDPI #12947
Conversation
src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider/ErrorProvider.cs
Outdated
Show resolved
Hide resolved
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #12947 +/- ##
===================================================
+ Coverage 76.07479% 76.10553% +0.03074%
===================================================
Files 3255 3275 +20
Lines 642151 643806 +1655
Branches 47295 47449 +154
===================================================
+ Hits 488515 489972 +1457
- Misses 150083 150273 +190
- Partials 3553 3561 +8
Flags with carried forward coverage won't be shown. Click here to find out more. |
@Tanya-Solyanik The fix has been tested passed, please review the PR. |
src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider/ErrorProvider.cs
Outdated
Show resolved
Hide resolved
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.
Please use the existing wrapper. In general, it is a good idea to look for other API usages in the codebase to see if there might be existing patterns that can be leveraged.
src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider/ErrorProvider.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider/ErrorProvider.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider/ErrorProvider.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider/ErrorProvider.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider/ErrorProvider.cs
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider/ErrorProvider.ErrorWindow.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider/ErrorProvider.IconRegion.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider/ErrorProvider.IconRegion.cs
Outdated
Show resolved
Hide resolved
d7a20d3
to
3d08357
Compare
…een for the first time, add the CurrentDpi property in the ErrorProvider class
src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/ScaleHelper.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider/ErrorProvider.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider/ErrorProvider.ErrorWindow.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider/ErrorProvider.cs
Outdated
Show resolved
Hide resolved
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.
@LeafShi1 Awesome! This looks a lot cleaner. :) Thank you!
src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider/ErrorProvider.cs
Outdated
Show resolved
Hide resolved
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.
Awesome! Message me directly when your back ports are ready, and I'll go over them.
/backport to release/9.0 |
Started backporting to release/9.0: https://github.com/dotnet/winforms/actions/runs/13669469329 |
@LeafShi1 backporting to release/9.0 failed, the patch most likely resulted in conflicts: $ git am --3way --ignore-whitespace --keep-non-patch changes.patch
Applying: Scale errorProvider Icon to DeviceDPI
Applying: Scale IconRegion according to currentDpi
Applying: Add _parentControl is null judgment
Applying: Add _initialLoad
Applying: Remove unused codeline
Applying: Replcase PInvoke.GetSystemMetricsForDpi with PInvoke.GetCurrentSystemMetrics
Applying: Scale icon in IconRegion class
error: sha1 information is lacking or useless (src/System.Windows.Forms/src/System/Windows/Forms/ErrorProvider/ErrorProvider.IconRegion.cs).
error: could not build fake ancestor
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0007 Scale icon in IconRegion class
Error: The process '/usr/bin/git' failed with exit code 128 Please backport manually! |
<!-- Please read CONTRIBUTING.md before submitting a pull request --> Fixes dotnet#12939 ## Proposed changes - Scale errorProvider Icon to DeviceDPI <!-- We are in TELL-MODE the following section must be completed --> ## Customer Impact - The icon of errorProvider can be scaled well on HDPI screen ## Regression? - Yes ## Risk - Minimal <!-- end TELL-MODE --> ## Screenshots <!-- Remove this section if PR does not change UI --> ### Before The icon of errorProvider is not scaled well on HDPI screen with SystemAware and PerMoniterV2 modes  ### After The icon of errorProvider can be scaled well on HDPI screen  ## Test methodology <!-- How did you ensure quality? --> - Manually ## Test environment(s) <!-- Remove any that don't apply --> - .net 10.0.0-preview.2.25111.15 <!-- Mention language, UI scaling, or anything else that might be relevant --> ###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/dotnet/winforms/pull/12947)
@JeremyKuhne I backported this PR to release/9.0 and release/8.0, please review them. |
<!-- Please read CONTRIBUTING.md before submitting a pull request --> Fixes dotnet#12939 ## Proposed changes - Scale errorProvider Icon to DeviceDPI <!-- We are in TELL-MODE the following section must be completed --> ## Customer Impact - The icon of errorProvider can be scaled well on HDPI screen ## Regression? - Yes ## Risk - Minimal <!-- end TELL-MODE --> ## Screenshots <!-- Remove this section if PR does not change UI --> ### Before The icon of errorProvider is not scaled well on HDPI screen with SystemAware and PerMoniterV2 modes  ### After The icon of errorProvider can be scaled well on HDPI screen  ## Test methodology <!-- How did you ensure quality? --> - Manually ## Test environment(s) <!-- Remove any that don't apply --> - .net 10.0.0-preview.2.25111.15 <!-- Mention language, UI scaling, or anything else that might be relevant --> ###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/dotnet/winforms/pull/12947)
…2915) <!-- Please read CONTRIBUTING.md before submitting a pull request --> Back port pr #10850 and pr #12947 to release8.0 Fixes #12850 and #12939 ## Bug Description The PR #8486 removed `new Icon(icon, 16 ,16)` from `IconRegion` constructor, that causes the released icon object to be directly referenced, so there is an exception `Cannot access a disposed object. Object name: 'Icon' `. Backport #10850 fixes the above problem, but the PR always scaled `IconRegion` to 100% DPI, so it causes issue #12939: _The icon of errorProvider is not scaled well on HDPI screen_, so backport #12947 to scale the ErrorProvider's `IconRegion` according to the current device DPI. ## Customer Impact - ErrorProvider exception when shown a second time after being dragged on another monitor with different DPI. This regression was reported by the customer. ## Regression? - Yes, it's fine in dotnet 7. This is due to #8486 ## Risk - Low - the fix only change ErrorProvider icon's display size when it run in HDPI screen. ## Testing - Manual testing with the user-provided project. - Automation regression test ###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/dotnet/winforms/pull/12915) --------- Co-authored-by: Ricardo Bossan <ricardobossan@protonmail.com> Co-authored-by: Ricardo Bossan (BEYONDSOFT CONSULTING INC) (from Dev Box) <v-rbossan@microsoft.com>
<!-- Please read CONTRIBUTING.md before submitting a pull request --> BackPort PR #12947 to 9.0 Fixes #12939 ## Proposed changes - Calculate the display size of the ErrorProvide Icon according to the DPI of the current device <!-- We are in TELL-MODE the following section must be completed --> ## Customer Impact - The icon of errorProvider is not scaled well on HDPI screen ## Regression? - Yes. it's fine in dotnet 8. This is due to #10850, the initial loaded size of the ErrorProvider IconRegion is scaled to 100% DPI even on HDPI screens. ## Risk - Low – because the change only change ErrorProvider icon's display size when it run in HDPI screen. <!-- end TELL-MODE --> ## Testing - Manual testing with the user-provided project ###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/dotnet/winforms/pull/13079)
Fixes #12939
Proposed changes
Customer Impact
Regression?
Risk
Screenshots
Before
The icon of errorProvider is not scaled well on HDPI screen with SystemAware and PerMoniterV2 modes
After
The icon of errorProvider can be scaled well on HDPI screen
Test methodology
Test environment(s)
Microsoft Reviewers: Open in CodeFlow