ComponentFactory.Krypton.Toolkit.KryptonOffice2013Renderer.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)
                        {
                            // Ensure we have cached the objects we need
                            UpdateCache();

                            // Do we draw as a menu strip or context menu item?
                            if (e.ToolStrip is MenuStrip)
                                DrawGradientToolItem(e.Graphics, e.Item, _gradientTracking);
                            else
                                DrawGradientContextMenuItem(e.Graphics, e.Item, _gradientTracking);
                        }
                        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))
                            {
                                // Do we draw as a menu strip or context menu item?
                                if (e.ToolStrip is MenuStrip)
                                    DrawGradientToolItem(e.Graphics, e.Item, _disabledItem);
                                else
                                    DrawGradientContextMenuItem(e.Graphics, e.Item, _disabledItem);
                            }
                        }
                    }
                }
            }
            else
            {
                base.OnRenderMenuItemBackground(e);
            }
        }