forked from jtborn/TFT-Overlay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathItemsCounter.cs
109 lines (91 loc) · 2.88 KB
/
ItemsCounter.cs
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
using Microsoft.VisualStudio.PlatformUI;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace TFT_Overlay
{
public partial class ItemsCounter : UserControl
{
private ICommand _upCommand;
private ICommand _downCommand;
#region Methods...
private void UpPoints() => Value += Step;
private void DownPoints() => Value -= Step;
#endregion
#region Commands...
public ICommand UpCommand => _upCommand ?? (_upCommand = new DelegateCommand(() => UpPoints()));
public ICommand DownCommand => _downCommand ?? (_downCommand = new DelegateCommand(() => DownPoints()));
#endregion
#region Properties...
#region ValueProperty
public static DependencyProperty ValueProperty =
DependencyProperty.Register(
"Value",
typeof(int),
typeof(ItemsCounter),
new PropertyMetadata(0));
public int Value
{
get { return (int)GetValue(ValueProperty); }
set
{
if (value < MinValue)
value = MinValue;
if (value > MaxValue)
value = MaxValue;
SetValue(ValueProperty, value);
}
}
#endregion
#region MinValueProperty
public readonly static DependencyProperty MinValueProperty = DependencyProperty.Register(
"MinValue",
typeof(int),
typeof(ItemsCounter),
new PropertyMetadata(0));
public int MinValue
{
get { return (int)GetValue(MinValueProperty); }
set
{
if (value > MaxValue)
MaxValue = value;
SetValue(MinValueProperty, value);
}
}
#endregion
#region MaxValueProperty
public readonly static DependencyProperty MaxValueProperty = DependencyProperty.Register(
"MaxValue",
typeof(int),
typeof(ItemsCounter),
new PropertyMetadata(int.MaxValue));
public int MaxValue
{
get { return (int)GetValue(MaxValueProperty); }
set
{
if (value < MinValue)
value = MinValue;
SetValue(MaxValueProperty, value);
}
}
#endregion
#region StepProperty
public readonly static DependencyProperty StepProperty = DependencyProperty.Register(
"Step",
typeof(int),
typeof(ItemsCounter),
new PropertyMetadata(1));
public int Step
{
get { return (int)GetValue(StepProperty); }
set
{
SetValue(StepProperty, value);
}
}
#endregion
#endregion
}
}