Menu Item
A drop-in replacement for the classic MenuItem that draws itself: menus with a picture
beside each command, a coloured side bar, check marks and radio dots in colours of your choice, Office
style highlighting, and group headers that divide a long menu into sections.
Assembly
| Assembly | Binarymission.WinForms.Controls.BinaryMenuItem.dll |
| Root namespace | Binarymission.WinForms.Controls.MenuControls |
| Target frameworks | .NET Framework 4.8 |
Overview
Build a MainMenu or ContextMenu exactly as usual, with
BinaryMenuItem objects in place of MenuItem; every item draws itself, so
there is no drawing code to write. Items can be nested, checked, radio-checked, disabled and given
shortcuts as usual. A caption of "-" makes a separator.
Colours
The colours are shared by every item in the application and set on
BinaryMenuItemManager: background, highlight, side bar, border, check mark, and the
theme of the side bar. Each item takes a copy as it is created; after changing them, call
BinaryMenuItemManager.PerformPaint with the form so that items already built pick up the
change. PrepareCustomColorMatrix gives a single item colours of its own.
This class is in the .NET Framework edition only; the classic menu does not exist in .NET 6 and later.
Getting started
using System;
using System.Drawing;
using System.Windows.Forms;
using Binarymission.WinForms.Controls.MenuControls;
public class InvoiceForm : Form
{
public InvoiceForm()
{
BinaryMenuItemManager.MenuRenderingStyle = MenuRenderingStyle.OutlookBlueTheme;
BinaryMenuItem file = new BinaryMenuItem("&File", null, false);
file.MenuItems.Add(new BinaryMenuItem("Recent invoices", null, true));
file.MenuItems.Add(new BinaryMenuItem("INV-20431 - Northwind", OnOpenRecent, false));
file.MenuItems.Add(new BinaryMenuItem("-", null, false));
file.MenuItems.Add(new BinaryMenuItem("&Save", OnSave, Shortcut.CtrlS, Properties.Resources.Save16, false));
file.MenuItems.Add(new BinaryMenuItem("&Print...", OnPrint, Shortcut.CtrlP, Properties.Resources.Print16, false));
Menu = new MainMenu(new MenuItem[] { file });
BinaryMenuItemManager.PerformPaint(this);
}
private void OnOpenRecent(object sender, EventArgs e) { }
private void OnSave(object sender, EventArgs e) { }
private void OnPrint(object sender, EventArgs e) { }
}API reference
Binarymission.WinForms.Controls.MenuControls
class BinaryMenuItem | A drop-in replacement for the classic MenuItem that draws itself: menus with a picture beside each command, a coloured side bar, check marks and radio dots in colours of your choice, Office style highlighting, and group headers that divide a long menu into sections. |
class BinaryMenuItemManager | BinaryMenuItemManager is the property manager class, which lets you set various properties to be applicable across all instances of BinaryMenuItem objects. |
enum MenuItemSelectionColorRenderingStyle | Specifies how a BinaryMenuItem under the pointer is highlighted. |
enum MenuRenderingStyle | Specifies the colour theme of the side bar - the column down the left of a drop-down menu behind the item images and check marks, when it is drawn as a gradient. |
enum MenuSideBarRenderingStyle | Specifies how the side bar - the column down the left of a drop-down menu behind the item images and check marks is filled. |