HypernovaDesktop Components · docs
Binarymission
WinFormsMenu Item › BinaryMenuItem

BinaryMenuItem

class.NET Framework 4.8Binarymission.WinForms.Controls.MenuControls

BinaryMenuItem provides a feature-packed and extended "Owner-drawn" MenuItem component for building MainMenus and ContextMenus for the Microsoft WinForms© .NET platform.

public class BinaryMenuItem : MenuItem

Inherits from / implements: MenuItem

Remarks

BinaryMenuItem class replaces the standard .NET MenuItem class by providing a pre-OwnerDrawn MenuItem object with built-in rich features for building Menus in your .NET Windows Forms applications.

To build menus for your application with BinaryMenuItem .NET, you just continue to use the standard .NET Menu and ContextMenu controls, and just replace in your code, the use of standard .NET MenuItem object with BinaryMenuItem object, along with the appropriate additional object constructor values.
In addition to the standard .NET framework’s MenuItem functionality, BinaryMenuItem .NET component comes pre-Ownerdrawn and ready-to-use and offers the following rich features:

1. Simplified User-interface rendering: The component comes fully "pre-ownerdrawn", and hence all you need to do is just to set its easy-to-use properties in order to customise your menu rendering!
You do not need to owner-draw the MenuItem object any more! Just set simple properties and run your application.

2. Image support: The component comes with direct support for associating icons with menu items, including a separate image-holder side bar (emulating the VS.NET style)

3. Ability to fully support Menu painting with custom colors (with Alpha-blending support): By setting the simple properties, you can set custom colors for menu background, item selection and hovering, and painting the checkmark and radio buttons (unlike the standard .NET Framework MenuItem object which only lets you display the Radiobutton/CheckMarks in Black color)

4. Direct support for dynamic property changes: The component also comes with built-in support for handling dynamic property changes (for example, your changes to MenuItem colors at runtime) with ease - this feature lets you change the menuitem colors and its alpha-blend factors at run-time.
Note: BinaryMenuItem cannot be loaded into VS.NET toolbox (just like the MenuItem object)!
To reference it, you need to add the object into your Solution Explorer->References!
If you are not using VS.NET, please just copy the Binarymission.BinaryMenuItem.dll into your application's Bin folder (both Debug and Release folders) and in your code, add the following using statement:-
using Binarymission.WinFormControls.MenuControl;
Now you can start using BinaryMenuItem object!

Members at a glance

BinaryMenuItemInitializes a new instance of BinaryMenuItem.
BinaryMenuItemInitializes a new instance of BinaryMenuItem.
BinaryMenuItemInitializes a new instance of BinaryMenuItem.
BinaryMenuItemInitializes a new instance of BinaryMenuItem.
BinaryMenuItemInitializes a new instance of BinaryMenuItem.
GroupHeaderBackColorGets or sets the background color for the menuitem, if this is to be drawn as a group header item, rather than the standard menu item.
GroupHeaderBorderColorGets or sets the color for the group header's border, if the menu item is to be drawn as a group header item, rather than the standard menu item.
GroupHeaderDottedBorderDepthGets or sets the width of each border dot (when drawing the group header as dotted border).
GroupHeaderDottedBorderGapGets or sets the gap between dots (when drawing the group header as dotted border).
GroupHeaderForeColorGets or sets the foreground color for the menuitem, if this is to be drawn as a group header item, rather than the standard menu item.
GroupHeaderGapWithTheBorderGets or sets the gap you want to have between the border and the group header drawing area.
ImageIndexGets or sets the Image index of the Image to be used from the BinaryMenuItem instance's associated ImageList.
ImageListGets or sets the ImageList to be associated with an instance of BinaryMenuItem.
IsGroupHeaderBorderDrawnAsDotsGets or sets as to whether to draw the group header as dots.
IsMenuItemAGroupHeaderGets or sets as to whether the given menu item instance is a group header item.
MenuItemClickHandlerGets or sets the EventHandler to be associated with an instance of BinaryMenuItem.
MenuItemImageGets or sets the image to be associated with an instance of BinaryMenuItem.
ShortcutTextGets or sets the ShortcutText to be associated with an instance of BinaryMenuItem.
TextGets or sets the Text for the Menu item. Refer to the base class documentation for more information.
TransparentColorForImageGets or sets the transparent color for the image associated with an instance of BinaryMenuItem.
OnDrawItemPlease refer to the base class implementation.
OnMeasureItemPlease refer to the base class implementation.
OnSelectPlease refer to the base class implementation.
PrepareCustomColorMatrixA helper method to render this BinaryMenuItem using user supplied colors.

Constructors

BinaryMenuItem

public BinaryMenuItem() : this(null, null, false)

Initializes a new instance of BinaryMenuItem.

BinaryMenuItem

public BinaryMenuItem(string MenuItemText, EventHandler CustomEventHandler, Shortcut ShortCutToAssociate, bool isMenuItemAGroupHeader) : this(MenuItemText, CustomEventHandler, isMenuItemAGroupHeader)

Initializes a new instance of BinaryMenuItem.

MenuItemText
MenuItems's text
CustomEventHandler
The Event handler you want to associate with the BinaryMenuItem instance
ShortCutToAssociate
The Shortcut you want to associate with BinaryMenuItem instance

BinaryMenuItem

