|
0
|
1 |
using System; |
|
|
2 |
using System.Net; |
|
|
3 |
using System.Windows; |
|
|
4 |
using System.Windows.Controls; |
|
|
5 |
using System.Windows.Documents; |
|
|
6 |
using System.Windows.Ink; |
|
|
7 |
using System.Windows.Input; |
|
|
8 |
using System.Windows.Media; |
|
|
9 |
using System.Windows.Media.Animation; |
|
|
10 |
using System.Windows.Shapes; |
|
|
11 |
using System.Windows.Data; |
|
|
12 |
using SLExtensions.Input; |
|
|
13 |
using Iri.Modernisation.BaseMVVM.Commands; |
|
|
14 |
using Iri.Modernisation.Data.Models; |
|
|
15 |
using System.Collections.Generic; |
|
|
16 |
using System.Linq; |
|
|
17 |
using Iri.Modernisation.Controls.View; |
|
|
18 |
namespace Iri.Modernisation.Controls.ViewModel |
|
|
19 |
{ |
|
|
20 |
|
|
|
21 |
/// <summary> |
|
|
22 |
/// ViewModel du module d'annotation |
|
|
23 |
/// </summary> |
|
|
24 |
public class AnnotationMakerVM : BaseMVVM.ViewModel.ViewModel |
|
|
25 |
{ |
|
25
|
26 |
|
|
|
27 |
private PolemicElement _refElement; |
|
0
|
28 |
/// <summary> |
|
|
29 |
/// Element référent |
|
|
30 |
/// </summary> |
|
|
31 |
public PolemicElement RefElement |
|
|
32 |
{ |
|
|
33 |
get |
|
|
34 |
{ |
|
|
35 |
return _refElement; |
|
|
36 |
} |
|
|
37 |
set |
|
|
38 |
{ |
|
|
39 |
_refElement = value; |
|
|
40 |
|
|
|
41 |
_newAnnotation = new Annotation(((PolemicElement)value).Chapter); |
|
|
42 |
Begin = ((PolemicElement)value).TimerIn.TotalMilliseconds; |
|
|
43 |
End = ((PolemicElement)value).TimerOut.TotalMilliseconds; |
|
28
|
44 |
BasicRelation = new PolemicLink() { FromElement = ((PolemicElement)value), ToElement = _newAnnotation, Type = null}; |
|
0
|
45 |
PolemicRelation = new PolemicLink(); |
|
|
46 |
PolemicRelation.FromElement = _newAnnotation; |
|
|
47 |
|
|
|
48 |
OnPropertyChanged(String.Empty); |
|
|
49 |
//OnPropertyChanged("RefElement"); |
|
|
50 |
//OnPropertyChanged("IsControlEnable"); |
|
|
51 |
|
|
|
52 |
} |
|
|
53 |
} |
|
|
54 |
|
|
|
55 |
/// <summary> |
|
|
56 |
/// Savoir si le module de liens est activé |
|
|
57 |
/// </summary> |
|
|
58 |
public bool IsBinderActive { get; set; } |
|
25
|
59 |
/// <summary> |
|
|
60 |
/// Liste des Tags Référants |
|
|
61 |
/// </summary> |
|
0
|
62 |
public List<String> RefTags |
|
|
63 |
{ |
|
|
64 |
get |
|
|
65 |
{ |
|
|
66 |
if (_refElement != null) |
|
|
67 |
{ |
|
|
68 |
return _refElement.Tags; |
|
|
69 |
} |
|
|
70 |
else |
|
|
71 |
{ |
|
|
72 |
return new List<String>(); |
|
|
73 |
} |
|
|
74 |
} |
|
|
75 |
} |
|
|
76 |
|
|
|
77 |
/// <summary> |
|
|
78 |
/// Annotation créé |
|
|
79 |
/// </summary> |
|
|
80 |
private Annotation _newAnnotation; |
|
|
81 |
|
|
25
|
82 |
|
|
|
83 |
private TimeSpan _begin; |
|
0
|
84 |
/// <summary> |
|
|
85 |
/// Temps de début de l'annotation |
|
|
86 |
/// </summary> |
|
|
87 |
public double Begin |
|
|
88 |
{ |
|
|
89 |
get |
|
|
90 |
{ |
|
|
91 |
return _begin.TotalMilliseconds; |
|
|
92 |
} |
|
|
93 |
set |
|
|
94 |
{ |
|
|
95 |
_begin = TimeSpan.FromMilliseconds(value); |
|
|
96 |
_newAnnotation.TimerIn = TimeSpan.FromMilliseconds(value); |
|
|
97 |
OnPropertyChanged("Begin"); |
|
|
98 |
} |
|
|
99 |
} |
|
|
100 |
|
|
25
|
101 |
|
|
|
102 |
private TimeSpan _end; |
|
0
|
103 |
/// <summary> |
|
|
104 |
/// Temps de fin de l'annotation |
|
|
105 |
/// </summary> |
|
|
106 |
public double End |
|
|
107 |
{ |
|
|
108 |
get |
|
|
109 |
{ |
|
|
110 |
return _end.TotalMilliseconds; |
|
|
111 |
} |
|
|
112 |
set |
|
|
113 |
{ |
|
|
114 |
_end = TimeSpan.FromMilliseconds(value); |
|
|
115 |
_newAnnotation.TimerOut = TimeSpan.FromMilliseconds(value); |
|
|
116 |
OnPropertyChanged("End"); |
|
|
117 |
} |
|
|
118 |
} |
|
|
119 |
|
|
28
|
120 |
private PolemicTypeDescription _selectedType; |
|
0
|
121 |
/// <summary> |
|
|
122 |
/// Convertion Rectange |
|
|
123 |
/// </summary> |
|
28
|
124 |
public PolemicTypeDescription SelectedType |
|
0
|
125 |
{ |
|
|
126 |
get |
|
|
127 |
{ |
|
|
128 |
return _selectedType; |
|
|
129 |
} |
|
|
130 |
set |
|
|
131 |
{ |
|
|
132 |
_selectedType = value; |
|
28
|
133 |
OnPropertyChanged("SelectedType"); |
|
|
134 |
// Type = (PolemicElementType)((Rectangle)_selectedType).Resources["PolemicType"]; |
|
0
|
135 |
} |
|
|
136 |
} |
|
|
137 |
|
|
25
|
138 |
private String _title; |
|
0
|
139 |
/// <summary> |
|
|
140 |
/// Titre de l'annotation |
|
|
141 |
/// </summary> |
|
|
142 |
public String Title |
|
|
143 |
{ |
|
|
144 |
get |
|
|
145 |
{ return _title; } |
|
|
146 |
set |
|
|
147 |
{ |
|
|
148 |
_title = value; |
|
|
149 |
_newAnnotation.Title = value; |
|
|
150 |
OnPropertyChanged("Title"); |
|
|
151 |
} |
|
|
152 |
} |
|
|
153 |
|
|
25
|
154 |
private String _description; |
|
|
155 |
|
|
0
|
156 |
/// <summary> |
|
|
157 |
/// Description de l'annotation |
|
|
158 |
/// </summary> |
|
|
159 |
public String Description |
|
|
160 |
{ |
|
|
161 |
get |
|
|
162 |
{ |
|
|
163 |
return _description; |
|
|
164 |
} |
|
|
165 |
set |
|
|
166 |
{ |
|
|
167 |
_description = value; |
|
|
168 |
_newAnnotation.Description = value; |
|
|
169 |
OnPropertyChanged("Description"); |
|
|
170 |
} |
|
|
171 |
|
|
|
172 |
} |
|
|
173 |
|
|
|
174 |
/// <summary> |
|
|
175 |
/// Tags de l'annotation |
|
|
176 |
/// </summary> |
|
|
177 |
public List<String> _tags =new List<String>(); |
|
25
|
178 |
/// <summary> |
|
|
179 |
/// Tags de l'annotation |
|
|
180 |
/// </summary> |
|
0
|
181 |
public String Tags |
|
|
182 |
{ |
|
|
183 |
get |
|
|
184 |
{ |
|
|
185 |
try |
|
|
186 |
{ |
|
|
187 |
return String.Join(",", _tags.ToArray()); |
|
|
188 |
} |
|
|
189 |
catch |
|
|
190 |
{ |
|
|
191 |
return String.Empty; |
|
|
192 |
} |
|
|
193 |
} |
|
|
194 |
set |
|
|
195 |
{ |
|
|
196 |
String val = (String)value; |
|
|
197 |
_tags = val.Split(',').ToList(); |
|
|
198 |
_newAnnotation.Tags = val.Split(',').ToList(); |
|
|
199 |
OnPropertyChanged("Tags"); |
|
|
200 |
|
|
|
201 |
|
|
|
202 |
} |
|
|
203 |
} |
|
|
204 |
|
|
25
|
205 |
|
|
|
206 |
private PolemicLink _basicRelation; |
|
0
|
207 |
/// <summary> |
|
|
208 |
/// Relation basique |
|
|
209 |
/// </summary> |
|
|
210 |
public PolemicLink BasicRelation |
|
|
211 |
{ |
|
|
212 |
get |
|
|
213 |
{ |
|
|
214 |
return _basicRelation; |
|
|
215 |
} |
|
|
216 |
set |
|
|
217 |
{ |
|
|
218 |
_basicRelation = value; |
|
|
219 |
OnPropertyChanged("BasicRelation"); |
|
|
220 |
} |
|
|
221 |
|
|
|
222 |
|
|
|
223 |
} |
|
|
224 |
|
|
25
|
225 |
|
|
|
226 |
private PolemicLink _polemicRelation; |
|
0
|
227 |
/// <summary> |
|
|
228 |
/// Relation polémique |
|
|
229 |
/// </summary> |
|
|
230 |
public PolemicLink PolemicRelation |
|
|
231 |
{ |
|
|
232 |
get |
|
|
233 |
{ |
|
|
234 |
|
|
|
235 |
return _polemicRelation; |
|
|
236 |
} |
|
|
237 |
set |
|
|
238 |
{ |
|
|
239 |
_polemicRelation = value; |
|
|
240 |
OnPropertyChanged("PolemicRelation"); |
|
|
241 |
} |
|
|
242 |
|
|
|
243 |
|
|
|
244 |
} |
|
|
245 |
|
|
|
246 |
/// <summary> |
|
|
247 |
/// Détermine si le control est activé ou non |
|
|
248 |
/// </summary> |
|
|
249 |
public bool IsControlEnable |
|
|
250 |
{ |
|
|
251 |
get |
|
|
252 |
{ |
|
|
253 |
return _refElement != null; |
|
|
254 |
} |
|
|
255 |
} |
|
|
256 |
|
|
|
257 |
/// <summary> |
|
|
258 |
/// Permet d'initialiser les commands; |
|
|
259 |
/// </summary> |
|
|
260 |
private void InitializeCommands() |
|
|
261 |
{ |
|
|
262 |
Commands.ContextualBinderLayer.BeginBind.Executed += new EventHandler<ExecutedEventArgs>(BeginBind_Executed); |
|
|
263 |
Commands.ContextualBinderLayer.SelectBind.Executed += new EventHandler<ExecutedEventArgs>(SelectBind_Executed); |
|
|
264 |
Commands.ContextualBinderLayer.ActiveBind.Executed += new EventHandler<ExecutedEventArgs>(ActiveBind_Executed); |
|
|
265 |
Commands.ContextualBinderLayer.DesactiveBind.Executed += new EventHandler<ExecutedEventArgs>(DesactiveBind_Executed); |
|
|
266 |
Commands.AnnotationMaker.OkClick.Executed += new EventHandler<ExecutedEventArgs>(OkClickAnnotationMaker_Executed); |
|
|
267 |
} |
|
|
268 |
|
|
25
|
269 |
private void DesactiveBind_Executed(object sender, ExecutedEventArgs e) |
|
0
|
270 |
{ |
|
|
271 |
IsBinderActive = false; |
|
|
272 |
} |
|
|
273 |
|
|
25
|
274 |
private void ActiveBind_Executed(object sender, ExecutedEventArgs e) |
|
0
|
275 |
{ |
|
|
276 |
IsBinderActive = true; |
|
|
277 |
} |
|
|
278 |
|
|
|
279 |
|
|
|
280 |
|
|
25
|
281 |
private void SelectBind_Executed(object sender, ExecutedEventArgs e) |
|
0
|
282 |
{ |
|
|
283 |
if (IsControlEnable && IsBinderActive ) |
|
|
284 |
{ |
|
|
285 |
PolemicRelation.ToElement = (PolemicElement)e.Source; |
|
|
286 |
OnPropertyChanged("PolemicRelation"); |
|
|
287 |
} |
|
|
288 |
|
|
|
289 |
} |
|
|
290 |
|
|
25
|
291 |
private void BeginBind_Executed(object sender, ExecutedEventArgs e) |
|
0
|
292 |
{ |
|
|
293 |
if (IsControlEnable) |
|
|
294 |
{ |
|
|
295 |
PolemicRelation.Type = ((ContextualLinkBinder)e.Parameter).PolemicType; |
|
|
296 |
PolemicRelation.ToElement = null; |
|
|
297 |
OnPropertyChanged("PolemicRelation"); |
|
|
298 |
|
|
|
299 |
} |
|
|
300 |
|
|
|
301 |
} |
|
|
302 |
|
|
|
303 |
|
|
|
304 |
|
|
25
|
305 |
private void OkClickAnnotationMaker_Executed(object sender, ExecutedEventArgs e) |
|
0
|
306 |
{ |
|
28
|
307 |
String message = "Ok clicked "+SelectedType.Title+" \n"; |
|
0
|
308 |
message += _begin + "-->" + _end; |
|
|
309 |
message += "\n" + Title; |
|
|
310 |
message += "\n" + Description; |
|
|
311 |
|
|
|
312 |
foreach (string tag in _tags) |
|
|
313 |
{ |
|
|
314 |
message += "\n|-" + tag; |
|
|
315 |
} |
|
|
316 |
|
|
28
|
317 |
message += "PolemicLink "+PolemicRelation.Type.Title; |
|
0
|
318 |
MessageBox.Show(message); |
|
|
319 |
} |
|
|
320 |
|
|
|
321 |
/// <summary> |
|
|
322 |
/// Constructeur par défaut |
|
|
323 |
/// </summary> |
|
|
324 |
public AnnotationMakerVM() |
|
|
325 |
{ |
|
|
326 |
|
|
|
327 |
InitializeCommands(); |
|
|
328 |
|
|
|
329 |
} |
|
|
330 |
|
|
|
331 |
/// <summary> |
|
|
332 |
/// Constructeur par référence |
|
|
333 |
/// </summary> |
|
|
334 |
/// <param name="refAParam">Element référant</param> |
|
|
335 |
public AnnotationMakerVM(PolemicElement refAParam) |
|
|
336 |
{ |
|
|
337 |
|
|
|
338 |
|
|
|
339 |
RefElement = refAParam; |
|
|
340 |
|
|
|
341 |
|
|
|
342 |
|
|
|
343 |
_newAnnotation = new Annotation(RefElement.Chapter); |
|
|
344 |
_begin = RefElement.TimerIn; |
|
|
345 |
_end = RefElement.TimerOut; |
|
28
|
346 |
_basicRelation = new PolemicLink() { FromElement = RefElement, ToElement = _newAnnotation, Type = null}; |
|
0
|
347 |
_polemicRelation = new PolemicLink(); |
|
|
348 |
PolemicRelation.FromElement = _newAnnotation; |
|
|
349 |
InitializeCommands(); |
|
|
350 |
} |
|
|
351 |
|
|
|
352 |
|
|
28
|
353 |
public PolemicTypeDescription[] ListAnnotationDescription |
|
|
354 |
{ |
|
|
355 |
get |
|
|
356 |
{ |
|
|
357 |
return FactoryVideoLivre.AnnotationDescriptions; |
|
|
358 |
} |
|
|
359 |
|
|
|
360 |
} |
|
|
361 |
|
|
|
362 |
|
|
0
|
363 |
} |
|
|
364 |
|
|
|
365 |
} |