ComponentFactory.Krypton.Toolkit.KryptonOffice2013Renderer.OnRenderArrow C# (CSharp) Method

OnRenderArrow() protected method

Raises the RenderArrow event.
protected OnRenderArrow ( System.Windows.Forms.ToolStripArrowRenderEventArgs e ) : void
e System.Windows.Forms.ToolStripArrowRenderEventArgs An ToolStripArrowRenderEventArgs containing the event data.
return void
        protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e)
        {
            // Cannot paint a zero sized area
            if ((e.ArrowRectangle.Width > 0) &&
                (e.ArrowRectangle.Height > 0))
            {
                // Create a path that is used to fill the arrow
                using (GraphicsPath arrowPath = CreateArrowPath(e.Item,
                                                                e.ArrowRectangle,
                                                                e.Direction))
                {
                    // Get the rectangle that encloses the arrow and expand slightly
                    // so that the gradient is always within the expanding bounds
                    RectangleF boundsF = arrowPath.GetBounds();
                    boundsF.Inflate(1f, 1f);

                    // Set correct color of the arrow
                    Color color1;
                    Color color2;
                    if (!e.Item.Enabled)
                    {
                        color1 = _disabled;
                        color2 = _disabled;
                    }
                    else
                    {
                        if (e.Item.Pressed || e.Item.Selected || (e.Item is ToolStripMenuItem))
                            color1 = KCT.MenuItemText;
                        else
                            color1 = KCT.ToolStripText;

                        color2 = CommonHelper.WhitenColor(color1, 0.7f, 0.7f, 0.7f);
                    }

                    float angle = 0;

                    // Use gradient angle to match the arrow direction
                    switch (e.Direction)
                    {
                        case ArrowDirection.Right:
                            angle = 0;
                            break;
                        case ArrowDirection.Left:
                            angle = 180f;
                            break;
                        case ArrowDirection.Down:
                            angle = 90f;
                            break;
                        case ArrowDirection.Up:
                            angle = 270f;
                            break;
                    }

                    // Draw the actual arrow using a gradient
                    using (LinearGradientBrush arrowBrush = new LinearGradientBrush(boundsF, color1, color2, angle))
                        e.Graphics.FillPath(arrowBrush, arrowPath);
                }
            }
        }