The MonoDevelop toolbox provides a palette of items that the user can choose to insert into their current document. While originally intended for use in GUI designer, it can also be used for text snippets.
There are three ways that components can be provided to the toolbox: loaders, providers, and dynamic providers.
The toolbox loader extension point can be used to register classes that can scan an assembly (or metadata file) for toolbox items. The user can select assemblies or metadata files to be scanned in the component selector dialog, when choosing which components are to be visible in the toolbox.
This is implemented by registering a class that implements MonoDevelop.DesignerSupport.Toolbox.IToolboxLoader to the /MonoDevelop/DesignerSupport/ToolboxLoaders extension path. Since scanning assemblies is computationally expensive, MonoDevelop automatically maintains an index/cache of toolbox scan results.
This extension point should be used for providing global toolbox items that can be added to any applicable project. Adding one of these components to a project should automatically add any relevant assembly references needed.
The Toolbox Providers extension point is used to provide items that are included in the toolbox by default. It can provide a set of toolbox nodes, or a list of assembly/metadata files to be scanned by the toolbox loaders.
This is implemented by registering a class that implements MonoDevelop.DesignerSupport.Toolbox.IToolboxDefaultProvider to the /MonoDevelop/DesignerSupport/ToolboxProviders extension path.
The dynamic toolbox provider provides changeable toolbox items specific to the document. This may include things like clipboard snippets, or components defined in referenced projects. Since projects are changeable, so these may be updated on-the-fly via the parser service.
This is implemented by registering a class that implements MonoDevelop.DesignerSupport.Toolbox.IToolboxDynamicProvider to the /MonoDevelop/DesignerSupport/ToolboxProviders extension path, or implemeting this interface on the ViewContent or a TextEditorExtension.
Internally, the toolbox is a collection of objects that derive fromMonoDevelop.DesignerSupport.Toolbox .ItemToolboxNode. These subclasses must be registered with the MonoDevelop serialisation infrastructure.
Nodes expose a description, category, name, and icon. Of particular interest are the members that can be overridden:
There are several useful variants already implemented:
The ITextToolboxNode interface can be implemented on any toolbox node to make it visible to the text editor. This allows creating, for example, designer toolbox items that can also emit text. It has the following members:
A ViewContent or TextEditorExtension must implement MonoDevelop.DesignerSupport.Toolbox.IToolboxConsumer in order to be able to consume toolbox items. It has several members:
The interface MonoDevelop.DesignerSupport.Toolbox.ICustomFilteringToolboxConsumer may be implemented instead to fully override filtering of toolbox nodes; it adds one member:
The toolbox contains a store of all loaded toolbox nodes, and when the active toolbox consumer changes, it uses filters to generate a set of nodes for that consumer.
Each toolbox node contains a collection of .NEt/Mono ToolboxFilter attributes. In the case of nodes that are generated from .NET/Mono types, these attributes are extracted from the type; they can be applied multiple times to the type. The filter contains a string and a ToolboxItemFilterType.{Require, Prevent, Allow, Custom} value. These filters are compared between the node and the consumer. The item will be shown if the following rules hold:
In addition, a toolbox consumer can use ICustomFilteringToolboxConsumer to override this filtering fully.
A generic toolbox loader that scans .NET/Mono assemblies out-of-process for the System.ComponentModel.ToolboxItemAttribute. It should provide a further extension point that can be used to define how the attributes are treated when they are encountered. By unifying the ToolboxItemAttribute-based loaders, the scanning time for multiple loaders will be greatly reduced.
| Images 0 | ||
|---|---|---|
| No images to display in the gallery. |