-
Notifications
You must be signed in to change notification settings - Fork 0
/
RunRevealControl.xaml.cs
169 lines (152 loc) · 3.86 KB
/
RunRevealControl.xaml.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
using System;
using System.Windows.Controls;
using System.ComponentModel;
namespace ScheduleRevealTool
{
public partial class RunRevealControl : UserControl
{
public RunRevealControl()
{
InitializeComponent();
}
public string Game
{
get
{
return GameText.Text;
}
set
{
GameText.Text = value;
}
}
public string Category
{
get
{
return CategoryText.Text;
}
set
{
CategoryText.Text = value;
}
}
public string Runners
{
get
{
return RunnerNamesText.Text;
}
set
{
RunnerNamesText.Text = value;
if (value.Contains(",") || value.Contains("&") || value.ToLower().Contains(" vs."))
RunnerLabelLabel.Content = "Runners:";
else
RunnerLabelLabel.Content = "Runner:";
}
}
public string Estimate
{
get
{
return EstimateText.Text;
}
set
{
EstimateText.Text = value;
}
}
public string Platform
{
get
{
return PlatformText.Text;
}
set
{
PlatformText.Text = value;
}
}
public string Time
{
get
{
return TimeText.Text;
}
set
{
TimeText.Text = value;
}
}
private Run curRun = null;
public void Clear()
{
GameText.Clear();
CategoryText.Clear();
RunnerNamesText.Clear();
PlatformText.Clear();
EstimateText.Clear();
TimeText.Clear();
if (curRun != null)
{
curRun.PropertyChanged -= Run_PropertyChanged;
curRun = null;
}
}
public void FromRun(Run run)
{
Game = run.Game;
Category = run.Category;
Runners = run.Runners;
Platform = run.Platform;
Estimate = run.Estimate;
Time = run.Time;
if (curRun != null)
curRun.PropertyChanged -= Run_PropertyChanged;
curRun = run;
curRun.PropertyChanged += Run_PropertyChanged;
}
private void Run_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
Run run = (Run)sender;
switch (e.PropertyName)
{
case "Game":
Game = run.Game;
break;
case "Category":
Category = run.Category;
break;
case "Runners":
Runners = run.Runners;
break;
case "Platform":
Platform = run.Platform;
break;
case "Estimate":
Estimate = run.Estimate;
break;
case "Time":
Time = run.Time;
break;
default:
break;
}
}
public Run ToRun()
{
if (curRun != null)
return curRun;
return new Run
{
Game = Game,
Category = Category,
Runners = Runners,
Platform = Platform,
Estimate = Estimate,
Time = Time
};
}
}
}