public BinaryMenuItem(string MenuItemText, EventHandler CustomEventHandler, Shortcut ShortCutToAssociate, Bitmap Icon, bool isMenuItemAGroupHeader) : this(MenuItemText, CustomEventHandler, isMenuItemAGroupHeader)

Initializes a new instance of BinaryMenuItem.

MenuItemText
MenuItems's text
CustomEventHandler
The Event handler you want to associate with the BinaryMenuItem instance
ShortCutToAssociate
The Shortcut you want to associate with BinaryMenuItem instance
Icon
The Icon (Bitmap) you want to associate with BinaryMenuItem instance, to display it alongside the MenuItem text

BinaryMenuItem

public BinaryMenuItem(string MenuItemText, EventHandler CustomEventHandler, Shortcut ShortCutToAssociate, Bitmap Icon, ImageList ImagelistToAssociate, int ImagelistIndex, bool isMenuItemAGroupHeader) : this(MenuItemText, CustomEventHandler, isMenuItemAGroupHeader)

Initializes a new instance of BinaryMenuItem.

MenuItemText
MenuItems's text
CustomEventHandler
The Event handler you want to associate with the BinaryMenuItem instance
ShortCutToAssociate
The Shortcut you want to associate with BinaryMenuItem instance
Icon
The Icon (Bitmap) you want to associate with BinaryMenuItem instance, to display it alongside the MenuItem text
ImagelistToAssociate
The ImageList you want to associate with BinaryMenuItem instance, to display it alongside the MenuItem text
ImagelistIndex
The Index in the ImageList which points to the Image that needs to be used for this instance of BinaryMenuItem.
There are two ways of specifying the image you want to associate with the BinaryMenuItem instance.
1. By specifying the Bitmap object in the 4th parameter.
2. By specifying an ImageList and an appropriate Index number in that ImageList in parameters 5 and 6 respectively. In either case, you can set the other unused Image parameter to null.

BinaryMenuItem

public BinaryMenuItem(string MenuItemText, EventHandler CustomEventHandler, bool isMenuItemAGroupHeader) : base(MenuItemText, CustomEventHandler)

Initializes a new instance of BinaryMenuItem.

MenuItemText
MenuItem's text
CustomEventHandler
The Event handler you want to associate with the BinaryMenuItem instance
This overloaded constructor can be used if you want the basic MenuItem's appearance (i.e without an associated Image).
But of-course, you can always set the MenuItem's image by setting its MenuItemImage property.

Properties

GroupHeaderBackColor

public Color GroupHeaderBackColor

Gets or sets the background color for the menuitem, if this is to be drawn as a group header item, rather than the standard menu item.

GroupHeaderBorderColor

public Color GroupHeaderBorderColor

Gets or sets the color for the group header's border, if the menu item is to be drawn as a group header item, rather than the standard menu item.

GroupHeaderDottedBorderDepth

public int GroupHeaderDottedBorderDepth

Gets or sets the width of each border dot (when drawing the group header as dotted border).

GroupHeaderDottedBorderGap

public int GroupHeaderDottedBorderGap

Gets or sets the gap between dots (when drawing the group header as dotted border).

GroupHeaderForeColor

public Color GroupHeaderForeColor

Gets or sets the foreground color for the menuitem, if this is to be drawn as a group header item, rather than the standard menu item.

GroupHeaderGapWithTheBorder

public int GroupHeaderGapWithTheBorder

Gets or sets the gap you want to have between the border and the group header drawing area.

ImageIndex

public int ImageIndex

Gets or sets the Image index of the Image to be used from the BinaryMenuItem instance's associated ImageList.

ImageList

public ImageList ImageList

Gets or sets the ImageList to be associated with an instance of BinaryMenuItem.

IsGroupHeaderBorderDrawnAsDots

public bool IsGroupHeaderBorderDrawnAsDots

Gets or sets as to whether to draw the group header as dots.

IsMenuItemAGroupHeader

public bool IsMenuItemAGroupHeader

Gets or sets as to whether the given menu item instance is a group header item.

This will mean that this menu item cannot be clicked / hovered over.

MenuItemClickHandler

public EventHandler MenuItemClickHandler

Gets or sets the EventHandler to be associated with an instance of BinaryMenuItem.

MenuItemImage

public Bitmap MenuItemImage

Gets or sets the image to be associated with an instance of BinaryMenuItem.

ShortcutText

public string ShortcutText

Gets or sets the ShortcutText to be associated with an instance of BinaryMenuItem.

Text

public new string Text

Gets or sets the Text for the Menu item. Refer to the base class documentation for more information.

TransparentColorForImage

public Color TransparentColorForImage

Gets or sets the transparent color for the image associated with an instance of BinaryMenuItem.

Methods

OnDrawItem

protected override void OnDrawItem(DrawItemEventArgs e)

Please refer to the base class implementation.

OnMeasureItem

protected override void OnMeasureItem(MeasureItemEventArgs e)

Please refer to the base class implementation.

OnSelect

protected override void OnSelect(EventArgs e)

Please refer to the base class implementation.

e

PrepareCustomColorMatrix

public void PrepareCustomColorMatrix( Color menuItemBackgroundColor, Color menuItemSelectionColor, Color menuItemControlColor)

A helper method to render this BinaryMenuItem using user supplied colors.

menuItemBackgroundColor
Specify a specific background color to use.
menuItemSelectionColor
Specifiy a specific selection color.
menuItemControlColor
Specify a specific color to draw the side bar in the menu item.