internal override Size GetPreferredSizeCore (Size proposedSize)
{
Size retsize = Size.Empty;
foreach (Control child in Controls) {
Size child_preferred_size;
if (child.AutoSize)
child_preferred_size = child.PreferredSize;
else
child_preferred_size = child.ExplicitBounds.Size;
int child_right = child.Bounds.X + child_preferred_size.Width;
int child_bottom = child.Bounds.Y + child_preferred_size.Height;
if (child.Dock == DockStyle.Fill) {
if (child_right > retsize.Width)
retsize.Width = child_right;
}
else if (child.Dock != DockStyle.Top && child.Dock != DockStyle.Bottom && child_right > retsize.Width)
retsize.Width = child_right + child.Margin.Right;
if (child.Dock == DockStyle.Fill) {
if (child_bottom > retsize.Height)
retsize.Height = child_bottom;
}
else if (child.Dock != DockStyle.Left && child.Dock != DockStyle.Right && child_bottom > retsize.Height)
retsize.Height = child_bottom + child.Margin.Bottom;
}
if (retsize == Size.Empty) { // no child controls
retsize.Height += this.Padding.Top;
retsize.Width += this.Padding.Left;
}
retsize.Height += this.Padding.Bottom;
retsize.Width += this.Padding.Right;
return SizeFromClientSize (retsize);
}