ComponentFactory.Krypton.Ribbon.ViewDrawRibbonGalleryButton.RenderBefore C# (CSharp) Method

RenderBefore() public method

Perform rendering before child elements are rendered.
public RenderBefore ( RenderContext context ) : void
context ComponentFactory.Krypton.Toolkit.RenderContext Rendering context.
return void
        public override void RenderBefore(RenderContext context)
        {
            // Reduce background to fit inside the border
            Rectangle backRect = ClientRectangle;
            backRect.Inflate(-1, -1);

            // If disabled then we need to reflect that immediately
            if (!Enabled)
                ElementState = PaletteState.Disabled;
            else if (ElementState == PaletteState.Disabled)
                ElementState = PaletteState.Normal;

            // Create border paths
            using (GraphicsPath borderPath = CreateBorderPath(ClientRectangle))
            {
                // Are we allowed to draw a background?
                if (_paletteBack.GetBackDraw(State) == InheritBool.True)
                {
                    _mementoBack = context.Renderer.RenderStandardBack.DrawBack(context, backRect, borderPath, _paletteBack,
                                                                                VisualOrientation.Top, State, _mementoBack);
                }

                // Are we allowed to draw the content?
                if (_paletteContent.GetContentDraw(State) == InheritBool.True)
                {
                    context.Renderer.RenderStandardContent.DrawContent(context, ClientRectangle, _paletteContent,
                                                                       _mementoContent, VisualOrientation.Top,
                                                                       State, false, false);
                }

                // Are we allowed to draw border?
                if (_paletteBorder.GetBorderDraw(State) == InheritBool.True)
                {
                    // Get the border color from palette
                    Color borderColor = _paletteBorder.GetBorderColor1(State);

                    // Draw the border last to overlap the background
                    using (AntiAlias aa = new AntiAlias(context.Graphics))
                        using (Pen borderPen = new Pen(borderColor))
                            context.Graphics.DrawPath(borderPen, borderPath);
                }
            }
        }