/// <summary> /// Layout the collection of commands. /// </summary> protected void LayoutControl() { // If we are not initializing then... if (_initCount == 0) { // Need to recalculate the layout of commands using defined layout engine Rectangle usedRectangle = _engine.LayoutCommands(_states, _details); // Do we automatically resize to match size of contents? if (EnableAutoSize) { // Increase actual control size by padding area if (Direction == LayoutDirection.Horizontal) { usedRectangle.Width += Padding.Width; usedRectangle.Height += Padding.Height; } else { usedRectangle.Width += Padding.Height; usedRectangle.Height += Padding.Width; } // Apply the needed size according to docking style switch (this.Dock) { case DockStyle.Top: case DockStyle.Bottom: this.Height = usedRectangle.Height; break; case DockStyle.Left: case DockStyle.Right: this.Width = usedRectangle.Width; break; case DockStyle.None: this.Height = usedRectangle.Height; this.Width = usedRectangle.Width; break; } } // Reset need to layout commands _layoutRequired = false; } }