Search
Diagram.DrawStyledText Method
See Also
 





Draws a formatted text string, the same way text is drawn in shape nodes whose EnableStyledText property is set to true. This method lets you display styled text in custom-drawn nodes or links.

Namespace: MindFusion.Diagramming
Assembly: MindFusion.Diagramming

 Syntax

C#  Copy Code

public static void DrawStyledText (
    IGraphics graphics,
    string text,
    Font font,
    Brush textBrush,
    RectangleF textBounds,
    StringFormat format
)

Visual Basic  Copy Code

Public Shared Sub DrawStyledText( _
    graphics As IGraphics, _
    text As String, _
    font As Font, _
    textBrush As Brush, _
    textBounds As RectangleF, _
    format As StringFormat _
)

 Parameters

graphics
The IGraphics canvas on which to draw.
text

The text that should be drawn, including formatting tags.

font

The font used to draw the text.

textBrush

The brush used to draw the text.

textBounds

The bounds of the text layout rectangle.

format

Specifies the text alignment.

 Remarks

You might use this method when you custom-draw shape nodes and still need to use the EnableStyledText rendering functionality of MindFusion.Diagramming.

 Example

The following sample code illustrates how to manually render styled text.

C#  Copy Code

private void diagram_DrawNode(object sender, DrawNodeEventArgs e)
{
    Diagram.DrawStyledText(e.Graphics, "<b>test</b> <i>test</i>",
        diagram.Font, Brushes.Black, e.Node.Bounds, StringFormat.GenericDefault);
}

Visual Basic  Copy Code

Private Sub diagram_DrawNode(ByVal sender As Object, ByVal e As DrawNodeEventArgs) Handles diagram.DrawNode

    Diagram.DrawStyledText(e.Graphics, "<b>test</b> <i>test</i>", _
        diagram.Font, Brushes.Black, e.Node.Bounds, StringFormat.GenericDefault)

End Sub

 See Also