diff --git a/src/System.Windows.Forms.Legacy/System.Windows.Forms.Package/System.Windows.Forms.Package.csproj b/src/System.Windows.Forms.Legacy/System.Windows.Forms.Package/System.Windows.Forms.Package.csproj
index 359cb207ff6..631dca2c65c 100644
--- a/src/System.Windows.Forms.Legacy/System.Windows.Forms.Package/System.Windows.Forms.Package.csproj
+++ b/src/System.Windows.Forms.Legacy/System.Windows.Forms.Package/System.Windows.Forms.Package.csproj
@@ -10,7 +10,7 @@
0.1.0
$(WtgPackageVersionPrefix)-dev
WiseTech Global forked version of System.Windows.Forms that includes controls that were deprecated in .NET Core 3.1 and .NET 5, like DataGrid, Menu, ToolBar and StatusBar.
- Rollback custom binding context support in BindingContext/RelatedCurrencyManager, PR link: https://github.com/WiseTechGlobal/winforms/pull/20
+ Remove IsScalingRequirementMet from DefaultLayout.cs, PR link: https://github.com/WiseTechGlobal/winforms/pull/37
WiseTech Global
© WiseTech Global Limited. All rights reserved.
README.md
diff --git a/src/System.Windows.Forms/System/Windows/Forms/Layout/DefaultLayout.cs b/src/System.Windows.Forms/System/Windows/Forms/Layout/DefaultLayout.cs
index b0b05183a93..395a5b084ca 100644
--- a/src/System.Windows.Forms/System/Windows/Forms/Layout/DefaultLayout.cs
+++ b/src/System.Windows.Forms/System/Windows/Forms/Layout/DefaultLayout.cs
@@ -762,24 +762,12 @@ private static void UpdateAnchorInfo(IArrangedElement element)
AnchorStyles anchor = GetAnchor(element);
if (IsAnchored(anchor, AnchorStyles.Right))
{
- if (ScaleHelper.IsScalingRequirementMet && (anchorInfo.Right - parentWidth > 0) && (oldAnchorInfo.Right < 0))
- {
- // Parent was resized to fit its parent, or screen, we need to reuse old anchors info to prevent losing control beyond right edge.
- anchorInfo.Right = oldAnchorInfo.Right;
- if (!IsAnchored(anchor, AnchorStyles.Left))
- {
- // Control might have been resized, update Left anchors.
- anchorInfo.Left = oldAnchorInfo.Right - cachedBounds.Width;
- }
- }
- else
- {
- anchorInfo.Right -= parentWidth;
+ // This differs from the official WinForms implementation because we encountered an issue with DPI handling. See WI01100144.
+ anchorInfo.Right -= parentWidth;
- if (!IsAnchored(anchor, AnchorStyles.Left))
- {
- anchorInfo.Left -= parentWidth;
- }
+ if (!IsAnchored(anchor, AnchorStyles.Left))
+ {
+ anchorInfo.Left -= parentWidth;
}
}
else if (!IsAnchored(anchor, AnchorStyles.Left))
@@ -790,26 +778,12 @@ private static void UpdateAnchorInfo(IArrangedElement element)
if (IsAnchored(anchor, AnchorStyles.Bottom))
{
- if (ScaleHelper.IsScalingRequirementMet && (anchorInfo.Bottom - parentHeight > 0) && (oldAnchorInfo.Bottom < 0))
- {
- // The parent was resized to fit its parent or the screen, we need to reuse the old anchors info
- // to prevent positioning the control beyond the bottom edge.
- anchorInfo.Bottom = oldAnchorInfo.Bottom;
+ // This differs from the official WinForms implementation because we encountered an issue with DPI handling. See WI01100144.
+ anchorInfo.Bottom -= parentHeight;
- if (!IsAnchored(anchor, AnchorStyles.Top))
- {
- // The control might have been resized, update the Top anchor.
- anchorInfo.Top = oldAnchorInfo.Bottom - cachedBounds.Height;
- }
- }
- else
+ if (!IsAnchored(anchor, AnchorStyles.Top))
{
- anchorInfo.Bottom -= parentHeight;
-
- if (!IsAnchored(anchor, AnchorStyles.Top))
- {
- anchorInfo.Top -= parentHeight;
- }
+ anchorInfo.Top -= parentHeight;
}
}
else if (!IsAnchored(anchor, AnchorStyles.Top))
@@ -1048,19 +1022,19 @@ private static void ApplyCachedBounds(IArrangedElement container)
while (dictionary.Count > 0)
{
#endif
- foreach (DictionaryEntry entry in dictionary)
- {
- IArrangedElement element = (IArrangedElement)entry.Key;
+ foreach (DictionaryEntry entry in dictionary)
+ {
+ IArrangedElement element = (IArrangedElement)entry.Key;
- Debug.Assert(element.Container == container, "We have non-children in our containers cached bounds store.");
+ Debug.Assert(element.Container == container, "We have non-children in our containers cached bounds store.");
#if DEBUG
// We are about to set the bounds to the cached value. We clear the cached value
// before SetBounds because some controls fiddle with the bounds on SetBounds
// and will callback InitLayout with a different bounds and BoundsSpecified.
dictionary.Remove(entry.Key);
#endif
- Rectangle bounds = (Rectangle)entry.Value!;
- element.SetBounds(bounds, BoundsSpecified.None);
+ Rectangle bounds = (Rectangle)entry.Value!;
+ element.SetBounds(bounds, BoundsSpecified.None);
#if DEBUG
break;
}