aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/Vector3Widget.cs
blob: 9acc615d825efd1419c94f569372265832a316d2 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// Copyright (c) 2021-2021  Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
//
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)

using System;
using System.ComponentModel;
using System.Numerics;
using Crow;
using Crow.Drawing;
//using vkvg;

namespace vkChess
{
	public class Vector3Widget : TemplatedControl
	{
		Vector3 vector;
		protected float minValue, maxValue, smallStep, bigStep;
		protected int decimals;


		[DefaultValue(2)]
		public int Decimals
		{
			get => decimals;
			set
			{
				if (value == decimals)
					return;
				decimals = value;
				NotifyValueChangedAuto (decimals);
				RegisterForRedraw ();
			}
		}
		[DefaultValue(0.0f)]
		public virtual float Minimum {
			get => minValue;
			set {
				if (minValue == value)
					return;

				minValue = value;
				NotifyValueChangedAuto (minValue);
				RegisterForRedraw ();
			}
		}
		[DefaultValue(100.0f)]
		public virtual float Maximum
		{
			get => maxValue;
			set {
				if (maxValue == value)
					return;

				maxValue = value;
				NotifyValueChangedAuto (maxValue);
				RegisterForRedraw ();
			}
		}
		[DefaultValue(1.0f)]
		public virtual float SmallIncrement
		{
			get => smallStep;
			set {
				if (smallStep == value)
					return;

				smallStep = value;
				NotifyValueChangedAuto (smallStep);
				RegisterForRedraw ();
			}
		}
		[DefaultValue(5.0f)]
		public virtual float LargeIncrement
		{
			get => bigStep;
			set {
				if (bigStep == value)
					return;

				bigStep = value;
				NotifyValueChangedAuto (bigStep);
				RegisterForRedraw ();
			}
		}

		public Vector3 Value {
			get => vector;
			set {
				if (vector == value)
					return;
				vector = value;
				NotifyValueChangedAuto (vector);
				NotifyValueChanged ("X", vector.X);
				NotifyValueChanged ("Y", vector.Y);
				NotifyValueChanged ("Z", vector.Z);
			}
		}
		public float X {
			get => vector.X;
			set {
				if (X == value)
					return;
				vector.X = value;
				NotifyValueChangedAuto (vector.X);
				NotifyValueChanged ("Value", vector);
			}
		}
		public float Y {
			get => vector.Y;
			set {
				if (Y == value)
					return;
				vector.Y = value;
				NotifyValueChangedAuto (vector.Y);
				NotifyValueChanged ("Value", vector);
			}
		}
		public float Z {
			get => vector.Z;
			set {
				if (Z == value)
					return;
				vector.Z = value;
				NotifyValueChangedAuto (vector.Z);
				NotifyValueChanged ("Value", vector);
			}
		}
	}
}