Nevron .NET Vision Documentation

Shapes are aggregate models, which are used to represent objects from the real world, concepts or abstractions. Shapes can be connected with each other and form complex relationships. Shapes are the primary building blocks of diagrams.

In the DOM all types of shapes derive from the base NShape class. Currently there are three distinct NShape class derivates:

All shapes share the following set of common features:

Shape Type

The shape type is controlled from the ShapeType property (gets/sets a value from the ShapeType enumeration). There are only two types of shapes:

Besides the different way in which the diagram treats 1D and 2D shapes, the value of the ShapeType property influences the default values of several shape properties.


Plugs are only available for 1D shapes. In fact the shape will by design automatically create and destroy the shape plugs when you change the shape type. Each shape has two plugs - one start and one end plug.

The star plug is represented by an instance of the NStartPlug class and is accessible from the StartPlug property. The start plug position is anchored to the start point of the shape. When you move the start plug it actually moves the start point of the shape.

The end plug is represented by an instance of the NEndPlug class and is accessible from the EndPlug property. The end plug position is anchored to the end point of the shape. When you move the end plug it actually moves the end point of the shape.

Each plug can be connected to a single inward port of another shape. There are two ways of connecting a plug to a port:

In a plug-port connection the port is considered as master and the plug is considered as slave. This means that the plug will follow the movement of the port to which it is connected.

It is important to understand that physically not shapes, but their plugs and ports get connected. However it is more useful to logically threat these connections as if shapes are connected to other shapes. See Shape Navigation for more information.

You can disconnect a plug with the help of it's Disconnect method.

You can obtain the shapes to which the start and end plugs are connected via the FromShape and ToShape properties. Setting these properties will perform implicit connection of the respective plug.

Optional Shape Elements

Optionally, each shape can have the following set of additional shape elements:

By design a shape will only create the elements it needs (e.g. some shapes may not have labels, control points and/or ports). You can programmatically create and destroy the optional shape elements with the help of the CreateShapeElements and DestroyShapeElements methods, which both accept a combination of the ShapeElementsMask enumeration.

The following code will create the shape ports element, if the shape does not already has ports:

Copy Code
if (shape.Ports == null)
Visual Basic
Copy Code
If shape.Ports Is Nothing Then
End If

Currently all instancable shapes in the DOM have a single label, which is at the same time the default label. The only exception is the NTextShape (see Primitive Shapes  for more information). 

Expand and Collapse

Each shape can be either in expanded or collapsed state. By default all shapes are expanded. To collapse/expand a shape set its Collapsed property to true/false respectively.

When a shape is collapsed it will automatically reset its model size to be the size specified by the CollapsedSize property. Changing the model size of the shape, when the shape is collapsed will automatically update the CollapsedSize property of the shape.

When a shape is expanded it will automatically reset its model size to be the size specified by the ExpandedSize property. The ExpandedSize property is automatically updated when the shape is resized in expanded state.

A shape will expand/collapse relative to a pin point, the alignment of which is specified by the ExpandCollapsePinAlignment property.

All models that a shape aggregates are considered collapsed, when the shape is collapsed. A collapsed model is invisible and cannot be hit tested. Besides the aggregated models, the labels of a collapsed shape will also automatically become invisible and not hit testable. The only content that will remain visible are the shape decorators. That is why decorators are usually used in combination with collapsible shapes.

It is also worth mentioning that the diagram will automatically change the anchor positioning of plugs connected to ports, which reside in collapsed shapes (e.g. collapsed ports). By default ports, which are collapsed glue the connected plugs to the rim of the last collapsed shape in their ancestor path.

Interaction Style

In drawing views shapes are interactively edited with the help of trackers (interactive editors with handles, which the user can drag). There is a single tracker, for each type of shape aspect, which must be edited.

The trackers are automatically created by the drawing view when the shape is selected. You can however specify what types of trackers must be displayed for each shape through the InteractionStyle property. It gets/sets a NInteractionStyle structure, which exposes an easy way to raise/drop the flags in the InteractionStyleMask enumeration.

The following example will instruct the drawing view not to create a rotated bounds tracker for the shape, when it is selected:

Copy Code
NInteractionStyle interactionStyle = shape.InteractionStyle;
interactionStyle.RotatedBounds = false;
shape.InteractionStyle = interactionStyle;
Visual Basic
Copy Code
Dim interactionStyle As NInteractionStyle = shape.InteractionStyle
interactionStyle.RotatedBounds = False
shape.InteractionStyle = interactionStyle
Translation Slaves

It is in many cases necessary to implement rigid connected shapes structures. This is achieved with the help of shape translation slaves. The translation slaves of a shape are such shapes, which are translated with the shape when it is translated.

The translation shapes are specified through the TranslationSlaves property. It gets/sets a NTranslationSlaves structure, which exposes an easy way to raise/drop the flags in the TranslationSlavesMask enumeration.

The following example will instruct the shape to be translated together with it's destination shapes:

Copy Code
NTranslationSlaves translationSlaves = shape.TranslationSlaves;
translationSlaves.DestinationShapes = true;
shape.TranslationSlaves = translationSlaves;
Visual Basic
Copy Code
Dim translationSlaves As NTranslationSlaves = shape.TranslationSlaves
translationSlaves.DestinationShapes = True
shape.TranslationSlaves = translationSlaves

The accumulation of the shape translation slaves is recursive. For example: if a shape has to be translated, because it is a translation slave, then its translation slaves will also be translated.

Related Examples
Windows Forms: Document Object Model - Shapes folder
See Also



©2019. Nevron Software LLC.

Send Feedback