aboutsummaryrefslogtreecommitdiffstatsci
path: root/Samples/common/src/MyNumericControl.cs
blob: 38e162a3b0e7d1c3a98bc1e0e05de4a879ca9583 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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);
			}
		}
	}
}