| author | Matthieu Totet |
| Mon, 14 Dec 2009 17:02:03 +0100 | |
| changeset 23 | 10acb6a11a73 |
| parent 20 | c2dd8119a6c1 |
| child 24 | c031f1132dde |
| 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 Iri.Modernisation.Data.Models; |
|
12 |
using Iri.Modernisation.BaseMVVM.Commands; |
|
13 |
using Iri.Modernisation.BaseMVVM.ViewModel; |
|
| 17 | 14 |
using Iri.Modernisation.Controls.View; |
| 0 | 15 |
using System.Collections.Generic; |
| 20 | 16 |
using System.Collections.ObjectModel; |
17 |
||
| 0 | 18 |
namespace Iri.Modernisation.Controls.ViewModel |
19 |
{ |
|
20 |
public class ProductionTimeLineVM : BaseMVVM.ViewModel.ViewModel |
|
21 |
{ |
|
22 |
||
| 17 | 23 |
|
24 |
private bool _isIndexing; |
|
25 |
public bool IsIndexing |
|
26 |
{ |
|
27 |
get |
|
28 |
{ |
|
29 |
return _isIndexing; |
|
30 |
} |
|
31 |
set |
|
32 |
{ |
|
33 |
_isIndexing = value; |
|
34 |
OnPropertyChanged("IsIndexing"); |
|
35 |
} |
|
36 |
} |
|
| 0 | 37 |
|
38 |
private VideoBook _newBook; |
|
| 19 | 39 |
private ObservableCollection<VideoSequence>[] _listVideoSequences = new ObservableCollection<VideoSequence>[4]; |
40 |
public ObservableCollection<VideoSequence>[] ListVideoSequences |
|
| 0 | 41 |
{ |
42 |
get |
|
43 |
{ |
|
| 19 | 44 |
return _listVideoSequences; |
45 |
} |
|
46 |
set |
|
47 |
{ |
|
48 |
_listVideoSequences = value; |
|
49 |
OnPropertyChanged("ListVideoSequences"); |
|
50 |
} |
|
51 |
} |
|
52 |
|
|
53 |
public ObservableCollection<VideoSequence> SelectedVideoSequences |
|
54 |
{ |
|
55 |
get |
|
56 |
{ |
|
57 |
|
|
| 0 | 58 |
return _listVideoSequences[SelectedChapter]; |
59 |
} |
|
60 |
set |
|
61 |
{ |
|
62 |
_listVideoSequences[SelectedChapter] = value; |
|
| 19 | 63 |
//_newBook.Chapters[SelectedChapter].VideoSequences = value; |
| 0 | 64 |
OnPropertyChanged("SelectedVideoSequences"); |
65 |
} |
|
66 |
} |
|
|
23
10acb6a11a73
Update VideoViewer ( Allow Multi-VideoViewer)
Matthieu Totet
parents:
20
diff
changeset
|
67 |
public TimeSpan TotalBookDuration |
|
10acb6a11a73
Update VideoViewer ( Allow Multi-VideoViewer)
Matthieu Totet
parents:
20
diff
changeset
|
68 |
{ |
|
10acb6a11a73
Update VideoViewer ( Allow Multi-VideoViewer)
Matthieu Totet
parents:
20
diff
changeset
|
69 |
get |
|
10acb6a11a73
Update VideoViewer ( Allow Multi-VideoViewer)
Matthieu Totet
parents:
20
diff
changeset
|
70 |
{ |
|
10acb6a11a73
Update VideoViewer ( Allow Multi-VideoViewer)
Matthieu Totet
parents:
20
diff
changeset
|
71 |
TimeSpan temp = TimeSpan.Zero; |
|
10acb6a11a73
Update VideoViewer ( Allow Multi-VideoViewer)
Matthieu Totet
parents:
20
diff
changeset
|
72 |
foreach (ObservableCollection<VideoSequence> Ocvs in _listVideoSequences) |
|
10acb6a11a73
Update VideoViewer ( Allow Multi-VideoViewer)
Matthieu Totet
parents:
20
diff
changeset
|
73 |
{ |
|
10acb6a11a73
Update VideoViewer ( Allow Multi-VideoViewer)
Matthieu Totet
parents:
20
diff
changeset
|
74 |
foreach (VideoSequence Vs in Ocvs) |
|
10acb6a11a73
Update VideoViewer ( Allow Multi-VideoViewer)
Matthieu Totet
parents:
20
diff
changeset
|
75 |
{ |
|
10acb6a11a73
Update VideoViewer ( Allow Multi-VideoViewer)
Matthieu Totet
parents:
20
diff
changeset
|
76 |
temp += Vs.Duration; |
|
10acb6a11a73
Update VideoViewer ( Allow Multi-VideoViewer)
Matthieu Totet
parents:
20
diff
changeset
|
77 |
} |
|
10acb6a11a73
Update VideoViewer ( Allow Multi-VideoViewer)
Matthieu Totet
parents:
20
diff
changeset
|
78 |
} |
|
10acb6a11a73
Update VideoViewer ( Allow Multi-VideoViewer)
Matthieu Totet
parents:
20
diff
changeset
|
79 |
return temp; |
|
10acb6a11a73
Update VideoViewer ( Allow Multi-VideoViewer)
Matthieu Totet
parents:
20
diff
changeset
|
80 |
} |
|
10acb6a11a73
Update VideoViewer ( Allow Multi-VideoViewer)
Matthieu Totet
parents:
20
diff
changeset
|
81 |
} |
| 17 | 82 |
public VideoChapter[] Chapters |
83 |
{ |
|
84 |
get |
|
85 |
{ |
|
86 |
return _newBook.Chapters; |
|
87 |
} |
|
88 |
|
|
89 |
|
|
90 |
} |
|
91 |
public VideoChapter SelectedBookChapter |
|
92 |
{ |
|
93 |
get |
|
94 |
{ |
|
95 |
return _newBook.Chapters[SelectedChapter]; |
|
96 |
} |
|
97 |
} |
|
98 |
||
| 0 | 99 |
private int _selectedChapter=0; |
100 |
public int SelectedChapter |
|
101 |
{ |
|
102 |
get |
|
103 |
{ |
|
104 |
return _selectedChapter; |
|
105 |
} |
|
106 |
set |
|
107 |
{ |
|
108 |
_selectedChapter = value; |
|
109 |
OnPropertyChanged("SelectedChapter"); |
|
110 |
} |
|
111 |
} |
|
112 |
||
| 20 | 113 |
|
|
23
10acb6a11a73
Update VideoViewer ( Allow Multi-VideoViewer)
Matthieu Totet
parents:
20
diff
changeset
|
114 |
private double _position; |
|
10acb6a11a73
Update VideoViewer ( Allow Multi-VideoViewer)
Matthieu Totet
parents:
20
diff
changeset
|
115 |
public double Position |
|
10acb6a11a73
Update VideoViewer ( Allow Multi-VideoViewer)
Matthieu Totet
parents:
20
diff
changeset
|
116 |
{ |
|
10acb6a11a73
Update VideoViewer ( Allow Multi-VideoViewer)
Matthieu Totet
parents:
20
diff
changeset
|
117 |
get |
|
10acb6a11a73
Update VideoViewer ( Allow Multi-VideoViewer)
Matthieu Totet
parents:
20
diff
changeset
|
118 |
{ |
|
10acb6a11a73
Update VideoViewer ( Allow Multi-VideoViewer)
Matthieu Totet
parents:
20
diff
changeset
|
119 |
return _position; |
|
10acb6a11a73
Update VideoViewer ( Allow Multi-VideoViewer)
Matthieu Totet
parents:
20
diff
changeset
|
120 |
} |
|
10acb6a11a73
Update VideoViewer ( Allow Multi-VideoViewer)
Matthieu Totet
parents:
20
diff
changeset
|
121 |
set |
|
10acb6a11a73
Update VideoViewer ( Allow Multi-VideoViewer)
Matthieu Totet
parents:
20
diff
changeset
|
122 |
{ |
|
10acb6a11a73
Update VideoViewer ( Allow Multi-VideoViewer)
Matthieu Totet
parents:
20
diff
changeset
|
123 |
_position = value; |
|
10acb6a11a73
Update VideoViewer ( Allow Multi-VideoViewer)
Matthieu Totet
parents:
20
diff
changeset
|
124 |
OnPropertyChanged("Position"); |
|
10acb6a11a73
Update VideoViewer ( Allow Multi-VideoViewer)
Matthieu Totet
parents:
20
diff
changeset
|
125 |
} |
|
10acb6a11a73
Update VideoViewer ( Allow Multi-VideoViewer)
Matthieu Totet
parents:
20
diff
changeset
|
126 |
} |
| 20 | 127 |
|
128 |
private ObservableCollection<SegmentIndex>[] _listSegmentIndex; |
|
129 |
public ObservableCollection<SegmentIndex>[] ListIndex |
|
130 |
{ |
|
131 |
get |
|
132 |
{ |
|
133 |
return _listSegmentIndex; |
|
134 |
} |
|
135 |
} |
|
136 |
public ObservableCollection<SegmentIndex> SelectedIndex |
|
| 0 | 137 |
{ |
138 |
get |
|
139 |
{ |
|
140 |
return _listSegmentIndex[SelectedChapter]; |
|
141 |
} |
|
142 |
set |
|
143 |
{ |
|
144 |
_listSegmentIndex[SelectedChapter] = value; |
|
| 20 | 145 |
//_newBook.Chapters[SelectedChapter].Index = value; |
| 0 | 146 |
OnPropertyChanged("SelectedIndex"); |
147 |
} |
|
148 |
} |
|
149 |
||
| 17 | 150 |
private VideoChapterType _selectedChapterType; |
151 |
public VideoChapterType SelectedChapterType |
|
152 |
{ |
|
153 |
get |
|
154 |
{ |
|
155 |
return _selectedChapterType; |
|
156 |
} |
|
157 |
set |
|
158 |
{ |
|
159 |
_selectedChapterType = value; |
|
160 |
OnPropertyChanged("SelectedChapterType"); |
|
161 |
} |
|
162 |
} |
|
163 |
|
|
164 |
|
|
| 0 | 165 |
public ProductionTimeLineVM() |
166 |
{ |
|
167 |
_newBook = new VideoBook(); |
|
| 19 | 168 |
_listVideoSequences = new ObservableCollection<VideoSequence>[4] |
169 |
{ |
|
170 |
new ObservableCollection<VideoSequence>(), |
|
171 |
new ObservableCollection<VideoSequence>(), |
|
172 |
new ObservableCollection<VideoSequence>(), |
|
173 |
new ObservableCollection<VideoSequence>() |
|
174 |
}; |
|
175 |
// PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(ProductionTimeLineVM_PropertyChanged); |
|
176 |
// SelectedVideoSequences = new ObservableCollection<VideoSequence>(); |
|
| 20 | 177 |
Commands.ProductionView.DelVideoSequence.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(DelVideoSequence_Executed); |
| 17 | 178 |
Commands.ProductionTimeLine.EditorPartSelected.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(EditorPartSelected_Executed); |
| 18 | 179 |
Commands.ProductionTimeLine.EditorPartFinished.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(EditorPartFinished_Executed); |
| 20 | 180 |
Commands.ProductionView.ClickAddIndex.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(ClickAddIndex_Executed); |
| 19 | 181 |
_listVideoSequences[0].CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(SelectedVideoSequences_CollectionChanged); |
182 |
_listVideoSequences[1].CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(SelectedVideoSequences_CollectionChanged); |
|
183 |
_listVideoSequences[2].CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(SelectedVideoSequences_CollectionChanged); |
|
184 |
_listVideoSequences[3].CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(SelectedVideoSequences_CollectionChanged); |
|
| 20 | 185 |
|
186 |
_listSegmentIndex = new ObservableCollection<SegmentIndex>[4] |
|
187 |
{ |
|
188 |
new ObservableCollection<SegmentIndex>(), |
|
189 |
new ObservableCollection<SegmentIndex>(), |
|
190 |
new ObservableCollection<SegmentIndex>(), |
|
191 |
new ObservableCollection<SegmentIndex>() |
|
192 |
}; |
|
193 |
_listSegmentIndex[0].CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(SelectedVideoSequences_CollectionChanged); |
|
194 |
_listSegmentIndex[1].CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(SelectedVideoSequences_CollectionChanged); |
|
195 |
_listSegmentIndex[2].CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(SelectedVideoSequences_CollectionChanged); |
|
196 |
_listSegmentIndex[3].CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(SelectedVideoSequences_CollectionChanged); |
|
197 |
} |
|
198 |
||
199 |
void ClickAddIndex_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) |
|
200 |
{ |
|
201 |
if(IsIndexing) |
|
202 |
{ |
|
203 |
TimeSpan dur = TimeSpan.Zero; |
|
204 |
// Permet de créer un Index avec une durée calé sur les videos. |
|
205 |
foreach (VideoSequence Vs in SelectedVideoSequences) |
|
206 |
{ |
|
207 |
dur += Vs.Duration; |
|
208 |
} |
|
209 |
foreach (SegmentIndex Si in SelectedIndex) |
|
210 |
{ |
|
211 |
dur -= Si.Duration; |
|
212 |
} |
|
213 |
SelectedIndex.Add(new SegmentIndex(SelectedBookChapter) |
|
214 |
{ |
|
215 |
TimerIn = TimeSpan.Zero, |
|
216 |
TimerOut = dur, |
|
217 |
Chapter = SelectedBookChapter |
|
218 |
}); |
|
|
23
10acb6a11a73
Update VideoViewer ( Allow Multi-VideoViewer)
Matthieu Totet
parents:
20
diff
changeset
|
219 |
|
| 20 | 220 |
} |
221 |
|
|
222 |
} |
|
223 |
||
224 |
void DelVideoSequence_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) |
|
225 |
{ |
|
226 |
SelectedVideoSequences.Remove(((CustomableVideoElementVM)e.Parameter).VideoSequence); |
|
|
23
10acb6a11a73
Update VideoViewer ( Allow Multi-VideoViewer)
Matthieu Totet
parents:
20
diff
changeset
|
227 |
OnPropertyChanged("TotalBookDuration"); |
| 19 | 228 |
} |
229 |
||
230 |
void SelectedVideoSequences_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) |
|
231 |
{ |
|
|
23
10acb6a11a73
Update VideoViewer ( Allow Multi-VideoViewer)
Matthieu Totet
parents:
20
diff
changeset
|
232 |
OnPropertyChanged("TotalBookDuration"); |
| 19 | 233 |
Commands.ProductionView.VideoRecordUpdated.Execute(); |
234 |
} |
|
235 |
||
236 |
void ProductionTimeLineVM_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) |
|
237 |
{ |
|
| 20 | 238 |
//Commands.ProductionView.VideoRecordUpdated.Execute(); |
| 19 | 239 |
} |
| 17 | 240 |
|
| 18 | 241 |
void EditorPartFinished_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) |
242 |
{ |
|
243 |
SelectedChapter = -1; |
|
244 |
} |
|
245 |
||
| 17 | 246 |
void EditorPartSelected_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) |
247 |
{ |
|
| 18 | 248 |
|
249 |
SelectedChapter = (int)((HeaderProductionEventArgs)e.Source).ChapterType; |
|
| 17 | 250 |
SelectedChapterType = ((HeaderProductionEventArgs)e.Source).ChapterType ; |
251 |
IsIndexing = ((HeaderProductionEventArgs)e.Source).IsIndexPart; |
|
| 0 | 252 |
} |
|
23
10acb6a11a73
Update VideoViewer ( Allow Multi-VideoViewer)
Matthieu Totet
parents:
20
diff
changeset
|
253 |
|
| 0 | 254 |
} |
255 |
} |