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

                    // Default to disabled
                    Color color1 = _disabled;
                    Color color2 = _disabled;

                    // If not disabled then need to decide on actual colors
                    if (e.Item.Enabled)
                    {
                        // If the arrow is on a context menu
                        if ((e.Item.Owner is ContextMenuStrip) ||
                            (e.Item.Owner is ToolStripDropDownMenu) ||
                            (e.Item.OwnerItem is ToolStripOverflowButton))
                        {
                            if (((e.Item.Owner is ContextMenuStrip) || (e.Item.Owner is ToolStripDropDownMenu)) ||
                                ((e.Item.OwnerItem is ToolStripOverflowButton) && ((e.Item is ToolStripSplitButton) || (e.Item is ToolStripDropDownButton)) && (!e.Item.Selected || e.Item.Pressed)))
                                color1 = KCT.MenuItemText;
                            else
                                color1 = KCT.ToolStripText;

                            color2 = color1;
                        }
                        else
                        {
                            if ((e.Item.Owner is ToolStrip) ||
                                (e.Item.Owner is StatusStrip))
                            {
                                if (((e.Item is ToolStripSplitButton) || (e.Item is ToolStripDropDownButton)) && e.Item.Pressed)
                                    color1 = KCT.MenuItemText;
                                else
                                    color1 = KCT.ToolStripText;

                                color2 = color1;
                            }
                        }
                    }

                    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);
                }
            }
        }