diff options
Diffstat (limited to 'Samples/common/src/MyNumericControl.cs')
| -rw-r--r-- | Samples/common/src/MyNumericControl.cs | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/Samples/common/src/MyNumericControl.cs b/Samples/common/src/MyNumericControl.cs new file mode 100644 index 00000000..38e162a3 --- /dev/null +++ b/Samples/common/src/MyNumericControl.cs @@ -0,0 +1,46 @@ +//Tutorial +using Crow; + +namespace MyNumericControl { + public class MyNumericControl : TemplatedControl { + protected double actualValue, minValue, maxValue; + public double Minimum { + get => minValue; + set { + if (minValue == value) + return; + minValue = value; + if (Value < minValue) + Value = minValue; + NotifyValueChangedAuto (minValue); + } + } + public double Maximum { + get => maxValue; + set { + if (maxValue == value) + return; + maxValue = value; + NotifyValueChangedAuto (maxValue); + + if (Value > maxValue) + Value = maxValue; + + } + } + public virtual double Value { + get => actualValue; + set { + if (actualValue == value) + return; + if (value < minValue) + actualValue = minValue; + else if (value > maxValue) + actualValue = maxValue; + else + actualValue = value; + NotifyValueChangedAuto (actualValue); + } + } + } +}
\ No newline at end of file |