MindFusion.Wpf Pack Programmer's Guide
Text Attributes and Formatting

Text in Shape Nodes

A ShapeNode node can display Text within its outlines. Text position and alignment depend on the value of TextAlignment, TextPadding, TextWrapping and TextVerticalAlignment. The text is painted with the color set in TextBrush. Even more useful layout and formatting attributes can be enabled through PolygonalTextLayout and EnableStyledText.

Layout Text in Arbitrary Shapes

ShapeNode instances can have various shapes, as specified by their Shape and ShapeOrientation properties. To layout text inside non-rectangular shapes, enable PolygonalTextLayout. If enabled, Diagramming for WPF uses a formatting algorithm that fits exactly each line of text within the width of a line inside a polygonal shape. If a shape node has curved outlines, the formatting algorithm approximates them the poly-lines.

Supplementary Node Labels

Apart from main text content, the NodeLabel class lets you display additional labels and pin them to node's edges or corners. Call the AddLabel method to create such supplementary labels, and use NodeLabel (and base ItemLabel) properties and methods to customize their appearance and position.

Text Wrapping

If there isn't enough space available to fit a whole line of text, Diagramming for WPF wraps the text to a new line when it reaches the edge of the node. You can specify that the text should be wrapped only at word boundaries by setting TextTrimming to Word. The default is to split words into multiple parts if there is not enough space to fit a whole word.

If you prefer to use your own line-breaks, you can disable the automatic text wrapping by setting TextWrapping to None. If automatic wrapping is disabled and there isn't enough space to fit the whole line, the text is clipped at the node boundaries.

Text in Tables

A TableNode can display text in its caption area and inside each cell. Text in the Caption is painted with TextBrush and is aligned as specified by CaptionFormat. Text in cells is painted using their own TextBrush and is aligned according to their own TextFormat. Even more useful formatting attributes can be enabled by EnableStyledText property.

Styled Text

The ShapeNode.EnableStyledText property of shape nodes and the TableNode.EnableStyledText property of tables enables or disables styled text rendering. Styled text can have various attributes applied to the characters it contains. The attributes are specified using HTML-like formatting tags embedded in the raw text. Shape nodes can display styled text only if PolygonalTextLayout is enabled. Use the DrawStyledText method to display styled text in custom-drawn items.

The following table lists the currently supported style tags:

Tag

Description

<i>text</i>

Indicates italic text.

<b>text</b>

Indicates bold text.

<u>text</u>

Indicates underlined text.

<sub>text</sub>

Indicates subscript.

<sup>text</sup>

Indicates superscript.

<color=#RRGGBB>text</color>

Changes the color of the text. The red green and blue color channels are specified as two-digit hexadecimal numbers.

Link Labels

The Text of a DiagramLink is painted with the color specified in TextBrush and is positioned as set in TextStyle. Apart from main text content, the LinkLabel class lets you display additional labels and pin them to link's points or segments. Call the AddLabel method to create such supplementary labels, and use LinkLabel (and base ItemLabel) properties and methods to customize their appearance and position. Labels can automatically avoid overlapping nodes or other labels when their AutoArrange property is set.

Fonts

All items provide FontFamily, FontSize, FontStyle, FontWeight and FontStretch properties that allows getting or setting the font attributes used for rendering the items' text.