A ShapeNode node can display Text within its outlines. Text position and alignment depend on the value of TextFormat. The text is painted with the color set in TextBrush. Even more useful layout and formatting attributes can be enabled via PolygonalTextLayout and EnableStyledText.
ShapeNode instances can have various shapes, as specified via their Shape and ShapeOrientation properties. To layout text inside non-rectangular shapes, enable PolygonalTextLayout. If enabled, MindFusion.Diagramming 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.
If there isn't enough space available to fit a whole line of text, MindFusion.Diagramming 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 the Trimming member of TextFormat to StringTrimming.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 enabling the NoWrap flag in the FormatFlags member of TextFormat. If automatic wrapping is disabled and there isn't enough space to fit the whole line, the text is clipped at the node boundaries.
A TableNode can display text in its caption bar and inside each cell. Text in the Caption is painted with CaptionBrush and is aligned as specified via CaptionFormat. Text in cells is painted in their own TextBrush and is aligned according to their own TextFormat. Even more useful formatting attributes can be enabled via EnableStyledText property.
The EnableStyledText property of ShapeNode, TableNode and ItemLabel 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. |
When styled text is enabled, you must use <, > and & to display respectively the <, > and & symbols.
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.
All items provide a Font property that allows getting or setting the font used for rendering their text. Always set the font's Unit property to World to get correct zooming of items' text and proper formatting and layout.