Form

GPALMenuBar, GPALToolbar and GPALBarItem

Everything on Settings Every Control Takes applies here too. GPAL.MenuBar builds a menu bar and GPAL.Toolbar a toolbar. WithMenu starts a top level menu on a menu bar, and every WithItem after it goes under that menu until the next WithMenu. WithItem adds a GPALBarItem, and WithSeparator draws a dividing line between items. A toolbar takes WithItem and WithSeparator the same way, without the menus. A GPALBarItem is built from GPAL.BarItem, carries its own WithText, WithShortcutKey and callback, and its Enabled property greys one item while the rest of the bar stays usable.

NOTE

A menu that changes shape is one a user has to learn twice. Disabling leaves the command where it was, so its absence is a state rather than a mystery.

Examples

GPAL Fluent: High-level fluent C# API

//The same GPALBarItem can go on a menu and a toolbar, so a Save on both is one item and one handler.

GPALBarItem save = (GPALBarItem)GPAL.BarItem

.WithText("Save")

.WithShortcutKey(Keys.Control | Keys.S)

.WithCallback<EventHandler>(SaveClicked)

.WithName("menuSave");


GPALBarItem exit = (GPALBarItem)GPAL.BarItem

.WithText("Exit")

.WithCallback<EventHandler>((s, e) => myForm.Hide())

.WithName("menuExit");


GPALMenuBar menu = (GPALMenuBar)GPAL.MenuBar

.WithMenu("File")

.WithItem(save)

.WithSeparator()

.WithItem(exit)

.WithName("mainMenu");


save.Enabled = false; // nothing to save yet

💬 Ask GPAL