| author | totetm <> |
| Fri, 12 Feb 2010 15:57:01 +0100 | |
| changeset 46 | ab3057b82260 |
| parent 42 | 594fdedecf7f |
| child 47 | 9b26023b8c83 |
| permissions | -rw-r--r-- |
| 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.Collections.Generic; |
|
12 |
using System.Collections; |
|
13 |
using Iri.Modernisation.Data.Models; |
|
14 |
using System.Linq; |
|
15 |
using Iri.Modernisation.BaseMVVM.Commands; |
|
16 |
using Iri.Modernisation.BaseMVVM.ViewModel; |
|
17 |
namespace Iri.Modernisation.Controls.ViewModel |
|
18 |
{ |
|
| 25 | 19 |
/// <summary> |
20 |
/// ViewModel de ConsultationBook |
|
21 |
/// </summary> |
|
| 0 | 22 |
public class ConsultationBookViewVM : BaseMVVM.ViewModel.ViewModel |
23 |
{ |
|
24 |
||
25 |
private VideoBook _selectedBook; |
|
| 25 | 26 |
/// <summary> |
27 |
/// Livre Sélectionné |
|
28 |
/// </summary> |
|
| 0 | 29 |
public VideoBook SelectedBook |
30 |
{ |
|
31 |
get |
|
32 |
{ |
|
33 |
return _selectedBook; |
|
34 |
} |
|
35 |
set |
|
36 |
{ |
|
37 |
_selectedBook = value; |
|
38 |
OnPropertyChanged(null); |
|
39 |
} |
|
40 |
} |
|
41 |
||
| 25 | 42 |
|
| 0 | 43 |
|
44 |
private SegmentIndex _selectedIndex; |
|
| 25 | 45 |
/// <summary> |
46 |
/// Index Sélectionné |
|
47 |
/// </summary> |
|
| 0 | 48 |
public SegmentIndex SelectedIndex |
49 |
{ |
|
50 |
get |
|
51 |
{ |
|
52 |
|
|
53 |
return _selectedIndex; |
|
54 |
} |
|
55 |
set |
|
56 |
{ |
|
| 42 | 57 |
if (value != null) |
| 0 | 58 |
{ |
| 42 | 59 |
_selectedIndex = value; |
60 |
_selectedIndexTitle = ((SegmentIndex)value).Title; |
|
61 |
_selectedIndexDescription = ((SegmentIndex)value).Description; |
|
62 |
_selectedIndexTags = ((SegmentIndex)value).Tags; |
|
63 |
_selectedBook = _selectedIndex.Chapter.Book; |
|
64 |
_title = _selectedIndex.Chapter.Book.Title; |
|
65 |
_author = _selectedIndex.Chapter.Book.Author; |
|
66 |
_chapters = _selectedIndex.Chapter.Book.Chapters; |
|
67 |
_selectedIndexAnnotation.Clear(); |
|
68 |
List<AnnotationViewerVM> _temp = new List<AnnotationViewerVM>(); |
|
69 |
foreach (Annotation An in ((SegmentIndex)value).Chapter.Annotations) |
|
| 0 | 70 |
{ |
| 42 | 71 |
if (An.TimerIn <= ((SegmentIndex)value).TimerOut && An.TimerOut >= ((SegmentIndex)value).TimerIn) |
72 |
{ |
|
73 |
_temp.Add(new AnnotationViewerVM(An)); |
|
74 |
} |
|
| 0 | 75 |
} |
| 42 | 76 |
SelectedIndexAnnotation = _temp; |
| 0 | 77 |
} |
| 42 | 78 |
else |
79 |
{ |
|
80 |
_selectedIndex = null; |
|
81 |
_selectedIndexTitle = String.Empty; |
|
82 |
_selectedIndexDescription = String.Empty; |
|
83 |
_selectedIndexTags = new List<string>(); |
|
84 |
_selectedBook = null; |
|
85 |
_title = null; |
|
86 |
_author = null; |
|
87 |
_chapters = null; |
|
88 |
_selectedIndexAnnotation.Clear(); |
|
89 |
|
|
90 |
SelectedIndexAnnotation = new List<AnnotationViewerVM>(); |
|
91 |
} |
|
| 0 | 92 |
OnPropertyChanged(null); |
93 |
|
|
94 |
|
|
95 |
} |
|
96 |
} |
|
97 |
||
98 |
private String _selectedIndexTitle; |
|
| 25 | 99 |
/// <summary> |
100 |
/// Titre de l'Index |
|
101 |
/// </summary> |
|
| 0 | 102 |
public String SelectedIndexTitle |
103 |
{ |
|
104 |
get |
|
105 |
{ |
|
106 |
return _selectedIndexTitle; |
|
107 |
} |
|
108 |
set |
|
109 |
{ |
|
110 |
_selectedIndexTitle = value; |
|
111 |
OnPropertyChanged("SelectedIndexTitle"); |
|
112 |
} |
|
113 |
} |
|
114 |
||
115 |
private String _selectedIndexDescription; |
|
| 25 | 116 |
/// <summary> |
117 |
/// Description de L'index |
|
118 |
/// </summary> |
|
| 0 | 119 |
public String SelectedIndexDescription |
120 |
{ |
|
121 |
get |
|
122 |
{ |
|
123 |
return _selectedIndexDescription; |
|
124 |
} |
|
125 |
set |
|
126 |
{ |
|
127 |
_selectedIndexDescription = value; |
|
128 |
OnPropertyChanged("SelectedIndexDescription"); |
|
129 |
} |
|
130 |
} |
|
131 |
||
132 |
private List<String> _selectedIndexTags = new List<string>(); |
|
| 25 | 133 |
/// <summary> |
134 |
/// Tags de l'Index |
|
135 |
/// </summary> |
|
| 0 | 136 |
public String SelectedIndexTags |
137 |
{ |
|
138 |
get |
|
139 |
{ |
|
140 |
try |
|
141 |
{ |
|
142 |
return String.Join(",", _selectedIndexTags.ToArray()); |
|
143 |
} |
|
144 |
catch |
|
145 |
{ |
|
146 |
return String.Empty; |
|
147 |
} |
|
148 |
} |
|
149 |
set |
|
150 |
{ |
|
151 |
String val = (String)value; |
|
152 |
_selectedIndexTags = val.Split(',').ToList(); |
|
153 |
OnPropertyChanged("SelectedIndexTags"); |
|
154 |
} |
|
155 |
} |
|
156 |
||
157 |
private List<AnnotationViewerVM> _selectedIndexAnnotation = new List<AnnotationViewerVM>(); |
|
| 25 | 158 |
/// <summary> |
159 |
/// Liste des annotations de l'index |
|
160 |
/// </summary> |
|
| 0 | 161 |
public List<AnnotationViewerVM> SelectedIndexAnnotation |
162 |
{ |
|
163 |
get |
|
164 |
{ |
|
165 |
return _selectedIndexAnnotation; |
|
166 |
} |
|
167 |
set |
|
168 |
{ |
|
169 |
_selectedIndexAnnotation = value; |
|
170 |
OnPropertyChanged("SelectedIndexAnnotation"); |
|
171 |
} |
|
172 |
} |
|
173 |
|
|
174 |
||
175 |
private String _title; |
|
| 25 | 176 |
/// <summary> |
177 |
/// Titre du VideoLivre |
|
178 |
/// </summary> |
|
| 0 | 179 |
public String Title |
180 |
{ |
|
181 |
get |
|
182 |
{ |
|
183 |
return _title; |
|
184 |
} |
|
185 |
private set |
|
186 |
{ |
|
187 |
_title = value; |
|
| 42 | 188 |
|
| 0 | 189 |
OnPropertyChanged("Title"); |
190 |
} |
|
191 |
} |
|
192 |
||
193 |
private User _author; |
|
| 25 | 194 |
/// <summary> |
195 |
/// Auteur du Videolivre |
|
196 |
/// </summary> |
|
| 0 | 197 |
public User Author |
198 |
{ |
|
199 |
get |
|
200 |
{ |
|
201 |
return _author; |
|
202 |
} |
|
203 |
private set |
|
204 |
{ |
|
205 |
_author = value; |
|
| 42 | 206 |
|
| 0 | 207 |
OnPropertyChanged("Author"); |
208 |
} |
|
209 |
||
210 |
} |
|
211 |
||
212 |
private VideoChapter[] _chapters; |
|
| 25 | 213 |
/// <summary> |
214 |
/// Chapitres du VideoLivre |
|
215 |
/// </summary> |
|
| 0 | 216 |
public VideoChapter[] Chapters |
217 |
{ |
|
218 |
get |
|
219 |
{ |
|
220 |
return _chapters; |
|
221 |
} |
|
222 |
private set |
|
223 |
{ |
|
224 |
_chapters = value; |
|
| 42 | 225 |
|
| 0 | 226 |
OnPropertyChanged("Chapters"); |
227 |
} |
|
228 |
} |
|
229 |
||
230 |
private List<SegmentIndex>[] _segmentIndex = new List<SegmentIndex>[4]; |
|
| 25 | 231 |
/// <summary> |
232 |
/// |
|
233 |
/// </summary> |
|
| 0 | 234 |
public List<SegmentIndex>[] SegmentIndex |
235 |
{ |
|
236 |
get |
|
237 |
{ |
|
238 |
return _segmentIndex; |
|
239 |
} |
|
240 |
set |
|
241 |
{ |
|
242 |
_segmentIndex = value; |
|
243 |
OnPropertyChanged("SegmentIndex"); |
|
244 |
} |
|
245 |
} |
|
246 |
||
247 |
private List<Annotation>[] _annotations = new List<Annotation>[4]; |
|
| 25 | 248 |
/// <summary> |
249 |
/// Annotations |
|
250 |
/// </summary> |
|
| 0 | 251 |
public List<Annotation>[] Annotations |
252 |
{ |
|
253 |
get |
|
254 |
{ |
|
255 |
return _annotations; |
|
256 |
} |
|
257 |
set |
|
258 |
{ |
|
259 |
_annotations = value; |
|
260 |
OnPropertyChanged("Annotations"); |
|
261 |
} |
|
262 |
} |
|
263 |
||
264 |
private BookTimeLineVM _selectedBookVM; |
|
| 25 | 265 |
/// <summary> |
266 |
/// ViewModel de BookTimeLine |
|
267 |
/// </summary> |
|
| 0 | 268 |
public BookTimeLineVM SelectedBookVM |
269 |
{ |
|
270 |
get |
|
271 |
{ |
|
272 |
return _selectedBookVM; |
|
273 |
} |
|
274 |
set |
|
275 |
{ |
|
| 42 | 276 |
if (value != null) |
277 |
{ |
|
278 |
_selectedBookVM = value; |
|
279 |
||
280 |
_selectedBook = value.SelectedBook; |
|
281 |
_title = value.SelectedBook.Title; |
|
282 |
_author = value.SelectedBook.Author; |
|
283 |
_chapters = value.SelectedBook.Chapters; |
|
284 |
ActualVideoSourceVM.Source = value.SelectedBook.MediaPath; |
|
| 0 | 285 |
ActualVideoSourceVM.Position = TimeSpan.FromMilliseconds(value.Position); |
| 42 | 286 |
|
287 |
||
288 |
||
289 |
SelectedIndex = value.SelectedBook.Chapters[0].Index[0]; |
|
290 |
Commands.GoToTime.Execute(value.Position); |
|
291 |
} |
|
292 |
else |
|
293 |
{ |
|
294 |
_selectedBookVM = null; |
|
295 |
_selectedBook = null; |
|
296 |
_title = null; |
|
297 |
_author = null; |
|
298 |
_chapters = null; |
|
299 |
ActualVideoSourceVM.Source = null; |
|
300 |
ActualVideoSourceVM.Position = TimeSpan.Zero; |
|
301 |
SelectedIndex = null; |
|
302 |
} |
|
303 |
OnPropertyChanged(String.Empty); |
|
304 |
|
|
| 0 | 305 |
} |
306 |
} |
|
307 |
private VideoViewerVM _actualVideoSourceVM; |
|
| 25 | 308 |
/// <summary> |
309 |
/// Video Actuellement en visionnage |
|
310 |
/// </summary> |
|
| 0 | 311 |
public VideoViewerVM ActualVideoSourceVM |
312 |
{ |
|
313 |
get |
|
314 |
{ |
|
315 |
return _actualVideoSourceVM; |
|
316 |
} |
|
317 |
set |
|
318 |
{ |
|
319 |
_actualVideoSourceVM = value; |
|
320 |
OnPropertyChanged("ActualVideoSourceVM"); |
|
321 |
} |
|
322 |
} |
|
323 |
public ConsultationBookViewVM() |
|
324 |
{ |
|
| 25 | 325 |
|
| 15 | 326 |
ActualVideoSourceVM = new VideoViewerVM(true,false); |
| 0 | 327 |
InitializeCommands(); |
328 |
||
329 |
||
330 |
} |
|
331 |
public ConsultationBookViewVM(BookTimeLineVM param) |
|
332 |
{ |
|
333 |
_selectedBookVM = param; |
|
334 |
_selectedBook = param.SelectedBook; |
|
335 |
_title = param.SelectedBook.Title; |
|
336 |
_author = param.SelectedBook.Author; |
|
337 |
_chapters = param.SelectedBook.Chapters; |
|
| 30 | 338 |
|
| 0 | 339 |
if (param.SelectedBook.Chapters[0].VideoSequences.Count != 0) |
340 |
{ |
|
| 15 | 341 |
ActualVideoSourceVM = new VideoViewerVM(true,false) { Source = param.SelectedBook.MediaPath }; |
| 0 | 342 |
} |
343 |
SelectedIndex = param.SelectedBook.Chapters[0].Index[0]; |
|
344 |
|
|
345 |
InitializeCommands(); |
|
| 42 | 346 |
|
347 |
|
|
| 0 | 348 |
|
| 42 | 349 |
} |
| 0 | 350 |
|
| 42 | 351 |
void ActualVideoSourceVM_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) |
352 |
{ |
|
353 |
|
|
354 |
if (e.PropertyName == "Position") |
|
355 |
{ |
|
356 |
if (SelectedBook != null) |
|
357 |
{ |
|
358 |
TimeSpan Pos = TimeSpan.FromMilliseconds(SelectedBookVM.Position); |
|
359 |
SelectedBookVM.Position = Pos.TotalMilliseconds; |
|
360 |
if (SelectedIndex.TimerOut < Pos || SelectedIndex.TimerIn > Pos) |
|
361 |
{ |
|
362 |
foreach (SegmentIndex Index in SelectedIndex.Chapter.Index) |
|
363 |
{ |
|
364 |
if (Index.TimerIn <= Pos && Index.TimerOut >= Pos) |
|
365 |
{ |
|
366 |
SelectedIndex = Index; |
|
367 |
} |
|
368 |
||
369 |
} |
|
370 |
} |
|
371 |
} |
|
372 |
} |
|
| 0 | 373 |
} |
374 |
private void InitializeCommands() |
|
375 |
{ |
|
| 22 | 376 |
ActualVideoSourceVM.Tick += new EventHandler<VideoViewerVMEventArgs>(ActualVideoSourceVM_Tick); |
| 42 | 377 |
Commands.TimeChange.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(TimeChange_Executed); |
378 |
} |
|
| 0 | 379 |
|
|
46
ab3057b82260
Fixed|pas de chaise musical pour la fonction tetris
totetm <>
parents:
42
diff
changeset
|
380 |
private void TimeChange_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) |
| 0 | 381 |
{ |
| 42 | 382 |
BookTimeLineVM BookTimeLineVM = (BookTimeLineVM)e.Source; |
383 |
||
384 |
if (BookTimeLineVM == this.SelectedBookVM) |
|
| 0 | 385 |
{ |
| 42 | 386 |
UpdateAnnotation(); |
387 |
} |
|
388 |
} |
|
389 |
||
|
46
ab3057b82260
Fixed|pas de chaise musical pour la fonction tetris
totetm <>
parents:
42
diff
changeset
|
390 |
public void UpdateAnnotation() |
| 42 | 391 |
{ |
392 |
if (SelectedBook != null) |
|
393 |
{ |
|
394 |
TimeSpan Pos = TimeSpan.FromMilliseconds(SelectedBookVM.Position); |
|
| 30 | 395 |
SelectedBookVM.Position = Pos.TotalMilliseconds; |
396 |
if (SelectedIndex.TimerOut < Pos || SelectedIndex.TimerIn > Pos) |
|
| 22 | 397 |
{ |
| 30 | 398 |
foreach (SegmentIndex Index in SelectedIndex.Chapter.Index) |
| 22 | 399 |
{ |
| 30 | 400 |
if (Index.TimerIn <= Pos && Index.TimerOut >= Pos) |
401 |
{ |
|
402 |
SelectedIndex = Index; |
|
403 |
} |
|
404 |
||
| 22 | 405 |
} |
406 |
} |
|
| 0 | 407 |
} |
408 |
} |
|
| 42 | 409 |
|
410 |
private void ActualVideoSourceVM_Tick(object sender, VideoViewerVMEventArgs e) |
|
411 |
{ |
|
|
46
ab3057b82260
Fixed|pas de chaise musical pour la fonction tetris
totetm <>
parents:
42
diff
changeset
|
412 |
|
|
ab3057b82260
Fixed|pas de chaise musical pour la fonction tetris
totetm <>
parents:
42
diff
changeset
|
413 |
SelectedBookVM.Position = e.Position.TotalMilliseconds; |
|
ab3057b82260
Fixed|pas de chaise musical pour la fonction tetris
totetm <>
parents:
42
diff
changeset
|
414 |
UpdateAnnotation(); |
|
ab3057b82260
Fixed|pas de chaise musical pour la fonction tetris
totetm <>
parents:
42
diff
changeset
|
415 |
|
| 42 | 416 |
} |
| 0 | 417 |
|
418 |
} |
|
419 |
} |