Class Label
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
Properties
Color
The colour of the text.
public Color Color { get; set; }
Property Value
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
FontSize
The size of the text, in pixels. Zero uses the font's own size.
public float FontSize { get; set; }
Property Value
LetterSpacing
Extra space between letters, in pixels.
public float LetterSpacing { get; set; }
Property Value
Text
The text shown. Changing it recalculates the label's size and the lines it wraps to.
public string Text { get; set; }
Property Value
TextAlignment
Where the lines of text sit across the label's width.
public Label.Alignment TextAlignment { get; set; }
Property Value
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
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
gameTimeIGameTime
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.