Commands and Command Bars Manager
In This Topic
Commands are used to facilitate the implementation of any diagram user action, which can be performed from a menu, toolbar or context menu. The diagram commands implementation is not bound to the Nevron User Interface, which makes it possible to reuse them with other UI suites. All diagram commands derive from the base NDiagramCommand class. Diagram commands can, in general, be classified as follows:
- Button Commands - these are commands, which are performed on single button click events. They implement the INDiagramButtonCommand interface, a core implementation of which can be found in the NDiagramButtonCommand class.
- Check Button Commands - these are button commands, which have a checked state. They implement the INDiagramCheckButtonCommand interface, a core implementation of which can be found in the NDiagramCheckButtonCommand class.
- Combo Box Commands - these are commands, which are visually represented as a combo box and can be used to perform an operation, which can accept several options. They implement the INDiagramComboCommand interface a core implementation of which can be found in the NDiagramComboCommand class.
- Menu Commands - these are commands, which can host several other commands and are usually displayed in menus. They implement the INDiagramMenuCommand interface a core implementation of which can be found in the NDiagramMenuCommand class.
- Option Menu Commands - these are menu commands, the items of which are the options from which the user can select. They implement the INDiagramOptionMenuCommand interface a core implementation of which can be found in the NDiagramOptionMenuCommand class.
Based on the operation they perform, commands are also grouped in ranges. The command ranges currently available are enumerated by the DiagramCommandRange enumeration. The commands currently implemented are enumerated by the DiagramCommand enumeration. It is important to remember that each diagram command has an id and range (exposed by the Id and RangeId properties).
Diagram Commander
The diagram commander (hereafter referred to as commander) is represented by an instance of the NDiagramCommander class. It serves as a bridge between the Nevron User Interface and the diagram commands. The commander maintains a collection of diagram commands, which is accessible from its Commands property. Initially it contains all currently implemented commands. Currently the commander can be used to control the following controls:
-
View - the controlled view is specified by the
View property
-
Statusbar - the controlled statusbar is specified by the
StatusBar property
-
Property Browser - the controlled property browser is specified by the
PropertyBrowser property
-
Library Browser - the controlled library browser is specified by the
LibraryBrowser property
Diagram Command Bars Manager
The diagram command bars manager (hereafter referred to as manager) is a component, which is represented by the NDiagramCommandBarsManager class. The manager contains a commander, which is accessible from its Commander property. It also exposes the same set of control properties as the commander and naturally delegates the set implementations to the contained commander. In this way the logic behind all commands is wrapped inside the commander and the diagram commands.
The manager derives from the Nevron UI NCommandBarsManager class and, as such, is responsible for populating it with Nevron UI command contexts and command ranges. The command ranges and command contexts are recreated by Recreate method. The ranges are initialized with the values of the DiagramCommandRange enumeration, while the command contexts are populated with the Nevron UI representation of the diagram commands. The Recreate method also rebuilds the main menu and the docking toolbars.
The main menu, docking toolbars and context menu building is performed by several replaceable parts of the manager, which are responsible to create command context instances (Nevron UI commands) and that is why they are called command builders. All command builders derive from the base NCommandBuilder class. Currently available are the following command builders:
-
Main Menu Builder - it is represented by the
NDiagramMainMenuBuilder class, an instance of which can be obtained from the
MainMenuBuilder property of the manager. You can use it to control the commands which appear in the main menu.
-
Toolbars Builder - it is represented by the
NDiagramToolbarsBuilder class, an instance of which can be obtained from the
ToolbarsBuilder property of the manager. You can use it to control the commands which appear in the toolbars.
-
Context Menu Builder - it is represented by the
NDiagramContextMenuBuilder class, an instance of which can be obtained from the
ContextMenuBuilder property of the manager. You can use it to control the commands which appear in context menus.
Related Examples
Windows Forms: Visual Interface Components - Command Bars
Windows Forms: Visual Interface Components - Context Menu
See Also