.NET Customisation
User Guide
.NET Customisation
:
How to Write a CAF Addin
: Addin Commands
Addin Commands
User access to an Addin's functionality is typically accessed via context menus and tools grouped on a command ribbon. In common with most Windows applications, the CAF provides an interactive interface via the CommandBarManager for the creation and customisation of menus and ribbon groups and the various types of tool that they can contain. The CAF offers a mechanism for publishing the capabilities of the Addin to the CommandBarManager for this purpose, namely the Command object. The Command is a C# class that provides this interface for the CommandBarManager, and also provides a standard communication channel between the user interface and the Addin for the execution of the command and the feedback of state such as "enabled", "visible" and "checked". This is therefore a good mechanism for keeping the requirements of the user interface separate from the definition of the Addin itself. The code of the Command objects provides part of the formal interface of the "GUI Manager" component of the Addin as described in
The IAddin Interface
.
For historical reasons the CAF also support a traditional event style interface where the programmer provides event handlers to respond to the various events generated as a result of user interaction with the user interface. However this traditional approach to user interface development, although still supported by the CAF, is not recommended. There are known issues with this older approach, not least being an incompatibility with newer user interface styles such as command ribbons. It should also be noted here that old style tool bars are themselves not compatible with command ribbons. Thus any Addin that needs to be deployed with older style menus/command bars as well as newer style command ribbons should avoid the use of free standing tool bars. The Administration module uses older style menus/command bars.
When the user interacts with the CommandBarManager to build or customise menus, command bars or ribbon groups and their tools, the result is stored in a "User Interface Customisation" (UIC) file. This is a XML file containing the definitions of the menus, commandbars and their contents including the values of their various properties. Details of how to create these UIC files will be covered later in this manual. The UIC file provides the link between the user interface and the Command objects for the Addin. The UIC definition is loaded at start-up and the links to the Addin Commands are then created using the services of the Command Manager. Selection of the menu entry or clicking on the button will then cause the associated command to be executed.
One of the advantages of a command based model is that it forces the decoupling of the user interface or presentation layer from the application logic. The application logic has no direct reference to the presentation layer entities. If application state needs to be reflected in the user interface then the application modifies the state of the command. The command knows which user interface entities are associated with it and takes the necessary steps to make sure that its internal state is reflected in the user interface. This is easily achieved for state such as "enabled", "visible" or "checked", but becomes complex when dynamic application state needs to be reflected in user interface entities such as a combo-box.
1974 to current year.
AVEVA Solutions Limited and its subsidiaries. All rights reserved.