Show / Hide Table of Contents

Class NumberBox

InputBox control that allows text input.

Inheritance
object
ControlBase
TextBox
NumberBox
Inherited Members
TextBox._cachedBuilder
TextBox._caretPos
TextBox._text
TextBox.Resize(int, int)
TextBox.ValidateCursorPosition(string)
TextBox.CheckKeyPressCancel(AsciiKey)
TextBox.OnLeftMouseClicked(ControlBase.ControlMouseState)
TextBox.Mask
TextBox.LeftDrawOffset
TextBox.DisableMouse
TextBox.DisableKeyboard
TextBox.MaxLength
TextBox.Validator
TextBox.CaretPosition
TextBox.Text
TextBox.CaretEffect
TextBox.UseDifferentTextAreaWidth
TextBox.TextAreaWidth
TextBox.TextChanged
TextBox.TextChangedPreview
TextBox.KeyPressed
TextBox.TextValidated
ControlBase.MouseState_IsMouseOver
ControlBase.MouseState_EnteredWithButtonDown
ControlBase.MouseState_IsMouseLeftDown
ControlBase.MouseState_IsMouseRightDown
ControlBase.OnIsDirtyChanged()
ControlBase.LostMouse(MouseScreenObjectState)
ControlBase.OnParentChanged()
ControlBase.OnPositionChanged()
ControlBase.PlaceRelativeTo(ControlBase, Direction.Types, int)
ControlBase.DetermineState()
ControlBase.OnStateChanged(ControlStates, ControlStates)
ControlBase.OnSurfaceChanged(ICellSurface, ICellSurface)
ControlBase.FindThemeFont()
ControlBase.FindThemeColors()
ControlBase.SetThemeColors(Colors)
ControlBase.HasThemeColors()
ControlBase.CreateControlSurface()
ControlBase.RefreshThemeStateColors(Colors)
ControlBase.OnMouseEnter(ControlBase.ControlMouseState)
ControlBase.OnMouseExit(ControlBase.ControlMouseState)
ControlBase.OnMouseIn(ControlBase.ControlMouseState)
ControlBase.OnRightMouseClicked(ControlBase.ControlMouseState)
ControlBase.ThemeState
ControlBase.UseKeyboard
ControlBase.UseMouse
ControlBase.CanFocus
ControlBase.CanResize
ControlBase.AlternateFont
ControlBase.Surface
ControlBase.MouseArea
ControlBase.IsMouseButtonStateClean
ControlBase.Position
ControlBase.AbsolutePosition
ControlBase.IsVisible
ControlBase.Tag
ControlBase.TabStop
ControlBase.TabIndex
ControlBase.IsDirty
ControlBase.Name
ControlBase.FocusOnMouseClick
ControlBase.Width
ControlBase.Height
ControlBase.IsFocused
ControlBase.IsEnabled
ControlBase.Bounds
ControlBase.Parent
ControlBase.State
ControlBase.IsDirtyChanged
ControlBase.Focused
ControlBase.Unfocused
ControlBase.PositionChanged
ControlBase.MouseEnter
ControlBase.MouseExit
ControlBase.MouseMove
ControlBase.MouseButtonClicked
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: SadConsole.UI.Controls
Assembly: SadConsole.dll
Syntax
[DataContract]
public class NumberBox : TextBox

Constructors

NumberBox(int)

Creates a new instance of the input box.

Declaration
public NumberBox(int width)
Parameters
Type Name Description
int width

The width of the input box.

Fields

_allowDecimalPoint

Indicates that the input box (when numeric) will accept decimal points.

Declaration
[DataMember(Name = "AllowDecimalPoint")]
protected bool _allowDecimalPoint
Field Value
Type Description
bool

Properties

AllowDecimal

Gets or sets whether or not this input box should restrict numeric input should allow a decimal point.

Declaration
public bool AllowDecimal { get; set; }
Property Value
Type Description
bool

DefaultDecimalValue

The default value to use when the current value is invalid and AllowDecimal is true.

Declaration
[DataMember]
public double DefaultDecimalValue { get; set; }
Property Value
Type Description
double

DefaultValue

The default value to use when the current value is invalid and AllowDecimal is false.

Declaration
[DataMember]
public long DefaultValue { get; set; }
Property Value
Type Description
long

DownButtonGlyph

The glyph for the down button.

Declaration
[DataMember]
public int DownButtonGlyph { get; set; }
Property Value
Type Description
int

DownButtonStep

Sets the down button's value step.

Declaration
[DataMember]
public long DownButtonStep { get; set; }
Property Value
Type Description
long

DownButtonStepDecimal

Sets the down button's value step when AllowDecimal is on.

Declaration
[DataMember]
public double DownButtonStepDecimal { get; set; }
Property Value
Type Description
double

IsEditingNumberInvalid

When true, indicates that the number is either out of bounds of the NumberMinimum and NumberMaximum range, or it can't be property parsed. Otherwise, false

Declaration
public bool IsEditingNumberInvalid { get; }
Property Value
Type Description
bool
Remarks

Used by the theme system.

NumberBoxInvalidNumberForeground

