|
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 System.Collections.Generic; |
|
|
12 |
using System.Collections; |
|
|
13 |
using Iri.Modernisation.Data.Models; |
|
|
14 |
using System.Linq; |
|
|
15 |
using Iri.Modernisation.BaseMVVM.Commands; |
|
|
16 |
using Iri.Modernisation.BaseMVVM.ViewModel; |
|
|
17 |
namespace Iri.Modernisation.Controls.ViewModel |
|
|
18 |
{ |
|
25
|
19 |
/// <summary> |
|
|
20 |
/// ViewModel de ConsultationBook |
|
|
21 |
/// </summary> |
|
0
|
22 |
public class ConsultationBookViewVM : BaseMVVM.ViewModel.ViewModel |
|
|
23 |
{ |
|
|
24 |
|
|
|
25 |
private VideoBook _selectedBook; |
|
25
|
26 |
/// <summary> |
|
|
27 |
/// Livre Sélectionné |
|
|
28 |
/// </summary> |
|
0
|
29 |
public VideoBook SelectedBook |
|
|
30 |
{ |
|
|
31 |
get |
|
|
32 |
{ |
|
|
33 |
return _selectedBook; |
|
|
34 |
} |
|
|
35 |
set |
|
|
36 |
{ |
|
|
37 |
_selectedBook = value; |
|
|
38 |
OnPropertyChanged(null); |
|
|
39 |
} |
|
|
40 |
} |
|
|
41 |
|
|
25
|
42 |
|
|
0
|
43 |
|
|
|
44 |
private SegmentIndex _selectedIndex; |
|
25
|
45 |
/// <summary> |
|
|
46 |
/// Index Sélectionné |
|
|
47 |
/// </summary> |
|
0
|
48 |
public SegmentIndex SelectedIndex |
|
|
49 |
{ |
|
|
50 |
get |
|
|
51 |
{ |
|
|
52 |
|
|
|
53 |
return _selectedIndex; |
|
|
54 |
} |
|
|
55 |
set |
|
|
56 |
{ |
|
|
57 |
_selectedIndex = value; |
|
|
58 |
_selectedIndexTitle = ((SegmentIndex)value).Title; |
|
|
59 |
_selectedIndexDescription = ((SegmentIndex)value).Description; |
|
|
60 |
_selectedIndexTags = ((SegmentIndex)value).Tags; |
|
|
61 |
_selectedBook = _selectedIndex.Chapter.Book; |
|
|
62 |
_title = _selectedIndex.Chapter.Book.Title; |
|
|
63 |
_author = _selectedIndex.Chapter.Book.Author; |
|
|
64 |
_chapters = _selectedIndex.Chapter.Book.Chapters; |
|
|
65 |
_selectedIndexAnnotation.Clear(); |
|
|
66 |
List<AnnotationViewerVM> _temp = new List<AnnotationViewerVM>(); |
|
|
67 |
foreach (Annotation An in ((SegmentIndex)value).Chapter.Annotations) |
|
|
68 |
{ |
|
|
69 |
if (An.TimerIn <= ((SegmentIndex)value).TimerOut && An.TimerOut >= ((SegmentIndex)value).TimerIn) |
|
|
70 |
{ |
|
|
71 |
_temp.Add(new AnnotationViewerVM (An)); |
|
|
72 |
} |
|
|
73 |
} |
|
|
74 |
SelectedIndexAnnotation = _temp; |
|
|
75 |
|
|
|
76 |
OnPropertyChanged(null); |
|
|
77 |
|
|
|
78 |
|
|
|
79 |
} |
|
|
80 |
} |
|
|
81 |
|
|
|
82 |
private String _selectedIndexTitle; |
|
25
|
83 |
/// <summary> |
|
|
84 |
/// Titre de l'Index |
|
|
85 |
/// </summary> |
|
0
|
86 |
public String SelectedIndexTitle |
|
|
87 |
{ |
|
|
88 |
get |
|
|
89 |
{ |
|
|
90 |
return _selectedIndexTitle; |
|
|
91 |
} |
|
|
92 |
set |
|
|
93 |
{ |
|
|
94 |
_selectedIndexTitle = value; |
|
|
95 |
OnPropertyChanged("SelectedIndexTitle"); |
|
|
96 |
} |
|
|
97 |
} |
|
|
98 |
|
|
|
99 |
private String _selectedIndexDescription; |
|
25
|
100 |
/// <summary> |
|
|
101 |
/// Description de L'index |
|
|
102 |
/// </summary> |
|
0
|
103 |
public String SelectedIndexDescription |
|
|
104 |
{ |
|
|
105 |
get |
|
|
106 |
{ |
|
|
107 |
return _selectedIndexDescription; |
|
|
108 |
} |
|
|
109 |
set |
|
|
110 |
{ |
|
|
111 |
_selectedIndexDescription = value; |
|
|
112 |
OnPropertyChanged("SelectedIndexDescription"); |
|
|
113 |
} |
|
|
114 |
} |
|
|
115 |
|
|
|
116 |
private List<String> _selectedIndexTags = new List<string>(); |
|
25
|
117 |
/// <summary> |
|
|
118 |
/// Tags de l'Index |
|
|
119 |
/// </summary> |
|
0
|
120 |
public String SelectedIndexTags |
|
|
121 |
{ |
|
|
122 |
get |
|
|
123 |
{ |
|
|
124 |
try |
|
|
125 |
{ |
|
|
126 |
return String.Join(",", _selectedIndexTags.ToArray()); |
|
|
127 |
} |
|
|
128 |
catch |
|
|
129 |
{ |
|
|
130 |
return String.Empty; |
|
|
131 |
} |
|
|
132 |
} |
|
|
133 |
set |
|
|
134 |
{ |
|
|
135 |
String val = (String)value; |
|
|
136 |
_selectedIndexTags = val.Split(',').ToList(); |
|
|
137 |
OnPropertyChanged("SelectedIndexTags"); |
|
|
138 |
} |
|
|
139 |
} |
|
|
140 |
|
|
|
141 |
private List<AnnotationViewerVM> _selectedIndexAnnotation = new List<AnnotationViewerVM>(); |
|
25
|
142 |
/// <summary> |
|
|
143 |
/// Liste des annotations de l'index |
|
|
144 |
/// </summary> |
|
0
|
145 |
public List<AnnotationViewerVM> SelectedIndexAnnotation |
|
|
146 |
{ |
|
|
147 |
get |
|
|
148 |
{ |
|
|
149 |
return _selectedIndexAnnotation; |
|
|
150 |
} |
|
|
151 |
set |
|
|
152 |
{ |
|
|
153 |
_selectedIndexAnnotation = value; |
|
|
154 |
OnPropertyChanged("SelectedIndexAnnotation"); |
|
|
155 |
} |
|
|
156 |
} |
|
|
157 |
|
|
|
158 |
|
|
|
159 |
private String _title; |
|
25
|
160 |
/// <summary> |
|
|
161 |
/// Titre du VideoLivre |
|
|
162 |
/// </summary> |
|
0
|
163 |
public String Title |
|
|
164 |
{ |
|
|
165 |
get |
|
|
166 |
{ |
|
|
167 |
return _title; |
|
|
168 |
} |
|
|
169 |
private set |
|
|
170 |
{ |
|
|
171 |
_title = value; |
|
|
172 |
_selectedBook.Title = value; |
|
|
173 |
OnPropertyChanged("Title"); |
|
|
174 |
} |
|
|
175 |
} |
|
|
176 |
|
|
|
177 |
private User _author; |
|
25
|
178 |
/// <summary> |
|
|
179 |
/// Auteur du Videolivre |
|
|
180 |
/// </summary> |
|
0
|
181 |
public User Author |
|
|
182 |
{ |
|
|
183 |
get |
|
|
184 |
{ |
|
|
185 |
return _author; |
|
|
186 |
} |
|
|
187 |
private set |
|
|
188 |
{ |
|
|
189 |
_author = value; |
|
|
190 |
_selectedBook.Author = value; |
|
|
191 |
OnPropertyChanged("Author"); |
|
|
192 |
} |
|
|
193 |
|
|
|
194 |
} |
|
|
195 |
|
|
|
196 |
private VideoChapter[] _chapters; |
|
25
|
197 |
/// <summary> |
|
|
198 |
/// Chapitres du VideoLivre |
|
|
199 |
/// </summary> |
|
0
|
200 |
public VideoChapter[] Chapters |
|
|
201 |
{ |
|
|
202 |
get |
|
|
203 |
{ |
|
|
204 |
return _chapters; |
|
|
205 |
} |
|
|
206 |
private set |
|
|
207 |
{ |
|
|
208 |
_chapters = value; |
|
|
209 |
_selectedBook.Chapters = value; |
|
|
210 |
OnPropertyChanged("Chapters"); |
|
|
211 |
} |
|
|
212 |
} |
|
|
213 |
|
|
|
214 |
private List<SegmentIndex>[] _segmentIndex = new List<SegmentIndex>[4]; |
|
25
|
215 |
/// <summary> |
|
|
216 |
/// |
|
|
217 |
/// </summary> |
|
0
|
218 |
public List<SegmentIndex>[] SegmentIndex |
|
|
219 |
{ |
|
|
220 |
get |
|
|
221 |
{ |
|
|
222 |
return _segmentIndex; |
|
|
223 |
} |
|
|
224 |
set |
|
|
225 |
{ |
|
|
226 |
_segmentIndex = value; |
|
|
227 |
OnPropertyChanged("SegmentIndex"); |
|
|
228 |
} |
|
|
229 |
} |
|
|
230 |
|
|
|
231 |
private List<Annotation>[] _annotations = new List<Annotation>[4]; |
|
25
|
232 |
/// <summary> |
|
|
233 |
/// Annotations |
|
|
234 |
/// </summary> |
|
0
|
235 |
public List<Annotation>[] Annotations |
|
|
236 |
{ |
|
|
237 |
get |
|
|
238 |
{ |
|
|
239 |
return _annotations; |
|
|
240 |
} |
|
|
241 |
set |
|
|
242 |
{ |
|
|
243 |
_annotations = value; |
|
|
244 |
OnPropertyChanged("Annotations"); |
|
|
245 |
} |
|
|
246 |
} |
|
|
247 |
|
|
|
248 |
private BookTimeLineVM _selectedBookVM; |
|
25
|
249 |
/// <summary> |
|
|
250 |
/// ViewModel de BookTimeLine |
|
|
251 |
/// </summary> |
|
0
|
252 |
public BookTimeLineVM SelectedBookVM |
|
|
253 |
{ |
|
|
254 |
get |
|
|
255 |
{ |
|
|
256 |
return _selectedBookVM; |
|
|
257 |
} |
|
|
258 |
set |
|
|
259 |
{ |
|
|
260 |
_selectedBookVM = value; |
|
|
261 |
|
|
|
262 |
_selectedBook = value.SelectedBook; |
|
|
263 |
_title = value.SelectedBook.Title; |
|
|
264 |
_author = value.SelectedBook.Author; |
|
|
265 |
_chapters = value.SelectedBook.Chapters; |
|
35
|
266 |
ActualVideoSourceVM.Source = value.SelectedBook.MediaPath; |
|
0
|
267 |
ActualVideoSourceVM.Position = TimeSpan.FromMilliseconds(value.Position); |
|
35
|
268 |
|
|
0
|
269 |
|
|
|
270 |
|
|
|
271 |
SelectedIndex = value.SelectedBook.Chapters[0].Index[0]; |
|
|
272 |
|
|
|
273 |
OnPropertyChanged(null); |
|
|
274 |
Commands.GoToTime.Execute(value.Position); |
|
|
275 |
} |
|
|
276 |
} |
|
|
277 |
private VideoViewerVM _actualVideoSourceVM; |
|
25
|
278 |
/// <summary> |
|
|
279 |
/// Video Actuellement en visionnage |
|
|
280 |
/// </summary> |
|
0
|
281 |
public VideoViewerVM ActualVideoSourceVM |
|
|
282 |
{ |
|
|
283 |
get |
|
|
284 |
{ |
|
|
285 |
return _actualVideoSourceVM; |
|
|
286 |
} |
|
|
287 |
set |
|
|
288 |
{ |
|
|
289 |
_actualVideoSourceVM = value; |
|
|
290 |
OnPropertyChanged("ActualVideoSourceVM"); |
|
|
291 |
} |
|
|
292 |
} |
|
|
293 |
public ConsultationBookViewVM() |
|
|
294 |
{ |
|
25
|
295 |
|
|
15
|
296 |
ActualVideoSourceVM = new VideoViewerVM(true,false); |
|
0
|
297 |
InitializeCommands(); |
|
|
298 |
|
|
|
299 |
|
|
|
300 |
} |
|
|
301 |
public ConsultationBookViewVM(BookTimeLineVM param) |
|
|
302 |
{ |
|
|
303 |
_selectedBookVM = param; |
|
|
304 |
_selectedBook = param.SelectedBook; |
|
|
305 |
_title = param.SelectedBook.Title; |
|
|
306 |
_author = param.SelectedBook.Author; |
|
|
307 |
_chapters = param.SelectedBook.Chapters; |
|
30
|
308 |
|
|
0
|
309 |
if (param.SelectedBook.Chapters[0].VideoSequences.Count != 0) |
|
|
310 |
{ |
|
15
|
311 |
ActualVideoSourceVM = new VideoViewerVM(true,false) { Source = param.SelectedBook.MediaPath }; |
|
0
|
312 |
} |
|
|
313 |
SelectedIndex = param.SelectedBook.Chapters[0].Index[0]; |
|
|
314 |
|
|
|
315 |
InitializeCommands(); |
|
|
316 |
|
|
|
317 |
|
|
|
318 |
} |
|
|
319 |
private void InitializeCommands() |
|
|
320 |
{ |
|
22
|
321 |
ActualVideoSourceVM.Tick += new EventHandler<VideoViewerVMEventArgs>(ActualVideoSourceVM_Tick); |
|
|
322 |
} |
|
0
|
323 |
|
|
25
|
324 |
private void ActualVideoSourceVM_Tick(object sender, VideoViewerVMEventArgs e) |
|
0
|
325 |
{ |
|
30
|
326 |
if(SelectedBook!=null) |
|
0
|
327 |
{ |
|
30
|
328 |
TimeSpan Pos = e.Position; |
|
|
329 |
SelectedBookVM.Position = Pos.TotalMilliseconds; |
|
|
330 |
if (SelectedIndex.TimerOut < Pos || SelectedIndex.TimerIn > Pos) |
|
22
|
331 |
{ |
|
30
|
332 |
foreach (SegmentIndex Index in SelectedIndex.Chapter.Index) |
|
22
|
333 |
{ |
|
30
|
334 |
if (Index.TimerIn <= Pos && Index.TimerOut >= Pos) |
|
|
335 |
{ |
|
|
336 |
SelectedIndex = Index; |
|
|
337 |
} |
|
|
338 |
|
|
22
|
339 |
} |
|
|
340 |
} |
|
0
|
341 |
} |
|
|
342 |
} |
|
|
343 |
|
|
|
344 |
} |
|
|
345 |
} |