using System; namespace DesktopMagicPluginAPI.Inputs { /// /// Represents a up-down control. /// public class IntegerUpDown : Element { private int _value; /// /// Gets or sets the maximum value for the element. /// public int Maximum { get; } /// /// Gets or sets the minimum value for the element. /// public int Minimum { get; } /// /// Gets or sets the value assigned to the element. /// public int Value { get => _value; set { if (_value != value) { _value = value; ValueChanged(); } } } /// /// Initializes a new instance of the class with the provided value, value and . /// /// The maximum value for the element. /// The minimum value for the element. /// The value assigned to the element. /// public IntegerUpDown(int min, int max, int value = 0) { if (min < 0) { throw new ArgumentException("Value can not be negative!", nameof(min)); } if (max < 0) { throw new ArgumentException("Value can not be negative!", nameof(max)); } if (min > max) { throw new ArgumentException($"{nameof(min)} is greater than or equal to {nameof(max)}!"); } if (value > max) { throw new ArgumentException($"{nameof(value)} is greater than {nameof(max)}!"); } if (value < min) { throw new ArgumentException($"{nameof(value)} is less than {nameof(min)}!"); } Minimum = min; Maximum = max; Value = value; } } }