ComponentFactory.Krypton.Toolkit.ViewDrawCanvas.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");

            // Do we need to draw the background?
            if (_drawCanvas &&(_paletteBack.GetBackDraw(State) == InheritBool.True))
            {
                GraphicsPath borderPath;
                Padding borderPadding;

                // Ask the border renderer for a path that encloses the border
                if (DrawTabBorder)
                {
                    borderPath = context.Renderer.RenderTabBorder.GetTabBackPath(context, ClientRectangle, _paletteBorder, Orientation, State, TabBorderStyle);
                    borderPadding = Padding.Empty;
                }
                else
                {
                    borderPath = context.Renderer.RenderStandardBorder.GetBackPath(context, ClientRectangle, _paletteBorder, Orientation, State);
                    borderPadding = context.Renderer.RenderStandardBorder.GetBorderRawPadding(_paletteBorder, State, Orientation);
                }

                // Apply the padding depending on the orientation
                Rectangle enclosingRect = CommonHelper.ApplyPadding(_orientation, ClientRectangle, borderPadding);

                // Render the background inside the border path
                _mementoBack = context.Renderer.RenderStandardBack.DrawBack(context, enclosingRect, borderPath, _paletteBack, _orientation, State, _mementoBack);

                borderPath.Dispose();
            }

            if (_drawCanvas && (_paletteBorder != null))
            {
                // Do we draw the border before the children?
                if (!DrawBorderLast)
                    RenderBorder(context);
                else
                {
                    // Drawing border afterwards, and so clip children to prevent drawing
                    // over the corners if they are rounded.  We only clip children if the
                    // border is drawn afterwards.

                    // Remember the current clipping region
                    _clipRegion = context.Graphics.Clip.Clone();

                    GraphicsPath borderPath;

                    // Restrict the clipping to the area inside the canvas border
                    if (DrawTabBorder)
                        borderPath = context.Renderer.RenderTabBorder.GetTabBorderPath(context, ClientRectangle, _paletteBorder, Orientation, State, TabBorderStyle);
                    else
                        borderPath = context.Renderer.RenderStandardBorder.GetBorderPath(context, ClientRectangle, _paletteBorder, Orientation, State);

                    // Create a new region the same as the existing clipping region
                    Region combineRegion = new Region(borderPath);

                    // Reduce clipping region down by our border path
                    combineRegion.Intersect(_clipRegion);
                    context.Graphics.Clip = combineRegion;

                    borderPath.Dispose();
                }
            }
        }