Search
Default Values

Default values

With the introduction of the new style system, the following default-value properties in the Diagram class are considered obsolete and will no longer have any effect on newly created items:

To provide the same functionality as those properties did before, use a Theme object with styles associated with the appropriate diagram item types. For example, to provide default pen for shape nodes, use the following code:

C#  Copy Code

ShapeNodeStyle defaultStyle = new ShapeNodeStyle();
defaultStyle.Stroke = ...;
defaultStyle.StrokeThickness = ...;
Theme theme = new Theme();
theme.RegisterStyle(typeof(ShapeNode), defaultStyle);
diagram.Theme = theme;

Visual Basic  Copy Code

Dim defaultStyle As New ShapeNodeStyle()
defaultStyle.Stroke = ...
defaultStyle.StrokeThickness = ...
Dim theme As New Theme()
theme.RegisterStyle(GetType(ShapeNode), defaultStyle)
diagram.Theme = theme

For convenience, the CreateThemeFromDefaults method of the Diagram class can create this Theme object from the diagram's current default values.

Alternatively, you can set the default values through a set of shortcut properties in the Diagram class. These shortcut properties create a Theme object internally, register the appropriate classes and assign the theme to the diagram. The following table illustrates this.

Old property

New equivalent

Diagram.ShapePen

Diagram.ShapeNodeStyle.Stroke
Diagram.ShapeNodeStyle.StrokeThickness

Diagram.ShapeBrush

Diagram.ShapeNodeStyle.Brush

Diagram.LinkPen

Diagram.DiagramLinkStyle.Stroke
Diagram.DiagramLinkStyle.StrokeThickness

Diagram.LinkBrush

Diagram.DiagramLinkStyle.Brush

Diagram.TablePen

Diagram.TableNodeStyle.Stroke
Diagram.TableNodeStyle.StrokeThickness

Diagram.TableBrush

Diagram.TableNodeStyle.Brush

Diagram.ShadowBrush

Diagram.DiagramStyle.ShadowBrush

Diagram.Font

Diagram.DiagramStyle.FontFamily
Diagram.DiagramStyle.FontSize
Diagram.DiagramStyle.FontStyle
Diagram.DiagramStyle.FontUnit

Diagram.TextColor

Diagram.DiagramStyle.TextBrush

 Important!

The Font, Brush, and Pen properties of diagram items are no longer guaranteed to be non-null. In fact their default value is now null, so replace these properties with their EffectiveFont, EffectiveBrush, and EffectivePen counterparts.