public override void Layout(ViewLayoutContext context)
{
Debug.Assert(context != null);
// Validate incoming reference
if (context == null) throw new ArgumentNullException("context");
// We take on all the available display area
ClientRectangle = context.DisplayRectangle;
// Do we have a metric source for additional padding?
if (_paletteMetric != null)
{
// Get the padding to be applied before the canvas drawing
Padding outerPadding = _paletteMetric.GetMetricPadding(State, _metricPadding);
// Apply the padding to the client rectangle
ClientRectangle = CommonHelper.ApplyPadding(Orientation, ClientRectangle, outerPadding);
}
Padding padding;
// Calculate how much space the border takes up
if (DrawTabBorder)
padding = context.Renderer.RenderTabBorder.GetTabBorderDisplayPadding(context, _paletteBorder, State, Orientation, TabBorderStyle);
else
padding = context.Renderer.RenderStandardBorder.GetBorderDisplayPadding(_paletteBorder, State, Orientation);
// Apply the padding to the client rectangle
context.DisplayRectangle = CommonHelper.ApplyPadding(Orientation, ClientRectangle, padding);
// Ensure any content children have correct composition setting
foreach (ViewBase child in this)
if (child is ViewDrawContent)
{
// Do we need to draw the background?
bool drawBackground = _drawCanvas && (_paletteBack.GetBackDraw(State) == InheritBool.True);
// Update the content accordingly
ViewDrawContent viewContent = (ViewDrawContent)child;
viewContent.DrawContentOnComposition = DrawCanvasOnComposition && !drawBackground;
}
// Let child elements layout
base.Layout(context);
// Put back the original display value now we have finished
context.DisplayRectangle = ClientRectangle;
}