Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1753,12 +1753,19 @@ private PropertyGridToolStripButton CreatePushButton(
EventHandler eventHandler,
bool useRadioButtonRole = false)
{
// ToolStripItem/ToolStripButton bake Margin and the minimum button width from
// ScaleHelper.InitialSystemDpi (the process's startup DPI) at construction time. Re-apply both
// explicitly so a button (re)created after a runtime DPI change reflects the grid's actual current
// DPI; DeviceDpi routes through ToolStripButton's own existing, correct DeviceDpi setter override.
// See https://github.com/dotnet/winforms/issues/8268.
PropertyGridToolStripButton button = new(this, useRadioButtonRole)
{
Text = toolTipText,
AutoToolTip = true,
DisplayStyle = ToolStripItemDisplayStyle.Image,
ImageIndex = imageIndex
ImageIndex = imageIndex,
Margin = ScaleHelper.ScaleToDpi(new Padding(0, 1, 0, 2), DeviceDpi),
DeviceDpi = DeviceDpi
};

button.Click += eventHandler;
Expand Down Expand Up @@ -2106,7 +2113,7 @@ private void EnsureLargeButtons()
ImageSize = s_largeButtonSize
};

if (ScaleHelper.IsScalingRequired)
if (ScaleHelper.IsScalingRequirementMet)
{
AddLargeImage(_alphaBitmap);
AddLargeImage(_categoryBitmap);
Expand Down Expand Up @@ -2140,7 +2147,7 @@ private void EnsureLargeButtons()
}
}

// This method should be called only inside a if (DpiHelper.IsScalingRequired) clause.
// This method should be called only inside a if (ScaleHelper.IsScalingRequirementMet) clause.
private void AddLargeImage(Bitmap? originalBitmap)
{
if (originalBitmap is null)
Expand Down Expand Up @@ -3874,7 +3881,7 @@ private void SetupToolbar(bool fullRebuild)
{
_normalButtonImages?.Dispose();
_normalButtonImages = new ImageList();
if (ScaleHelper.IsScalingRequired)
if (ScaleHelper.IsScalingRequirementMet)
{
_normalButtonImages.ImageSize = s_normalButtonSize;
}
Expand Down Expand Up @@ -4013,6 +4020,9 @@ private void SetupToolbar(bool fullRebuild)

_toolStrip.ImageList = LargeButtons ? _largeButtonImages : _normalButtonImages;

// Covers LargeButtons only (_largeButtonImages isn't ready earlier); a no-op otherwise.
_toolStrip.ImageScalingSize = _toolStrip.ImageList!.ImageSize;

using (SuspendLayoutScope scope = new(_toolStrip))
{
_toolStrip.Items.Clear();
Expand Down