Skip to content

Label Class

A simple surface for drawing text that can be moved and sized like a control.

C#
[DataContract]
public class Label : ControlBase

Inheritance objectControlBase

A control to display simple one-line text.

C#
public Label(string displayText)

displayText string
The text to display. Sets the width based on the length.

A control to display simple one-line text.

C#
public Label(int length)

length int
The initial length of the label without any text.

When true, shows an underline on the text.

C#
public bool ShowUnderline { get; set; }

When true, shows a strikethrough on the text.

C#
public bool ShowStrikethrough { get; set; }

Optional text color for the label. Otherwise the theme controls the color.

C#
public Color? TextColor { get; set; }

Sets the horizontal alignment of the label. Defaults to Left.

C#
public HorizontalAlignment Alignment { get; set; }

The text to display on the label. The label size is set in the constructor and cannot be changed.

C#
public string DisplayText { get; set; }

When true, only uses Normal for drawing.

C#
[DataMember]
public bool UseNormalStateOnly { get; set; }

The decorator to use when the ShowUnderline is true.

C#
[DataMember]
public CellDecorator DecoratorUnderline { get; set; }

The decorator to use when the ShowStrikethrough is true.

C#
[DataMember]
public CellDecorator DecoratorStrikethrough { get; set; }

Resizes the label but forces a height of 1.

C#
public override void Resize(int width, int height)

width int
The width of the label.

height int
Not used.

Redraws the control if applicable.

C#
public override void UpdateAndRedraw(TimeSpan time)

time TimeSpan
The duration of thecurrent frame.

Gets the strikethrough glyph defined by a font. If not found, returns glyph 196.

C#
protected CellDecorator GetStrikethrough(IFont font, Color color)

font IFont
The font.

color SadRogue.Primitives.Color
The color to shade the decorator.

CellDecorator
The cell decorator.

Gets the underline glyph defined by a font. If not found, returns glyph 95.

C#
protected CellDecorator GetUnderline(IFont font, Color color)

font IFont
The font.

color SadRogue.Primitives.Color
The color to shade the decorator.

CellDecorator
The cell decorator.