In This Article

ICanvas Interface

Provides the base requirements for an element that supports custom rendering of content.

public interface ICanvas

Methods

CreateTextBatch()

Creates an IDisposable object that contains a reference to a text renderer, which can be passed to the RunTextFormatter(IDisposable) to more efficiently process multiple similar text layouts in a batch.

IDisposable CreateTextBatch()

Returns

IDisposable:

An IDisposable object. Once disposed, the batch is ended.

CreateTextLayout(ITextProvider, Single, String, Single, Color, FontWeights, FontStyles, IEnumerable<ITextSpacer>)

Creates an ITextLayout that can render text runs on a canvas.

ITextLayout CreateTextLayout(ITextProvider textProvider, float maxWidth, string fontFamilyName, float fontSize, Color foreground, FontWeights fontWeight, FontStyles fontStyle, IEnumerable<ITextSpacer> spacers)
Parameter Type Description
textProvider ITextProvider

An ITextProvider that provides access to the text string.

maxWidth Single

The maximum width of the layout, which is used if word wrap is enabled.

fontFamilyName String

The default font family name.

fontSize Single

The default font size.

foreground Color

The default foreground.

fontWeight FontWeights

The default font weight.

fontStyle FontStyles

The default font style.

spacers IEnumerable<ITextSpacer>

The optional intra-text spacers.

Returns

ITextLayout:

The ITextLayout that was created.

CreateTextLayout(ITextProvider, Single, String, Single, Color, IEnumerable<ITextSpacer>)

Creates an ITextLayout that can render text runs on a canvas.

ITextLayout CreateTextLayout(ITextProvider textProvider, float maxWidth, string fontFamilyName, float fontSize, Color foreground, IEnumerable<ITextSpacer> spacers)
Parameter Type Description
textProvider ITextProvider

An ITextProvider that provides access to the text string.

maxWidth Single

The maximum width of the layout, which is used if word wrap is enabled.

fontFamilyName String

The default font family name.

fontSize Single

The default font size.

foreground Color

The default foreground.

spacers IEnumerable<ITextSpacer>

The optional intra-text spacers.

Returns

ITextLayout:

The ITextLayout that was created.

CreateTextLayout(String, Single, String, Single, Color)

Creates an ITextLayout that can render text runs on a canvas.

ITextLayout CreateTextLayout(string text, float maxWidth, string fontFamilyName, float fontSize, Color foreground)
Parameter Type Description
text String

The text string.

maxWidth Single

The maximum width of the layout, which is used if word wrap is enabled.

fontFamilyName String

The default font family name.

fontSize Single

The default font size.

foreground Color

The default foreground.

Returns

ITextLayout:

The ITextLayout that was created.

CreateTextSpacer(Int32, Object, Size, Single)

Creates an ITextSpacer that can create intra-text space within an ITextLayout.

ITextSpacer CreateTextSpacer(int characterIndex, object key, Size size, float baseline)
Parameter Type Description
characterIndex Int32

The character index at which the spacer should be inserted.

key Object

An optional object that uniquely identifies the spacer.

size Size

The size of the spacer.

baseline Single

The baseline of the spacer.

Returns

ITextSpacer:

The ITextSpacer that was created.

GetSolidColorBrush(Color)

Returns a solid color brush for the specified Color.

SolidBrush GetSolidColorBrush(Color color)
Parameter Type Description
color Color

The brush color.

Returns

SolidBrush:

A solid color brush for the specified Color.

GetSquiggleLinePen(Color)

Returns a squiggle line pen for the specified Color.

Pen GetSquiggleLinePen(Color color)
Parameter Type Description
color Color

The pen color.

Returns

Pen:

A squiggle line pen for the specified Color.

GetSquiggleLinePen(Color, Single)

Returns a squiggle line pen for the specified Color.

Pen GetSquiggleLinePen(Color color, float thickness)
Parameter Type Description
color Color

The pen color.

thickness Single

The pen thickness.

Returns

Pen:

A squiggle line pen for the specified Color and thickness.