forked from dotnet/winforms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The fix introduced in dotnet#4525 has redirected the `PropertyGrid` value rendering through a different code path which only relies on flags passed into `DrawTextInternal` completely side-stepping any modifications applied to the `Graphics` object. However the `PropertyGrid` value rendering routines do modify the `Graphics` object (applying clipping and transformations) but do not pass the necessary flags to `DrawTextInternal`. Fix by applying the necessary flags to preserve the `Graphics` modifications, and add debug-time asserts to check that necessary flags are applies, if the underlying `Graphics` object is modified. Fixes dotnet#4593 (cherry picked from commit 34cdcf6)
- Loading branch information
Showing
8 changed files
with
97 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 0 additions & 29 deletions
29
src/System.Windows.Forms/tests/UnitTests/PropertyGridInternal/PropertyGridViewTests.cs
This file was deleted.
Oops, something went wrong.
File renamed without changes.
67 changes: 67 additions & 0 deletions
67
...ts/UnitTests/System/Windows/Forms/PropertyGridInternal/PropertyGridViewTests.Rendering.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Drawing; | ||
using System.Windows.Forms.Metafiles; | ||
using System.Windows.Forms.PropertyGridInternal; | ||
using Xunit; | ||
|
||
namespace System.Windows.Forms.Tests | ||
{ | ||
public partial class PropertyGridViewTests | ||
{ | ||
[WinFormsFact] | ||
public void PropertyGridView_Render_Labels_Values_Correctly() | ||
{ | ||
Point pt = default(Point); | ||
using PropertyGrid propertyGrid = new() | ||
{ | ||
SelectedObject = pt, | ||
Size = new(300, 200), | ||
Visible = true | ||
}; | ||
|
||
PropertyGridView propertyGridView = propertyGrid.TestAccessor().GridView; | ||
|
||
// For us to be able to render PropertyGridView and its values | ||
// PropertyGrid must be visible and have a valid handle. | ||
// To be Visible is must either be visible (we don't want this in tests) or | ||
// have no parent - so we can't add it to another control (such as a form). | ||
propertyGrid.CreateControl(); | ||
|
||
using var emf = new EmfScope(); | ||
DeviceContextState state = new(emf); | ||
|
||
propertyGridView.PrintToMetafile(emf); | ||
|
||
// Only care about text: labels and values | ||
emf.Validate( | ||
state, | ||
|
||
// Category: Misc | ||
Validate.SkipTo( | ||
Validate.TextOut("Misc", new(25, 4, 25, 14), stateValidators: State.FontFace(Control.DefaultFont.Name))), | ||
|
||
// Value for "X" | ||
Validate.SkipTo( | ||
Validate.TextOut(" ", new(145, 22, 5, 14))), // blank?? | ||
Validate.SkipTo( | ||
Validate.TextOut(pt.X.ToString(), new(145, 22, 5, 14), stateValidators: State.FontFace(Control.DefaultFont.Name))), | ||
// Label for "X" | ||
Validate.SkipTo( | ||
Validate.TextOut(nameof(Point.X), new(25, 23, 6, 14), stateValidators: State.FontFace(Control.DefaultFont.Name))), | ||
|
||
// Value for "Y" | ||
Validate.SkipTo( | ||
Validate.TextOut(" ", new(145, 41, 5, 14))), // blank?? | ||
Validate.SkipTo( | ||
Validate.TextOut(pt.Y.ToString(), new(145, 41, 5, 14), stateValidators: State.FontFace(Control.DefaultFont.Name))), | ||
// Label for "Y" | ||
Validate.SkipTo( | ||
Validate.TextOut(nameof(Point.Y), new(25, 42, 6, 14), stateValidators: State.FontFace(Control.DefaultFont.Name))), | ||
|
||
Validate.SkipAll()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters