A command is an object that represents the semantic of an activity. Commands can be assigned to control elements; once the control elements are activated, the command is triggered. Processing is context-sensitive.
A command is an object that represents the semantic of an activity. "Copy" and "Save" are examples of commands.
Commands can be assigned to control elements e.g. to a ribbon button. The command is triggered when the control element is activated. The command needs to be processed once it has been triggered. Processing is context-sensitive. e.g. the Save command is processed differently in a text window compared to how it is processed in a window which contains an image.
A command is described by an object from the ExtCommand type using the following properties.
| Property | Function | Obligatory |
|---|---|---|
| Identifier | Unique, string identifier |
|
| LabelTitle | Command text |
|
| SmallImageSource | Image, size 16x16 | |
| LargeImageSource | Image, size 32x32 | |
| ToolTipText | Tool tip text | |
| ToolTipImageSource | Image in tool tip |
The command can be recognized by its identifier when being processed. This means that it is essential that all identifiers are unique. It is a good idea to use the plug-in name as the prefix of the identifier for plug-ins.
You need to create objects of the ExtCommand type when defining your own commands and register them as a list when editing the OpenModel message using the GUIRegistration.AddCommands method.
See the MID.Innovator.Plugin.Sample.Command sample for defining your own commands.
If the create methods of the RibbonManager class are used when creating a control element then the respective command is transferred as an argument to the create methods. The command's data, such as text, images and tool tips, are adopted from the control element.
Plug-ins can process commands using the class which realizes IApplicationComponent. To do this, the class also has to realize the ICommandDispatchable interface by providing two dispatcher methods:
CanExeCmd
Check the command for executability.
ExecuteCmd
Executes the command.
A row of dispatcher methods are called from the framework when a command is processed:
Framework dispatcher for model-independent commands
Framework dispatcher for model-dependent commands
Current window dispatcher
Dispatcher of all components which realize ICommandDispatchable
If a dispatcher processes a command it then returns true as a result and the row is aborted i.e. processing a command from multiple dispatcher methods is never possible at the same time. A plug-in therefore only needs to return true as a result in its dispatcher methods if it processes the command. Processing should not be confused with executability. Processing is given if a command is checked for executability and executed in certain cases. This is a set property that can never be changed. Executability, on the other hand, is a temporary property that depends on the current state of data in the application.
© 1986-2014 MID GmbH Nuremberg Germany. DIN EN 9001 certified. All rights reserved.