ComponentFactory.Krypton.Toolkit.ViewDrawForm.RenderAfter C# (CSharp) Method

RenderAfter() public method

Perform rendering after child elements are rendered.
public RenderAfter ( RenderContext context ) : void
context RenderContext Rendering context.
return void
        public override void RenderAfter(RenderContext context)
        {
            // Do we have a status strip to try and merge?
            if (_statusStrip != null)
            {
                // Is the status strip using the global renderer?
                if (_statusStrip.RenderMode == ToolStripRenderMode.ManagerRenderMode)
                {
                    // Cast to correct type
                    KryptonForm form = context.Control as KryptonForm;

                    if (form != null)
                    {
                        // Find the size of the borders around the form
                        Padding borders = form.RealWindowBorders;

                        // Grab the global renderer to use for painting
                        ToolStripRenderer renderer = ToolStripManager.Renderer;

                        // Size the render strip to the apparent size when merged into borders
                        _renderStrip.Width = form.Width;
                        _renderStrip.Height = _statusStrip.Height + borders.Bottom;

                        // Find vertical start of the status strip
                        int y = _statusStrip.Top + borders.Top;

                        try
                        {
                            // We need to transform downwards from drawing at 0,0 to actual required position
                            context.Graphics.TranslateTransform(0, y);

                            // Use the tool strip renderer to draw the correct status strip border/background
                            renderer.DrawToolStripBorder(new ToolStripRenderEventArgs(context.Graphics, _renderStrip));
                            renderer.DrawToolStripBackground(new ToolStripRenderEventArgs(context.Graphics, _renderStrip));
                        }
                        finally
                        {
                            // Make sure that even a crash in the renderer does not prevent the transform reversal
                            context.Graphics.TranslateTransform(0, -y);
                        }
                    }
                }
            }

            // Finally we let the border be drawn
            base.RenderAfter(context);
        }