NShape Programmer Tasks
Customizing the Toolbox

<< Click to Display Table of Contents >>

Navigation:  Programmer Tasks >

NShape Programmer Tasks
Customizing the Toolbox

Previous pageReturn to chapter overviewNext page

Typical NShape applications that offer editing functionality use some kind of toolbox for the application's end users where they can switch between the editing tools, e.g. the pointer tool (SelectionTool) and the tools for creating the various shapes (TemplateTools). In most cases, the application works with a predefined set of shape libraries and the user is not able to load additional shape libraries at runtime. So it is a good idea, to customize the user's tool box in order to improve the 'look and feel' of your application by only tools the user wants (or is allowed) to work with. In case the application wants to limit the user's access to the framework's functionality, providing a limited set of predefined shapes is even mandatory (see Programmer Tasks: Controlling User Access).

Before talking about customizing the contents of the user's toolbox, we need to take a quick look at the creation of templates and tools:

NShape is shipped with a set of components providing implementations of toolbox controls (ToolSetListViewPresenter and ToolSetToolStripPresenter) and a ToolSetController component to link these ToolSetPresenters to the rest of the NShape framework, namely the Project component. When opening or creating a project, the ToolSetController automatically creates a TemplateTool for each template in the project's repository and a SelectionTool. All tools in the ToolSetController are displayed by the ToolSetPresenter.

You can customize the contents of the toolbox

a)by enabling/disabling the automatic creation of templates when loading shape libraries.
See "Automatic Template Creation" for more details and example code.

b)by loading a predefined template project that defines all templates for the toolbox.
See "Loading a Template Project" for more details and example code.

c)by filling the toolbox manually in your application with code.
See "Filling the Toolbox Manually" for more details and example code.

See also

Programmer Tasks: Controlling User Access

Programmer Tasks: Customizing Context Menus