52 |
52 |
53 return _selectedIndex; |
53 return _selectedIndex; |
54 } |
54 } |
55 set |
55 set |
56 { |
56 { |
57 _selectedIndex = value; |
57 if (value != null) |
58 _selectedIndexTitle = ((SegmentIndex)value).Title; |
58 { |
59 _selectedIndexDescription = ((SegmentIndex)value).Description; |
59 _selectedIndex = value; |
60 _selectedIndexTags = ((SegmentIndex)value).Tags; |
60 _selectedIndexTitle = ((SegmentIndex)value).Title; |
61 _selectedBook = _selectedIndex.Chapter.Book; |
61 _selectedIndexDescription = ((SegmentIndex)value).Description; |
62 _title = _selectedIndex.Chapter.Book.Title; |
62 _selectedIndexTags = ((SegmentIndex)value).Tags; |
63 _author = _selectedIndex.Chapter.Book.Author; |
63 _selectedBook = _selectedIndex.Chapter.Book; |
64 _chapters = _selectedIndex.Chapter.Book.Chapters; |
64 _title = _selectedIndex.Chapter.Book.Title; |
65 _selectedIndexAnnotation.Clear(); |
65 _author = _selectedIndex.Chapter.Book.Author; |
66 List<AnnotationViewerVM> _temp = new List<AnnotationViewerVM>(); |
66 _chapters = _selectedIndex.Chapter.Book.Chapters; |
67 foreach (Annotation An in ((SegmentIndex)value).Chapter.Annotations) |
67 _selectedIndexAnnotation.Clear(); |
68 { |
68 List<AnnotationViewerVM> _temp = new List<AnnotationViewerVM>(); |
69 if (An.TimerIn <= ((SegmentIndex)value).TimerOut && An.TimerOut >= ((SegmentIndex)value).TimerIn) |
69 foreach (Annotation An in ((SegmentIndex)value).Chapter.Annotations) |
70 { |
70 { |
71 _temp.Add(new AnnotationViewerVM (An)); |
71 if (An.TimerIn <= ((SegmentIndex)value).TimerOut && An.TimerOut >= ((SegmentIndex)value).TimerIn) |
|
72 { |
|
73 _temp.Add(new AnnotationViewerVM(An)); |
|
74 } |
72 } |
75 } |
73 } |
76 SelectedIndexAnnotation = _temp; |
74 SelectedIndexAnnotation = _temp; |
77 } |
75 |
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 } |
76 OnPropertyChanged(null); |
92 OnPropertyChanged(null); |
77 |
93 |
78 |
94 |
79 } |
95 } |
80 } |
96 } |
255 { |
271 { |
256 return _selectedBookVM; |
272 return _selectedBookVM; |
257 } |
273 } |
258 set |
274 set |
259 { |
275 { |
260 _selectedBookVM = value; |
276 if (value != null) |
261 |
277 { |
262 _selectedBook = value.SelectedBook; |
278 _selectedBookVM = value; |
263 _title = value.SelectedBook.Title; |
279 |
264 _author = value.SelectedBook.Author; |
280 _selectedBook = value.SelectedBook; |
265 _chapters = value.SelectedBook.Chapters; |
281 _title = value.SelectedBook.Title; |
266 ActualVideoSourceVM.Source = value.SelectedBook.MediaPath; |
282 _author = value.SelectedBook.Author; |
|
283 _chapters = value.SelectedBook.Chapters; |
|
284 ActualVideoSourceVM.Source = value.SelectedBook.MediaPath; |
267 ActualVideoSourceVM.Position = TimeSpan.FromMilliseconds(value.Position); |
285 ActualVideoSourceVM.Position = TimeSpan.FromMilliseconds(value.Position); |
268 |
286 |
269 |
287 |
270 |
288 |
271 SelectedIndex = value.SelectedBook.Chapters[0].Index[0]; |
289 SelectedIndex = value.SelectedBook.Chapters[0].Index[0]; |
272 |
290 Commands.GoToTime.Execute(value.Position); |
273 OnPropertyChanged(null); |
291 } |
274 Commands.GoToTime.Execute(value.Position); |
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 |
275 } |
305 } |
276 } |
306 } |
277 private VideoViewerVM _actualVideoSourceVM; |
307 private VideoViewerVM _actualVideoSourceVM; |
278 /// <summary> |
308 /// <summary> |
279 /// Video Actuellement en visionnage |
309 /// Video Actuellement en visionnage |
311 ActualVideoSourceVM = new VideoViewerVM(true,false) { Source = param.SelectedBook.MediaPath }; |
341 ActualVideoSourceVM = new VideoViewerVM(true,false) { Source = param.SelectedBook.MediaPath }; |
312 } |
342 } |
313 SelectedIndex = param.SelectedBook.Chapters[0].Index[0]; |
343 SelectedIndex = param.SelectedBook.Chapters[0].Index[0]; |
314 |
344 |
315 InitializeCommands(); |
345 InitializeCommands(); |
316 |
346 |
317 |
347 |
|
348 |
|
349 } |
|
350 |
|
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 } |
318 } |
373 } |
319 private void InitializeCommands() |
374 private void InitializeCommands() |
320 { |
375 { |
321 ActualVideoSourceVM.Tick += new EventHandler<VideoViewerVMEventArgs>(ActualVideoSourceVM_Tick); |
376 ActualVideoSourceVM.Tick += new EventHandler<VideoViewerVMEventArgs>(ActualVideoSourceVM_Tick); |
322 } |
377 Commands.TimeChange.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(TimeChange_Executed); |
323 |
378 } |
324 private void ActualVideoSourceVM_Tick(object sender, VideoViewerVMEventArgs e) |
379 |
325 { |
380 void TimeChange_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) |
326 if(SelectedBook!=null) |
381 { |
327 { |
382 BookTimeLineVM BookTimeLineVM = (BookTimeLineVM)e.Source; |
328 TimeSpan Pos = e.Position; |
383 |
|
384 if (BookTimeLineVM == this.SelectedBookVM) |
|
385 { |
|
386 UpdateAnnotation(); |
|
387 } |
|
388 } |
|
389 |
|
390 private void UpdateAnnotation() |
|
391 { |
|
392 if (SelectedBook != null) |
|
393 { |
|
394 TimeSpan Pos = TimeSpan.FromMilliseconds(SelectedBookVM.Position); |
329 SelectedBookVM.Position = Pos.TotalMilliseconds; |
395 SelectedBookVM.Position = Pos.TotalMilliseconds; |
330 if (SelectedIndex.TimerOut < Pos || SelectedIndex.TimerIn > Pos) |
396 if (SelectedIndex.TimerOut < Pos || SelectedIndex.TimerIn > Pos) |
331 { |
397 { |
332 foreach (SegmentIndex Index in SelectedIndex.Chapter.Index) |
398 foreach (SegmentIndex Index in SelectedIndex.Chapter.Index) |
333 { |
399 { |