ComponentFactory.Krypton.Ribbon.ViewDrawRibbonScrollButton.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)
        {
            // Create a border offset down and right for drawing a shadow
            Rectangle shadowRect = ClientRectangle;
            shadowRect.X++;
            shadowRect.Y++;

            // Reduce background to fit inside the border
            Rectangle backRect = ClientRectangle;
            backRect.Inflate(-1, -1);

            // Create border paths
            using (GraphicsPath borderPath = CreateBorderPath(ClientRectangle),
                                shadowPath = CreateBorderPath(shadowRect))
            {
                // Are we allowed to draw a border?
                if (_ribbon.StateCommon.RibbonScroller.PaletteBorder.GetBorderDraw(State) == InheritBool.True)
                {
                    // Draw the border shadow
                    using (AntiAlias aa = new AntiAlias(context.Graphics))
                       using (SolidBrush shadowBrush = new SolidBrush(Color.FromArgb(16, Color.Black)))
                            context.Graphics.FillPath(shadowBrush, shadowPath);
                }

                // Are we allowed to draw a background?
                if (_ribbon.StateCommon.RibbonScroller.PaletteBack.GetBackDraw(State) == InheritBool.True)
                {
                    _mementoBack = context.Renderer.RenderStandardBack.DrawBack(context, backRect, borderPath,
                                                                                _ribbon.StateCommon.RibbonScroller.PaletteBack,
                                                                                VisualOrientation.Top,State, _mementoBack);
                }

                // Are we allowed to draw the content?
                if (_ribbon.StateCommon.RibbonScroller.PaletteContent.GetContentDraw(State) == InheritBool.True)
                {
                    // Get the text color from palette
                    Color textColor = _ribbon.StateCommon.RibbonScroller.PaletteContent.GetContentShortTextColor1(State);

                    // Draw the arrow content in center of the background
                    DrawArrow(context.Graphics, textColor, backRect);
                }

                // Are we allowed to draw border?
                if (_ribbon.StateCommon.RibbonScroller.PaletteBorder.GetBorderDraw(State) == InheritBool.True)
                {
                    // Get the border color from palette
                    Color borderColor = _ribbon.StateCommon.RibbonScroller.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);
                }
            }
        }