public override void Render(RenderContext context)
{
// Clipping area starts as the whole client area
Rectangle clipRectangle = ClientRectangle;
// Do we have a metric source for additional padding?
if (_paletteMetrics != null)
{
// Get the padding to be applied
Padding outerPadding = _paletteMetrics.GetMetricPadding(State, _metricPadding);
// Reduce the clipping area by the padding
clipRectangle = ApplyPadding(clipRectangle, outerPadding);
}
// New clipping region is at most our own client size
using (Region combineRegion = new Region(clipRectangle))
{
// Remember the current clipping region
Region clipRegion = context.Graphics.Clip.Clone();
// Reduce clipping region down by the existing clipping region
combineRegion.Intersect(clipRegion);
// Use new region that restricts drawing to our client size only
context.Graphics.Clip = combineRegion;
// Perform rendering before any children
RenderBefore(context);
// Ask each child to render in turn
foreach (ViewBase child in this)
{
// Only render visible children that are inside the clipping rectangle
if (child.Visible)
child.Render(context);
}
// Perform rendering after that of children
RenderAfter(context);
// Put clipping region back to original setting
context.Graphics.Clip = clipRegion;
}
}