Table of Contents

Class Label

Namespace
BSGameLib.UI.Controls
Assembly
BSGameLib.UI.dll

A piece of text drawn on screen. It sizes itself to its text, unless the view gives it a size.

public class Label : UIElement, IUpdateable, IEquatable<IUpdateable>, IDrawable, IIdentifiable<Guid>, IEquatable<IDrawable>, IDisposable
Inheritance
Label
Implements
Inherited Members

Constructors

Label(ILogger, View, string)

Creates a label in view.

public Label(ILogger logger, View view, string id = null)

Parameters

logger ILogger
view View
id string

Properties

Color

The colour of the text.

public Color Color { get; set; }

Property Value

Color

FontFile

The font to draw the text in: a font file, or the name of a built-in font. Null for the built-in default.

public string FontFile { get; set; }

Property Value

string

FontSize

The size of the text, in pixels. Zero uses the font's own size.

public float FontSize { get; set; }

Property Value

float

LetterSpacing

Extra space between letters, in pixels.

public float LetterSpacing { get; set; }

Property Value

float

Text

The text shown. Changing it recalculates the label's size and the lines it wraps to.

public string Text { get; set; }

Property Value

string

TextAlignment

Where the lines of text sit across the label's width.

public Label.Alignment TextAlignment { get; set; }

Property Value

Label.Alignment

Wrap

Whether text that is wider than the label wraps onto new lines, rather than running past its edge.

public bool Wrap { get; set; }

Property Value

bool

Methods

Draw(IGameTime)

Draws the label's fill and border, then its text, while the label is visible.

public override void Draw(IGameTime gameTime)

Parameters

gameTime IGameTime

LoadContent()

Loads the font and sets the label's size from its text.

public override void LoadContent()

Exceptions

FileNotFoundException

The font cannot be loaded, or it is not found and no FontSize is set.