diff --git a/Terminal.Gui/Views/NumericUpDown.cs b/Terminal.Gui/Views/NumericUpDown.cs index c1a46e972..44b43c0c2 100644 --- a/Terminal.Gui/Views/NumericUpDown.cs +++ b/Terminal.Gui/Views/NumericUpDown.cs @@ -1,16 +1,14 @@ #nullable enable using System.ComponentModel; -using Microsoft.CodeAnalysis.Operations; namespace Terminal.Gui; /// -/// Enables the user to increase or decrease a value by clicking on the up or down buttons. +/// Enables the user to increase or decrease a value with the mouse or keyboard. /// /// /// Supports the following types: , , , , -/// . -/// Supports only one digit of precision. +/// . Attempting to use any other type will result in an . /// public class NumericUpDown : View where T : notnull { @@ -28,19 +26,26 @@ public class NumericUpDown : View where T : notnull { Type type = typeof (T); - if (!(type == typeof (object) || type == typeof (int) || type == typeof (long) || type == typeof (double) || type == typeof (float) || type == typeof (double) || type == typeof (decimal))) + if (!(type == typeof (object) + || type == typeof (int) + || type == typeof (long) + || type == typeof (double) + || type == typeof (float) + || type == typeof (double) + || type == typeof (decimal))) { throw new InvalidOperationException ("T must be a numeric type that supports addition and subtraction."); } Increment = (dynamic)1; + // `object` is supported only for AllViewsTester if (type != typeof (object)) { Value = (dynamic)0; } - Width = Dim.Auto (DimAutoStyle.Content); //Dim.Function (() => Digits + 2); // button + 3 for number + button + Width = Dim.Auto (DimAutoStyle.Content); Height = Dim.Auto (DimAutoStyle.Content); _down = new () @@ -128,22 +133,23 @@ public class NumericUpDown : View where T : notnull return; - void OnDownButtonOnAccept (object? s, HandledEventArgs e) - { - InvokeCommand (Command.ScrollDown); - } + void OnDownButtonOnAccept (object? s, HandledEventArgs e) { InvokeCommand (Command.ScrollDown); } - void OnUpButtonOnAccept (object? s, HandledEventArgs e) - { - InvokeCommand (Command.ScrollUp); - } + void OnUpButtonOnAccept (object? s, HandledEventArgs e) { InvokeCommand (Command.ScrollUp); } } private T _value = default!; /// - /// The value that will be incremented or decremented. + /// Gets or sets the value that will be incremented or decremented. /// + /// + /// + /// and events are raised when the value changes. + /// The event can be canceled the change setting to + /// . + /// + /// public T Value { get => _value; @@ -196,7 +202,8 @@ public class NumericUpDown : View where T : notnull } /// - /// Raised when the value is about to change. Set to true to prevent the change. + /// Raised when the value is about to change. Set to true to prevent the + /// change. /// public event EventHandler>? ValueChanging; @@ -206,16 +213,12 @@ public class NumericUpDown : View where T : notnull public event EventHandler>? ValueChanged; /// - /// /// public T Increment { get; set; } } - /// /// Enables the user to increase or decrease an by clicking on the up or down buttons. /// public class NumericUpDown : NumericUpDown -{ - -} +{ }