client/src/Iri.Modernisation.Controls/ViewModel/ProductionTimeLine/ProductionTimeLineVM.cs
changeset 20 c2dd8119a6c1
parent 19 7d044e7562ea
child 23 10acb6a11a73
equal deleted inserted replaced
19:7d044e7562ea 20:c2dd8119a6c1
    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 Iri.Modernisation.Controls.View;
    14 using Iri.Modernisation.Controls.View;
    15 using System.Collections.Generic;
    15 using System.Collections.Generic;
    16 using SLExtensions.Collections.ObjectModel;
    16 using System.Collections.ObjectModel;
       
    17 
    17 namespace Iri.Modernisation.Controls.ViewModel
    18 namespace Iri.Modernisation.Controls.ViewModel
    18 {
    19 {
    19     public class ProductionTimeLineVM : BaseMVVM.ViewModel.ViewModel
    20     public class ProductionTimeLineVM : BaseMVVM.ViewModel.ViewModel
    20     {
    21     {
    21 
    22 
    93                 _selectedChapter = value;
    94                 _selectedChapter = value;
    94                 OnPropertyChanged("SelectedChapter");
    95                 OnPropertyChanged("SelectedChapter");
    95             }
    96             }
    96         }
    97         }
    97 
    98 
    98        
    99 
    99     
   100 
   100         private List<SegmentIndex>[] _listSegmentIndex = new List<SegmentIndex>[4];
   101         private ObservableCollection<SegmentIndex>[] _listSegmentIndex;
   101         public List<SegmentIndex> SelectedIndex
   102         public ObservableCollection<SegmentIndex>[] ListIndex
       
   103         {
       
   104             get
       
   105             {
       
   106                 return _listSegmentIndex;
       
   107             }
       
   108         }
       
   109         public ObservableCollection<SegmentIndex> SelectedIndex
   102         {
   110         {
   103             get
   111             get
   104             {
   112             {
   105                 return _listSegmentIndex[SelectedChapter];
   113                 return _listSegmentIndex[SelectedChapter];
   106             }
   114             }
   107             set
   115             set
   108             {
   116             {
   109                 _listSegmentIndex[SelectedChapter] = value;
   117                 _listSegmentIndex[SelectedChapter] = value;
   110                 _newBook.Chapters[SelectedChapter].Index = value;
   118                 //_newBook.Chapters[SelectedChapter].Index = value;
   111                 OnPropertyChanged("SelectedIndex");
   119                 OnPropertyChanged("SelectedIndex");
   112             }
   120             }
   113         }
   121         }
   114 
   122 
   115         private VideoChapterType _selectedChapterType;
   123         private VideoChapterType _selectedChapterType;
   137                 new ObservableCollection<VideoSequence>(),
   145                 new ObservableCollection<VideoSequence>(),
   138                 new ObservableCollection<VideoSequence>()
   146                 new ObservableCollection<VideoSequence>()
   139             };
   147             };
   140            // PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(ProductionTimeLineVM_PropertyChanged);
   148            // PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(ProductionTimeLineVM_PropertyChanged);
   141            // SelectedVideoSequences = new ObservableCollection<VideoSequence>();
   149            // SelectedVideoSequences = new ObservableCollection<VideoSequence>();
       
   150             Commands.ProductionView.DelVideoSequence.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(DelVideoSequence_Executed);
   142             Commands.ProductionTimeLine.EditorPartSelected.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(EditorPartSelected_Executed);
   151             Commands.ProductionTimeLine.EditorPartSelected.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(EditorPartSelected_Executed);
   143             Commands.ProductionTimeLine.EditorPartFinished.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(EditorPartFinished_Executed);
   152             Commands.ProductionTimeLine.EditorPartFinished.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(EditorPartFinished_Executed);
       
   153             Commands.ProductionView.ClickAddIndex.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(ClickAddIndex_Executed);
   144             _listVideoSequences[0].CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(SelectedVideoSequences_CollectionChanged);
   154             _listVideoSequences[0].CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(SelectedVideoSequences_CollectionChanged);
   145             _listVideoSequences[1].CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(SelectedVideoSequences_CollectionChanged);
   155             _listVideoSequences[1].CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(SelectedVideoSequences_CollectionChanged);
   146             _listVideoSequences[2].CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(SelectedVideoSequences_CollectionChanged);
   156             _listVideoSequences[2].CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(SelectedVideoSequences_CollectionChanged);
   147             _listVideoSequences[3].CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(SelectedVideoSequences_CollectionChanged);
   157             _listVideoSequences[3].CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(SelectedVideoSequences_CollectionChanged);
   148       
   158 
       
   159             _listSegmentIndex = new ObservableCollection<SegmentIndex>[4]
       
   160             {
       
   161                 new ObservableCollection<SegmentIndex>(),
       
   162                 new ObservableCollection<SegmentIndex>(),
       
   163                 new ObservableCollection<SegmentIndex>(),
       
   164                 new ObservableCollection<SegmentIndex>()
       
   165             };
       
   166             _listSegmentIndex[0].CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(SelectedVideoSequences_CollectionChanged);
       
   167             _listSegmentIndex[1].CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(SelectedVideoSequences_CollectionChanged);
       
   168             _listSegmentIndex[2].CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(SelectedVideoSequences_CollectionChanged);
       
   169             _listSegmentIndex[3].CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(SelectedVideoSequences_CollectionChanged);
       
   170         }
       
   171 
       
   172         void ClickAddIndex_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e)
       
   173         {
       
   174             if(IsIndexing)
       
   175             {
       
   176                 TimeSpan dur = TimeSpan.Zero;
       
   177                 // Permet de créer un Index avec une durée calé sur les videos.
       
   178                 foreach (VideoSequence Vs in SelectedVideoSequences)
       
   179                 {
       
   180                     dur += Vs.Duration;
       
   181                 }
       
   182                 foreach (SegmentIndex Si in SelectedIndex)
       
   183                 {
       
   184                     dur -= Si.Duration;
       
   185                 }
       
   186                 SelectedIndex.Add(new SegmentIndex(SelectedBookChapter) 
       
   187                 { 
       
   188                     TimerIn = TimeSpan.Zero, 
       
   189                     TimerOut = dur,
       
   190                     Chapter = SelectedBookChapter
       
   191                 });
       
   192             }
       
   193  
       
   194         }
       
   195 
       
   196         void DelVideoSequence_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e)
       
   197         {
       
   198             SelectedVideoSequences.Remove(((CustomableVideoElementVM)e.Parameter).VideoSequence);
   149         }
   199         }
   150 
   200 
   151         void SelectedVideoSequences_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
   201         void SelectedVideoSequences_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
   152         {
   202         {
   153             Commands.ProductionView.VideoRecordUpdated.Execute();
   203             Commands.ProductionView.VideoRecordUpdated.Execute();
   154         }
   204         }
   155 
   205 
   156         void ProductionTimeLineVM_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
   206         void ProductionTimeLineVM_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
   157         {
   207         {
   158             Commands.ProductionView.VideoRecordUpdated.Execute();
   208             //Commands.ProductionView.VideoRecordUpdated.Execute();
   159         }
   209         }
   160 
   210 
   161         void EditorPartFinished_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e)
   211         void EditorPartFinished_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e)
   162         {
   212         {
   163             SelectedChapter = -1;
   213             SelectedChapter = -1;