/// <summary> /// Perform a layout of the elements. /// </summary> /// <param name="context">Layout context.</param> public override void Layout(ViewLayoutContext context) { Debug.Assert(context != null); // We take on all the available display area ClientRectangle = context.DisplayRectangle; // Layout depends on orientation switch (Orientation) { case VisualOrientation.Top: context.DisplayRectangle = new Rectangle(ClientLocation.X, ClientRectangle.Bottom - GAP_LENGTH, ClientWidth, GAP_LENGTH); _separator.Layout(context); context.DisplayRectangle = new Rectangle(ClientLocation.X, ClientLocation.Y, ClientWidth, ClientHeight - GAP_LENGTH); _button.Layout(context); break; case VisualOrientation.Bottom: context.DisplayRectangle = new Rectangle(ClientLocation.X, ClientRectangle.Y, ClientWidth, GAP_LENGTH); _separator.Layout(context); context.DisplayRectangle = new Rectangle(ClientLocation.X, ClientLocation.Y + GAP_LENGTH, ClientWidth, ClientHeight - GAP_LENGTH); _button.Layout(context); break; case VisualOrientation.Left: if (_insetForTabs) { ClientRectangle = AdjustRectForTabs(ClientRectangle); } context.DisplayRectangle = new Rectangle(ClientRectangle.Right - GAP_LENGTH, ClientLocation.Y, GAP_LENGTH, ClientHeight); _separator.Layout(context); context.DisplayRectangle = new Rectangle(ClientLocation.X, ClientLocation.Y, ClientWidth - GAP_LENGTH, ClientHeight); _button.Layout(context); break; case VisualOrientation.Right: if (_insetForTabs) { ClientRectangle = AdjustRectForTabs(ClientRectangle); } context.DisplayRectangle = new Rectangle(ClientLocation.X, ClientLocation.Y, GAP_LENGTH, ClientHeight); _separator.Layout(context); context.DisplayRectangle = new Rectangle(ClientLocation.X + GAP_LENGTH, ClientLocation.Y, ClientWidth - GAP_LENGTH, ClientHeight); _button.Layout(context); break; } // Put back the original display rectangle context.DisplayRectangle = ClientRectangle; }