NShape Programmer Tasks
Automatic Template Creation

<< Click to Display Table of Contents >>

Navigation:  Programmer Tasks > Customizing the Toolbox >

NShape Programmer Tasks
Automatic Template Creation

Previous pageReturn to chapter overviewNext page

To Enable / Disable Automatic Template Creation

The easiest way to customize the contents of your application's toolbox is to disable the automatic creation of templates. The Project component has a AutoCreateTemplates property that specifies whether a template should be created automatically for each ShapeType of the loaded shape library.

1.Select the Project component and set its AutoGenerateTemplates property to false.
ToolBox content with AutoGenerateTemplates enabled.

ToolBox content with AutoGenerateTemplates enabled.

ToolBox content with AutoGenerateTemplates disabled.

ToolBox content with AutoGenerateTemplates disabled.

2.Create a new project and load the shape libraries.

project1.LibrarySearchPaths.Add(Application.StartupPath);
project1.Name = "My NShape Project";
project1.Create();
project1.AddLibraryByFilePath(Path.Combine(Application.StartupPath, "Dataweb.NShape.GeneralShapes.dll"));

3.Create a pointer tool and add it to the ToolSetController. Typically, the pointer tool is added as the "default tool". The default tool is specifies the tool that is selected automatically after another tool was executed.

toolSetController1.AddTool(new PointerTool(), true);

4.Create templates and add them to the repository.

Circle circle = (Circle)project1.ShapeTypes["Circle"].CreateInstance();
// Specify the permission set for all shapes created from this template
circle.SecurityDomainName = 'B';
circle.FillStyle = project1.Design.FillStyles.Red;
circle.LineStyle = project1.Design.LineStyles["MyCustomLineStyle"];
project1.Repository.InsertTemplate(new Template("Circle", circle));

5.Start your application and check the result. Your toolbox should now contain only two items: The pointer tool and a circle.
Customized ToolBox controls with only a pointer tool and a circle.

Customized ToolBox controls with only a pointer tool and a circle.