protected override void RefreshControlPositions()
{
if (this.ManagedControl == null)
return;
int totalWhiteSpace = BorderSize * 2 + (ColumnCount - 1) * HorizontalGapSize;
int columnWidth = (ManagedControl.Width - totalWhiteSpace) / ColumnCount;
int currentColumn = 1;
int currentLeft = BorderSize;
int currentTop = BorderSize;
int maxControlHeight = 0;
try
{
this.ManagedControl.SuspendLayout();
foreach (var control in this.ManagedControl.Controls.OfType<IControlHabanero>())
{
if (currentColumn > ColumnCount)
{
currentColumn = 1;
currentLeft = BorderSize;
currentTop += maxControlHeight + VerticalGapSize;
maxControlHeight = 0;
}
if (control.Height > maxControlHeight)
{
maxControlHeight = control.Height;
}
control.Location = new Point(currentLeft, currentTop);
control.Width = columnWidth;
currentLeft += columnWidth + HorizontalGapSize;
currentColumn++;
}
}
finally
{
this.ManagedControl.ResumeLayout(true);
}
}