client/src/Iri.Modernisation.Controls/ViewModel/BookTimeLine/BookTimeLineVM.cs
changeset 38 bd33267300aa
parent 25 a9c815025a1b
child 42 594fdedecf7f
equal deleted inserted replaced
37:beb938b4fb76 38:bd33267300aa
    10 using System.Windows.Shapes;
    10 using System.Windows.Shapes;
    11 using Iri.Modernisation.Data.Models;
    11 using Iri.Modernisation.Data.Models;
    12 using Iri.Modernisation.BaseMVVM.Commands;
    12 using Iri.Modernisation.BaseMVVM.Commands;
    13 using Iri.Modernisation.BaseMVVM.ViewModel;
    13 using Iri.Modernisation.BaseMVVM.ViewModel;
    14 using System.Collections.Generic;
    14 using System.Collections.Generic;
       
    15 using System.IO;
    15 namespace Iri.Modernisation.Controls.ViewModel
    16 namespace Iri.Modernisation.Controls.ViewModel
    16 {
    17 {
    17     /// <summary>
    18     /// <summary>
    18     /// ViewModel du module BookTimeLine
    19     /// ViewModel du module BookTimeLine
    19     /// </summary>
    20     /// </summary>
    20     public class BookTimeLineVM : BaseMVVM.ViewModel.ViewModel
    21     public class BookTimeLineVM : BaseMVVM.ViewModel.ViewModel
    21     {
    22     {
    22         
    23         static public double ratioPixMs = 6000;
    23         private VideoBook _selectedBook;
    24         private VideoBook _selectedBook;
    24         /// <summary>
    25         /// <summary>
    25         /// Livre sélectionné
    26         /// Livre sélectionné
    26         /// </summary>
    27         /// </summary>
    27         public VideoBook SelectedBook
    28         public VideoBook SelectedBook
    98                 _selectedBook.Chapters = value;
    99                 _selectedBook.Chapters = value;
    99                 OnPropertyChanged("Chapters");
   100                 OnPropertyChanged("Chapters");
   100             }
   101             }
   101         }
   102         }
   102 
   103 
   103         
   104 
   104         private List<SegmentIndex>[] _segmentIndex=new List<SegmentIndex>[4];
   105         private List<SegmentIndex>[] _segmentIndex;
   105         /// <summary>
   106         /// <summary>
   106         /// Liste des Index des Chapitres
   107         /// Liste des Index des Chapitres
   107         /// </summary>
   108         /// </summary>
   108         public List<SegmentIndex>[] SegmentIndex
   109         public List<SegmentIndex>[] SegmentIndex
   109         {
   110         {
   116                 _segmentIndex = value;
   117                 _segmentIndex = value;
   117                 OnPropertyChanged("SegmentIndex");
   118                 OnPropertyChanged("SegmentIndex");
   118             }
   119             }
   119         }
   120         }
   120 
   121 
   121        
   122 
   122         private List<Annotation>[] _annotations=new List<Annotation>[4];
   123         private List<Annotation>[] _annotations;
   123         /// <summary>
   124         /// <summary>
   124         /// Liste des Annotations
   125         /// Liste des Annotations
   125         /// </summary>
   126         /// </summary>
   126         public List<Annotation>[] Annotations
   127         public List<Annotation>[] Annotations
   127         {
   128         {
   179         /// Constructeur    
   180         /// Constructeur    
   180         /// </summary>
   181         /// </summary>
   181         /// <param name="bookParam">VideoLivre à étudier</param>
   182         /// <param name="bookParam">VideoLivre à étudier</param>
   182         public BookTimeLineVM(VideoBook bookParam)
   183         public BookTimeLineVM(VideoBook bookParam)
   183         {
   184         {
       
   185             ScaleValue = 1;
   184             _selectedBook = bookParam;
   186             _selectedBook = bookParam;
   185             _title = bookParam.Title;
   187             _title = bookParam.Title;
   186             _author = bookParam.Author;
   188             _author = bookParam.Author;
   187             _chapters = bookParam.Chapters;
   189             _chapters = bookParam.Chapters;
   188             _totalDuration = bookParam.Duration;
   190             _totalDuration = bookParam.Duration;
       
   191             _segmentIndex = new List<SegmentIndex>[bookParam.Chapters.Length];
       
   192             _annotations = new List<Annotation>[bookParam.Chapters.Length];
   189             LoadElements();
   193             LoadElements();
   190             Commands.TimeChange.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(TimeChange_Executed);
   194             Commands.TimeChange.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(TimeChange_Executed);
   191 
   195             Commands.BookTimeLine.SaveAnnotations.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(SaveAnnotations_Executed);
   192         }
   196 
   193 
   197         }
       
   198 
       
   199         void SaveAnnotations_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e)
       
   200         {
       
   201          
       
   202         }
       
   203         private double _scaleValue;
       
   204         public double ScaleValue
       
   205         {
       
   206             get
       
   207             {
       
   208                 return _scaleValue;
       
   209             }
       
   210             set
       
   211             {
       
   212                 _scaleValue = value;
       
   213                 OnPropertyChanged("ScaleValue");
       
   214                 OnPropertyChanged("WidthTimeStrip");
       
   215             }
       
   216         }
       
   217         public double WidthTimeStrip
       
   218         {
       
   219             get
       
   220             {
       
   221                 return (_selectedBook.Duration.TotalMilliseconds / BookTimeLineVM.ratioPixMs) * ScaleValue;
       
   222             }
       
   223         }
   194         private VideoViewerVM _videoViewerVM;
   224         private VideoViewerVM _videoViewerVM;
   195         /// <summary>
   225         /// <summary>
   196         /// ViewModel de VideoViewer
   226         /// ViewModel de VideoViewer
   197         /// </summary>
   227         /// </summary>
   198         public VideoViewerVM ViewModelVideoViewer
   228         public VideoViewerVM ViewModelVideoViewer
   222         private void LoadElements()
   252         private void LoadElements()
   223         {
   253         {
   224             for(int key=0;key< _selectedBook.Chapters.Length;key++)
   254             for(int key=0;key< _selectedBook.Chapters.Length;key++)
   225             {
   255             {
   226               _segmentIndex[key] = _selectedBook.Chapters[key].Index;
   256               _segmentIndex[key] = _selectedBook.Chapters[key].Index;
   227                _annotations[key] = _selectedBook.Chapters[key].Annotations;
   257               if (_selectedBook.Chapters[key].Annotations != null)
       
   258                 {
       
   259                     _annotations[key] = _selectedBook.Chapters[key].Annotations;
       
   260                 }
   228             }
   261             }
   229         }
   262         }
   230       
   263       
   231     }
   264     }
   232 }
   265 }