ComponentFactory.Krypton.Toolkit.KryptonSparkleRenderer.OnRenderMenuItemBackground C# (CSharp) Method

OnRenderMenuItemBackground() protected method

Raises the RenderMenuItemBackground event.
protected OnRenderMenuItemBackground ( System.Windows.Forms.ToolStripItemRenderEventArgs e ) : void
e System.Windows.Forms.ToolStripItemRenderEventArgs An ToolStripItemRenderEventArgs containing the event data.
return void
        protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
        {
            if ((e.ToolStrip is MenuStrip) ||
                (e.ToolStrip is ContextMenuStrip) ||
                (e.ToolStrip is ToolStripDropDownMenu))
            {
                if ((e.Item.Pressed) && (e.ToolStrip is MenuStrip))
                {
                    // Draw the menu/tool strip as a header for a context menu item
                    DrawContextMenuHeader(e.Graphics, e.Item);
                }
                else
                {
                    // We only draw a background if the item is selected and enabled
                    if (e.Item.Selected)
                    {
                        if (e.Item.Enabled)
                        {
                            UpdateCache();

                            if (e.ToolStrip is MenuStrip)
                                DrawGradientToolItem(e.Graphics, e.Item, _gradientTracking);
                            else
                                DrawLinearContextMenuItem(e.Graphics, e.Item, _linearItem);
                        }
                        else
                        {
                            // Get the mouse position in tool strip coordinates
                            Point mousePos = e.ToolStrip.PointToClient(Control.MousePosition);

                            // If the mouse is not in the item area, then draw disabled
                            if (!e.Item.Bounds.Contains(mousePos))
                                DrawLinearContextMenuItem(e.Graphics, e.Item, _disabledLinearItem);
                        }
                    }
                }
            }
            else
            {
                base.OnRenderMenuItemBackground(e);
            }
        }