aboutsummaryrefslogtreecommitdiffstatsci
path: root/Samples/common/src/MyNumericControl.cs
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-10-30 19:38:50 +0200
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-10-30 19:38:50 +0200
commita4367fb29faf7ee987b937e2397359a6020f25b9 (patch)
treec4bda0d5d5b2cc73b11f38795d151fbaf2c0c9a7 /Samples/common/src/MyNumericControl.cs
parentc706b713a716e8b7fd29508ccf88e5de5041d1d4 (diff)
update readme
Diffstat (limited to 'Samples/common/src/MyNumericControl.cs')
-rw-r--r--Samples/common/src/MyNumericControl.cs46
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