client/src/Iri.Modernisation.Controls/ViewModel/BookTimeLine/BookTimeLineVM.cs
changeset 38 bd33267300aa
parent 25 a9c815025a1b
child 42 594fdedecf7f
--- a/client/src/Iri.Modernisation.Controls/ViewModel/BookTimeLine/BookTimeLineVM.cs	Wed Jan 27 10:55:59 2010 +0100
+++ b/client/src/Iri.Modernisation.Controls/ViewModel/BookTimeLine/BookTimeLineVM.cs	Thu Feb 04 16:38:04 2010 +0100
@@ -12,6 +12,7 @@
 using Iri.Modernisation.BaseMVVM.Commands;
 using Iri.Modernisation.BaseMVVM.ViewModel;
 using System.Collections.Generic;
+using System.IO;
 namespace Iri.Modernisation.Controls.ViewModel
 {
     /// <summary>
@@ -19,7 +20,7 @@
     /// </summary>
     public class BookTimeLineVM : BaseMVVM.ViewModel.ViewModel
     {
-        
+        static public double ratioPixMs = 6000;
         private VideoBook _selectedBook;
         /// <summary>
         /// Livre sélectionné
@@ -100,8 +101,8 @@
             }
         }
 
-        
-        private List<SegmentIndex>[] _segmentIndex=new List<SegmentIndex>[4];
+
+        private List<SegmentIndex>[] _segmentIndex;
         /// <summary>
         /// Liste des Index des Chapitres
         /// </summary>
@@ -118,8 +119,8 @@
             }
         }
 
-       
-        private List<Annotation>[] _annotations=new List<Annotation>[4];
+
+        private List<Annotation>[] _annotations;
         /// <summary>
         /// Liste des Annotations
         /// </summary>
@@ -181,16 +182,45 @@
         /// <param name="bookParam">VideoLivre à étudier</param>
         public BookTimeLineVM(VideoBook bookParam)
         {
+            ScaleValue = 1;
             _selectedBook = bookParam;
             _title = bookParam.Title;
             _author = bookParam.Author;
             _chapters = bookParam.Chapters;
             _totalDuration = bookParam.Duration;
+            _segmentIndex = new List<SegmentIndex>[bookParam.Chapters.Length];
+            _annotations = new List<Annotation>[bookParam.Chapters.Length];
             LoadElements();
             Commands.TimeChange.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(TimeChange_Executed);
+            Commands.BookTimeLine.SaveAnnotations.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(SaveAnnotations_Executed);
 
         }
 
+        void SaveAnnotations_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e)
+        {
+         
+        }
+        private double _scaleValue;
+        public double ScaleValue
+        {
+            get
+            {
+                return _scaleValue;
+            }
+            set
+            {
+                _scaleValue = value;
+                OnPropertyChanged("ScaleValue");
+                OnPropertyChanged("WidthTimeStrip");
+            }
+        }
+        public double WidthTimeStrip
+        {
+            get
+            {
+                return (_selectedBook.Duration.TotalMilliseconds / BookTimeLineVM.ratioPixMs) * ScaleValue;
+            }
+        }
         private VideoViewerVM _videoViewerVM;
         /// <summary>
         /// ViewModel de VideoViewer
@@ -224,7 +254,10 @@
             for(int key=0;key< _selectedBook.Chapters.Length;key++)
             {
               _segmentIndex[key] = _selectedBook.Chapters[key].Index;
-               _annotations[key] = _selectedBook.Chapters[key].Annotations;
+              if (_selectedBook.Chapters[key].Annotations != null)
+                {
+                    _annotations[key] = _selectedBook.Chapters[key].Annotations;
+                }
             }
         }