|
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; |
|
|
14 |
using System.Collections.Generic; |
|
38
|
15 |
using System.IO; |
|
0
|
16 |
namespace Iri.Modernisation.Controls.ViewModel |
|
|
17 |
{ |
|
|
18 |
/// <summary> |
|
|
19 |
/// ViewModel du module BookTimeLine |
|
|
20 |
/// </summary> |
|
|
21 |
public class BookTimeLineVM : BaseMVVM.ViewModel.ViewModel |
|
|
22 |
{ |
|
38
|
23 |
static public double ratioPixMs = 6000; |
|
25
|
24 |
private VideoBook _selectedBook; |
|
0
|
25 |
/// <summary> |
|
|
26 |
/// Livre sélectionné |
|
|
27 |
/// </summary> |
|
|
28 |
public VideoBook SelectedBook |
|
|
29 |
{ |
|
|
30 |
get |
|
|
31 |
{ |
|
|
32 |
return _selectedBook; |
|
|
33 |
} |
|
|
34 |
} |
|
|
35 |
|
|
|
36 |
/// <summary> |
|
25
|
37 |
/// Nom de l'auteur |
|
0
|
38 |
/// </summary> |
|
|
39 |
public String AuthorFullname |
|
|
40 |
{ |
|
|
41 |
get |
|
|
42 |
{ |
|
25
|
43 |
return Author.UserName; |
|
0
|
44 |
} |
|
|
45 |
} |
|
|
46 |
|
|
25
|
47 |
|
|
|
48 |
private String _title; |
|
0
|
49 |
/// <summary> |
|
|
50 |
/// Titre du Livre |
|
|
51 |
/// </summary> |
|
|
52 |
public String Title |
|
|
53 |
{ |
|
|
54 |
get |
|
|
55 |
{ |
|
|
56 |
return _title; |
|
|
57 |
} |
|
|
58 |
private set |
|
|
59 |
{ |
|
|
60 |
_title = value; |
|
|
61 |
_selectedBook.Title = value; |
|
|
62 |
OnPropertyChanged("Title"); |
|
|
63 |
} |
|
|
64 |
} |
|
|
65 |
|
|
25
|
66 |
|
|
|
67 |
private User _author; |
|
0
|
68 |
/// <summary> |
|
|
69 |
/// Auteur du Livre |
|
|
70 |
/// </summary> |
|
|
71 |
public User Author |
|
|
72 |
{ |
|
|
73 |
get |
|
|
74 |
{ |
|
|
75 |
return _author; |
|
|
76 |
} |
|
|
77 |
private set |
|
|
78 |
{ |
|
|
79 |
_author = value; |
|
|
80 |
_selectedBook.Author = value; |
|
|
81 |
OnPropertyChanged("Author"); |
|
|
82 |
} |
|
|
83 |
|
|
|
84 |
} |
|
|
85 |
|
|
25
|
86 |
private VideoChapter[] _chapters; |
|
0
|
87 |
/// <summary> |
|
|
88 |
/// Chapitre du Livre |
|
|
89 |
/// </summary> |
|
|
90 |
public VideoChapter[] Chapters |
|
|
91 |
{ |
|
|
92 |
get |
|
|
93 |
{ |
|
|
94 |
return _chapters; |
|
|
95 |
} |
|
|
96 |
private set |
|
|
97 |
{ |
|
|
98 |
_chapters = value; |
|
|
99 |
_selectedBook.Chapters = value; |
|
|
100 |
OnPropertyChanged("Chapters"); |
|
|
101 |
} |
|
|
102 |
} |
|
|
103 |
|
|
38
|
104 |
|
|
|
105 |
private List<SegmentIndex>[] _segmentIndex; |
|
0
|
106 |
/// <summary> |
|
|
107 |
/// Liste des Index des Chapitres |
|
|
108 |
/// </summary> |
|
|
109 |
public List<SegmentIndex>[] SegmentIndex |
|
|
110 |
{ |
|
|
111 |
get |
|
|
112 |
{ |
|
|
113 |
return _segmentIndex; |
|
|
114 |
} |
|
|
115 |
set |
|
|
116 |
{ |
|
|
117 |
_segmentIndex = value; |
|
|
118 |
OnPropertyChanged("SegmentIndex"); |
|
|
119 |
} |
|
|
120 |
} |
|
|
121 |
|
|
38
|
122 |
|
|
|
123 |
private List<Annotation>[] _annotations; |
|
0
|
124 |
/// <summary> |
|
|
125 |
/// Liste des Annotations |
|
|
126 |
/// </summary> |
|
|
127 |
public List<Annotation>[] Annotations |
|
|
128 |
{ |
|
|
129 |
get |
|
|
130 |
{ |
|
|
131 |
return _annotations; |
|
|
132 |
} |
|
|
133 |
set |
|
|
134 |
{ |
|
|
135 |
_annotations = value; |
|
|
136 |
OnPropertyChanged("Annotations"); |
|
|
137 |
} |
|
|
138 |
} |
|
|
139 |
|
|
25
|
140 |
|
|
|
141 |
private TimeSpan _totalDuration; |
|
0
|
142 |
/// <summary> |
|
|
143 |
/// Durée totale du Livre |
|
|
144 |
/// </summary> |
|
|
145 |
public double TotalDuration |
|
|
146 |
{ |
|
|
147 |
get |
|
|
148 |
{ |
|
|
149 |
return _totalDuration.TotalMilliseconds; |
|
|
150 |
} |
|
|
151 |
set |
|
|
152 |
{ |
|
|
153 |
_totalDuration = new TimeSpan(0, 0, 0, 0, (int)value); |
|
|
154 |
_selectedBook.Duration = new TimeSpan(0, 0, 0, 0, (int)value); ; |
|
|
155 |
OnPropertyChanged("Duration"); |
|
|
156 |
} |
|
|
157 |
} |
|
|
158 |
|
|
25
|
159 |
|
|
|
160 |
private double _position; |
|
0
|
161 |
/// <summary> |
|
|
162 |
/// Position du curseur de lecture |
|
|
163 |
/// </summary> |
|
|
164 |
public double Position |
|
|
165 |
{ |
|
|
166 |
get |
|
|
167 |
{ |
|
|
168 |
return _position; |
|
|
169 |
} |
|
|
170 |
set |
|
|
171 |
{ |
|
|
172 |
_position = value; |
|
|
173 |
OnPropertyChanged("Position"); |
|
|
174 |
} |
|
|
175 |
} |
|
|
176 |
|
|
25
|
177 |
|
|
0
|
178 |
|
|
|
179 |
/// <summary> |
|
|
180 |
/// Constructeur |
|
|
181 |
/// </summary> |
|
|
182 |
/// <param name="bookParam">VideoLivre à étudier</param> |
|
|
183 |
public BookTimeLineVM(VideoBook bookParam) |
|
|
184 |
{ |
|
38
|
185 |
ScaleValue = 1; |
|
0
|
186 |
_selectedBook = bookParam; |
|
|
187 |
_title = bookParam.Title; |
|
|
188 |
_author = bookParam.Author; |
|
|
189 |
_chapters = bookParam.Chapters; |
|
|
190 |
_totalDuration = bookParam.Duration; |
|
38
|
191 |
_segmentIndex = new List<SegmentIndex>[bookParam.Chapters.Length]; |
|
|
192 |
_annotations = new List<Annotation>[bookParam.Chapters.Length]; |
|
0
|
193 |
LoadElements(); |
|
|
194 |
Commands.TimeChange.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(TimeChange_Executed); |
|
42
|
195 |
|
|
0
|
196 |
|
|
|
197 |
} |
|
25
|
198 |
|
|
42
|
199 |
|
|
38
|
200 |
private double _scaleValue; |
|
|
201 |
public double ScaleValue |
|
|
202 |
{ |
|
|
203 |
get |
|
|
204 |
{ |
|
|
205 |
return _scaleValue; |
|
|
206 |
} |
|
|
207 |
set |
|
|
208 |
{ |
|
|
209 |
_scaleValue = value; |
|
|
210 |
OnPropertyChanged("ScaleValue"); |
|
|
211 |
OnPropertyChanged("WidthTimeStrip"); |
|
|
212 |
} |
|
|
213 |
} |
|
|
214 |
public double WidthTimeStrip |
|
|
215 |
{ |
|
|
216 |
get |
|
|
217 |
{ |
|
|
218 |
return (_selectedBook.Duration.TotalMilliseconds / BookTimeLineVM.ratioPixMs) * ScaleValue; |
|
|
219 |
} |
|
|
220 |
} |
|
23
|
221 |
private VideoViewerVM _videoViewerVM; |
|
25
|
222 |
/// <summary> |
|
|
223 |
/// ViewModel de VideoViewer |
|
|
224 |
/// </summary> |
|
23
|
225 |
public VideoViewerVM ViewModelVideoViewer |
|
|
226 |
{ |
|
|
227 |
get |
|
|
228 |
{ |
|
|
229 |
return _videoViewerVM; |
|
|
230 |
} |
|
|
231 |
set |
|
|
232 |
{ |
|
|
233 |
_videoViewerVM = value; |
|
|
234 |
OnPropertyChanged("ViewModelVideoViewer"); |
|
|
235 |
} |
|
|
236 |
} |
|
25
|
237 |
private void TimeChange_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) |
|
0
|
238 |
{ |
|
24
|
239 |
if(e.Source == this) |
|
|
240 |
{ |
|
|
241 |
ViewModelVideoViewer.GoTo(TimeSpan.FromMilliseconds(((double)e.Parameter))); |
|
|
242 |
} |
|
0
|
243 |
} |
|
|
244 |
|
|
|
245 |
|
|
|
246 |
/// <summary> |
|
|
247 |
/// Chargement des éléments du livre (Index et Annotations) |
|
|
248 |
/// </summary> |
|
|
249 |
private void LoadElements() |
|
|
250 |
{ |
|
|
251 |
for(int key=0;key< _selectedBook.Chapters.Length;key++) |
|
|
252 |
{ |
|
|
253 |
_segmentIndex[key] = _selectedBook.Chapters[key].Index; |
|
38
|
254 |
if (_selectedBook.Chapters[key].Annotations != null) |
|
|
255 |
{ |
|
|
256 |
_annotations[key] = _selectedBook.Chapters[key].Annotations; |
|
|
257 |
} |
|
0
|
258 |
} |
|
|
259 |
} |
|
|
260 |
|
|
|
261 |
} |
|
|
262 |
} |