Diagram for .NET / User's Guide / Shape Factories / Common shape factory features

Common shape factory features

All shape factories share a common set of features implemented by the abstract NShapesFactory class, which is the base class for all types of shape factories. Following is a brief summary: 

 Name
Each shape factory has a name, which is specified by its Name property. The name of the shape factory is used as default title for the library, which can be produced by the factory (see below).
 Shape info and shape count

You can easily obtain the count of distinct shape, which can be produced by the factory with the help of the ShapesCount property.

You can also obtain information about the shape at a specified index with the help of the GetShapeInfo method - returns an instance of the NShapeInfo class.

 Creating a shape

A shape from a shape factory can be created with the help of the CreateShape method. The one and only parameter is the index of the shape which must be created. The following code example creates a pentagram shape:

C#
Copy Code
// create a pentagram 
NBasicShapesFactory factory = new NBasicShapesFactory(document);
NShape shape = factory.CreateShape((int)BasicShapes.Pentagram);
Visual Basic
Copy Code
' create a pentagram 
Dim factory As New NBasicShapesFactory(document)
Dim shape As NShape = factory.CreateShape(BasicShapes.Pentagram)
See Also