Table of Contents

Class Label

Namespace
Myra.Graphics2D.UI
Assembly
Myra.dll

A text label widget that displays formatted text with support for rich text formatting.

public class Label : Widget, IItemWithId, INotifyAttachedPropertyChanged
Inheritance
Label
Implements
Inherited Members

Constructors

Label(Stylesheet, string)

Initializes a new instance of the Label class with the specified stylesheet and style.

public Label(Stylesheet stylesheet, string styleName = "")

Parameters

stylesheet Stylesheet

The stylesheet to use for applying the style.

styleName string

The name of the style to apply. Defaults to the default stylesheet style.

Label(string)

Initializes a new instance of the Label class with the specified style.

public Label(string styleName = "")

Parameters

styleName string

The name of the style to apply. Defaults to the default stylesheet style.

Properties

AutoEllipsisMethod

The method used to abbreviate overflowing text.

public AutoEllipsisMethod AutoEllipsisMethod { get; set; }

Property Value

AutoEllipsisMethod

AutoEllipsisString

The string to use as ellipsis.

public string AutoEllipsisString { get; set; }

Property Value

string

DisabledTextColor

Gets or sets the text color when the label is disabled.

public Color? DisabledTextColor { get; set; }

Property Value

Color?

FocusedTextColor

Gets or sets the text color when the label has focus.

public Color? FocusedTextColor { get; set; }

Property Value

Color?

Font

Gets or sets the font used to render the label text.

public SpriteFontBase Font { get; set; }

Property Value

SpriteFontBase

OverTextColor

Gets or sets the text color when the mouse is over the label.

public Color? OverTextColor { get; set; }

Property Value

Color?

PressedTextColor

Gets or sets the text color when the label is pressed.

public Color? PressedTextColor { get; set; }

Property Value

Color?

SupportsCommands

Gets or sets a value indicating whether the text supports rich text formatting commands.

public bool SupportsCommands { get; set; }

Property Value

bool

Text

Gets or sets the text to display, with optional rich text formatting commands.

public string Text { get; set; }

Property Value

string

TextAlign

Gets or sets the horizontal alignment of the text.

public TextHorizontalAlignment TextAlign { get; set; }

Property Value

TextHorizontalAlignment

TextColor

Gets or sets the text color in the label's normal state.

public Color TextColor { get; set; }

Property Value

Color

VerticalSpacing

Gets or sets the vertical spacing in pixels between lines of text.

public int VerticalSpacing { get; set; }

Property Value

int

Wrap

Gets or sets a value indicating whether the text wraps to multiple lines.

public bool Wrap { get; set; }

Property Value

bool

Methods

ApplyLabelStyle(LabelStyle)

Applies the specified label style to this label.

public void ApplyLabelStyle(LabelStyle style)

Parameters

style LabelStyle

The label style to apply.

ApplyStyle(WidgetStyle)

Applies the specified widget style to this label.

protected override void ApplyStyle(WidgetStyle style)

Parameters

style WidgetStyle

The widget style to apply.

CopyFrom(Widget)

Copies all properties from another widget to this label.

protected override void CopyFrom(Widget w)

Parameters

w Widget

The widget to copy properties from.

InternalArrange()

Arranges the label's text layout within the label's bounds.

protected override void InternalArrange()

InternalMeasure(Point)

Measures the size required to display the label text.

protected override Point InternalMeasure(Point availableSize)

Parameters

availableSize Point

The available size for the label.

Returns

Point

The measured size needed for the label.

InternalRender(RenderContext)

Renders the label's text with appropriate color based on its state.

public override void InternalRender(RenderContext context)

Parameters

context RenderContext

The render context to draw with.