private void ReLayoutCorrectly()
{
var shrunkWidth = this.mainVerticalLayout.Width;
this.mainVerticalLayout.AutoSize = false;
this.mainVerticalLayout.Width = shrunkWidth;
var heightOfVisibleControls = 0;
foreach (Control control in this.mainVerticalLayout.Controls)
{
if (control.Visible == false)
continue;
heightOfVisibleControls += control.Height;
heightOfVisibleControls += control.Margin.Top;
heightOfVisibleControls += control.Margin.Bottom;
}
this.mainVerticalLayout.Height = heightOfVisibleControls;
}
#endregion