Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions src/System.Windows.Forms/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
override System.Windows.Forms.StatusStrip.DisplayRectangle.get -> System.Drawing.Rectangle
static System.Windows.Forms.Application.SetColorMode(System.Windows.Forms.SystemColorMode systemColorMode) -> void
static System.Windows.Forms.TaskDialog.ShowDialogAsync(nint hwndOwner, System.Windows.Forms.TaskDialogPage! page, System.Windows.Forms.TaskDialogStartupLocation startupLocation = System.Windows.Forms.TaskDialogStartupLocation.CenterOwner) -> System.Threading.Tasks.Task<System.Windows.Forms.TaskDialogButton!>!
static System.Windows.Forms.TaskDialog.ShowDialogAsync(System.Windows.Forms.IWin32Window! owner, System.Windows.Forms.TaskDialogPage! page, System.Windows.Forms.TaskDialogStartupLocation startupLocation = System.Windows.Forms.TaskDialogStartupLocation.CenterOwner) -> System.Threading.Tasks.Task<System.Windows.Forms.TaskDialogButton!>!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ protected override void SetDisplayedItems()
Rectangle lastItemBounds = Rectangle.Empty;

ToolStripItem? lastItem = null;
const double HideIntersectionRatioThreshold = 0.5;
for (int i = 0; i < Items.Count; i++)
{
ToolStripItem item = Items[i];
Expand All @@ -387,9 +388,36 @@ protected override void SetDisplayedItems()
// visible.
if (overflow || ((IArrangedElement)item).ParticipatesInLayout)
{
if (overflow || (SizingGrip && item.Bounds.IntersectsWith(SizeGripBounds)))
bool hide = false;

// Check for collisions with SizingGrip when SizingGrip is enabled.
if (!SizeGripBounds.IsEmpty)
{
Rectangle itemBounds = item.Bounds;

if (itemBounds.IntersectsWith(SizeGripBounds))
{
Rectangle intersect = Rectangle.Intersect(itemBounds, SizeGripBounds);
double itemArea = Math.Max(1, itemBounds.Width * itemBounds.Height);
double intersectArea = Math.Max(0, intersect.Width * intersect.Height);
double ratio = intersectArea / itemArea;

// Only hide intersections when the intersection ratio exceeds a threshold,
// otherwise, slight overlap is allowed.
if (ratio >= HideIntersectionRatioThreshold)
{
hide = true;
}
}
}

if (overflow)
{
hide = true;
}

if (hide)
{
// if the item collides with the size grip, set the location to nomansland.
SetItemLocation(item, noMansLand);
item.SetPlacement(ToolStripItemPlacement.None);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,7 @@ static ToolStripItem CreateStatusStripItem()
return new ToolStripStatusLabel()
{
AutoSize = false,
Size = new Size(50, 25)
Size = new Size(40, 25)
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void StatusStrip_Ctor_Default()
Assert.False(control.DesignMode);
Assert.Empty(control.DisplayedItems);
Assert.Same(control.DisplayedItems, control.DisplayedItems);
Assert.Equal(new Rectangle(1, 0, 185, 22), control.DisplayRectangle);
Assert.Equal(new Rectangle(1, 0, 173, 22), control.DisplayRectangle);
Assert.Equal(DockStyle.Bottom, control.Dock);
Assert.NotNull(control.DockPadding);
Assert.Same(control.DockPadding, control.DockPadding);
Expand Down Expand Up @@ -108,7 +108,7 @@ public void StatusStrip_Ctor_Default()
Assert.Equal(Point.Empty, control.Location);
Assert.Equal(Padding.Empty, control.Margin);
Assert.Equal(Size.Empty, control.MaximumSize);
Assert.Equal(new Size(185, 22), control.MaxItemSize);
Assert.Equal(new Size(173, 22), control.MaxItemSize);
Assert.Equal(Size.Empty, control.MinimumSize);
Assert.Equal(Orientation.Horizontal, control.Orientation);
Assert.NotNull(control.OverflowButton);
Expand Down
Loading