private void RedoLayout()
{
if(Orientation == Orientation.Vertical)
{
int h = Layout.StackVertically(Margin, Controls);
if(AutoSize)
{
Height = h;
Width = Controls.Select(c => c.X + c.Width).Max();
}
}
else
{
int w = Layout.StackHorizontally(Margin, Controls);
if(AutoSize)
{
Width = w;
Height = Controls.Select(c => c.Y + c.Height).Max();
}
}
}