Class NumberBox
InputBox control that allows text input.
Inherited Members
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
OnResized()
Called when Resize(int, int) was called.
Declaration
protected override void OnResized()
Overrides
OnUnfocused()
Called when the control loses focus.
Declaration
protected override void OnUnfocused()
Overrides
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
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
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. |