The color to use with a NumberBox control when IsEditingNumberInvalid is true.

Declaration
[DataMember]
public Color? NumberBoxInvalidNumberForeground { get; set; }
Property Value
Type Description
Color?

NumberMaximum

The maximum number that can be set for this text box.

Declaration
[DataMember]
public long NumberMaximum { get; set; }
Property Value
Type Description
long
Remarks

Set both NumberMaximum and NumberMinimum to 0 to disable number bounds checking.

NumberMinimum

The minimum number that can be set for this text box.

Declaration
[DataMember]
public long NumberMinimum { get; set; }
Property Value
Type Description
long
Remarks

Set both NumberMaximum and NumberMinimum to 0 to disable number bounds checking.

ShowUpDownButtons

When true, displays up and down buttons at the end of the box.

Declaration
[DataMember]
public bool ShowUpDownButtons { get; set; }
Property Value
Type Description
bool

State_IsMouseOverDownButton

Used by the mouse logic.

Declaration
public bool State_IsMouseOverDownButton { get; set; }
Property Value
Type Description
bool

State_IsMouseOverUpButton

Used by the mouse logic.

Declaration
public bool State_IsMouseOverUpButton { get; set; }
Property Value
Type Description
bool

UpButtonGlyph

The glyph for the up button.

Declaration
[DataMember]
public int UpButtonGlyph { get; set; }
Property Value
Type Description
int

UpButtonStep

Sets the up button's value step.

Declaration
[DataMember]
public long UpButtonStep { get; set; }
Property Value
Type Description
long

UpButtonStepDecimal

Sets the up button's value step when AllowDecimal is on.

Declaration
[DataMember]
public double UpButtonStepDecimal { get; set; }
Property Value
Type Description
double

Methods

DecreaseNumber(double)

Decreases the number stored in the Text property by the specified amount.

Declaration
public void DecreaseNumber(double amount)
Parameters
Type Name Description
double amount

The amount.

Exceptions
Type Condition
Exception

Thrown when this method is used and the AllowDecimal property is set to false.

DecreaseNumber(long)

Decreases the number stored in the Text property by the specified amount.

Declaration
public void DecreaseNumber(long amount)
Parameters
Type Name Description
long amount

The amount.

GetCulture()

Returns the current culture.

Declaration
protected CultureInfo GetCulture()
Returns
Type Description
CultureInfo

The current culture.

GetCultureDecimalSeperator()

Gets the current culture's decimal separator.

Declaration
protected char GetCultureDecimalSeperator()
Returns
Type Description
char

The current culture.

IncreaseNumber(double)

Increases the number stored in the Text property by the specified amount.

Declaration
public void IncreaseNumber(double amount)
Parameters
Type Name Description
double amount

The amount.

Exceptions
Type Condition
Exception

Thrown when this method is used and the AllowDecimal property is set to false.

IncreaseNumber(long)

Increases the number stored in the Text property by the specified amount.

Declaration
public void IncreaseNumber(long amount)
Parameters
Type Name Description
long amount

The amount.

OnFocused()

Called when the control is focused.

Declaration
protected override void OnFocused()
Overrides
TextBox.OnFocused()

OnResized()

Called when Resize(int, int) was called.

Declaration
protected override void OnResized()
Overrides
ControlBase.OnResized()

OnUnfocused()

Called when the control loses focus.

Declaration
protected override void OnUnfocused()
Overrides
TextBox.OnUnfocused()

ProcessKeyboard(Keyboard)

Called when the control should process keyboard information.

Declaration
public override bool ProcessKeyboard(Keyboard info)
Parameters
Type Name Description
Keyboard info

The keyboard information.

Returns
Type Description
bool

True if the keyboard was handled by this control.

Overrides
TextBox.ProcessKeyboard(Keyboard)

ProcessMouse(MouseScreenObjectState)

Checks if the mouse is the control and calls the appropriate mouse methods.

Declaration
public override bool ProcessMouse(MouseScreenObjectState state)
Parameters
Type Name Description
MouseScreenObjectState state

Mouse information.

Returns
Type Description
bool

True when the control is enabled, set to use the mouse and the mouse is over it, otherwise false.

Overrides
ControlBase.ProcessMouse(MouseScreenObjectState)

TextAsDouble()

Returns the Text property as parsed by TryParse(string, NumberStyles, IFormatProvider, out double) with the current culture.

Declaration
public double TextAsDouble()
Returns
Type Description
double

The parsed text value.

TextAsLong()

Returns the Text property as parsed by TryParse(string, NumberStyles, IFormatProvider, out long) with the current culture.

Declaration
public long TextAsLong()
Returns
Type Description
long

The parsed text value.

UpdateAndRedraw(TimeSpan)

Redraws the control if applicable.

Declaration
public override void UpdateAndRedraw(TimeSpan time)
Parameters
Type Name Description
TimeSpan time

The duration of thecurrent frame.

Overrides
TextBox.UpdateAndRedraw(TimeSpan)

Extension Methods

ExtensionsSystem.GetDebuggerDisplayValue(object)
In this article

Back to top

Back to top Generated by DocFX