ComponentFactory.Krypton.Toolkit.ViewDrawMenuColorBlock.RenderBefore C# (CSharp) Method

RenderBefore() public method

Perform rendering before child elements are rendered.
public RenderBefore ( RenderContext context ) : void
context RenderContext Rendering context.
return void
        public override void RenderBefore(RenderContext context)
        {
            Debug.Assert(context != null);

            // Validate incoming reference
            if (context == null) throw new ArgumentNullException("context");

            // Start with the full client rectangle
            Rectangle drawRect = ClientRectangle;

            // Do not draw over the left and right lines
            drawRect.X += 1;
            drawRect.Width -= 2;

            // Do we need to prevent drawing over top line?
            if (_first)
            {
                drawRect.Y += 1;
                drawRect.Height -= 1;
            }

            // Do we need to prevent drawing over last line?
            if (_last)
                drawRect.Height -= 1;

            // Draw ourself in the designated color
            using(SolidBrush brush = new SolidBrush(_color))
                context.Graphics.FillRectangle(brush, drawRect);
        }