|
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; |
|
15 namespace Iri.Modernisation.Controls.ViewModel |
|
16 { |
|
17 /// <summary> |
|
18 /// ViewModel du module BookTimeLine |
|
19 /// </summary> |
|
20 public class BookTimeLineVM : BaseMVVM.ViewModel.ViewModel |
|
21 { |
|
22 /// <summary> |
|
23 /// Livre sélectionné |
|
24 /// </summary> |
|
25 private VideoBook _selectedBook; |
|
26 public VideoBook SelectedBook |
|
27 { |
|
28 get |
|
29 { |
|
30 return _selectedBook; |
|
31 } |
|
32 } |
|
33 |
|
34 /// <summary> |
|
35 /// |
|
36 /// </summary> |
|
37 public String AuthorFullname |
|
38 { |
|
39 get |
|
40 { |
|
41 return Author.FirstName + " " + Author.Name; |
|
42 } |
|
43 } |
|
44 |
|
45 /// <summary> |
|
46 /// Titre du Livre |
|
47 /// </summary> |
|
48 private String _title; |
|
49 public String Title |
|
50 { |
|
51 get |
|
52 { |
|
53 return _title; |
|
54 } |
|
55 private set |
|
56 { |
|
57 _title = value; |
|
58 _selectedBook.Title = value; |
|
59 OnPropertyChanged("Title"); |
|
60 } |
|
61 } |
|
62 |
|
63 /// <summary> |
|
64 /// Auteur du Livre |
|
65 /// </summary> |
|
66 private User _author; |
|
67 public User Author |
|
68 { |
|
69 get |
|
70 { |
|
71 return _author; |
|
72 } |
|
73 private set |
|
74 { |
|
75 _author = value; |
|
76 _selectedBook.Author = value; |
|
77 OnPropertyChanged("Author"); |
|
78 } |
|
79 |
|
80 } |
|
81 |
|
82 /// <summary> |
|
83 /// Chapitre du Livre |
|
84 /// </summary> |
|
85 private VideoChapter[] _chapters; |
|
86 public VideoChapter[] Chapters |
|
87 { |
|
88 get |
|
89 { |
|
90 return _chapters; |
|
91 } |
|
92 private set |
|
93 { |
|
94 _chapters = value; |
|
95 _selectedBook.Chapters = value; |
|
96 OnPropertyChanged("Chapters"); |
|
97 } |
|
98 } |
|
99 |
|
100 /// <summary> |
|
101 /// Liste des Index des Chapitres |
|
102 /// </summary> |
|
103 private List<SegmentIndex>[] _segmentIndex=new List<SegmentIndex>[4]; |
|
104 public List<SegmentIndex>[] SegmentIndex |
|
105 { |
|
106 get |
|
107 { |
|
108 return _segmentIndex; |
|
109 } |
|
110 set |
|
111 { |
|
112 _segmentIndex = value; |
|
113 OnPropertyChanged("SegmentIndex"); |
|
114 } |
|
115 } |
|
116 |
|
117 /// <summary> |
|
118 /// Liste des Annotations |
|
119 /// </summary> |
|
120 private List<Annotation>[] _annotations=new List<Annotation>[4]; |
|
121 public List<Annotation>[] Annotations |
|
122 { |
|
123 get |
|
124 { |
|
125 return _annotations; |
|
126 } |
|
127 set |
|
128 { |
|
129 _annotations = value; |
|
130 OnPropertyChanged("Annotations"); |
|
131 } |
|
132 } |
|
133 |
|
134 /// <summary> |
|
135 /// Durée totale du Livre |
|
136 /// </summary> |
|
137 private TimeSpan _totalDuration; |
|
138 public double TotalDuration |
|
139 { |
|
140 get |
|
141 { |
|
142 return _totalDuration.TotalMilliseconds; |
|
143 } |
|
144 set |
|
145 { |
|
146 _totalDuration = new TimeSpan(0, 0, 0, 0, (int)value); |
|
147 _selectedBook.Duration = new TimeSpan(0, 0, 0, 0, (int)value); ; |
|
148 OnPropertyChanged("Duration"); |
|
149 } |
|
150 } |
|
151 |
|
152 private List<int> _polemicSpectrumData = new List<int>(); |
|
153 public List<int> PolemicSpectrumData |
|
154 { |
|
155 get |
|
156 { |
|
157 return _polemicSpectrumData; |
|
158 } |
|
159 } |
|
160 |
|
161 private List<int> _adhesionSpectrumData = new List<int>(); |
|
162 public List<int> AdhesionSpectrumData |
|
163 { |
|
164 get |
|
165 { |
|
166 return _adhesionSpectrumData; |
|
167 } |
|
168 } |
|
169 |
|
170 private List<int> _referenceSpectrumData = new List<int>(); |
|
171 public List<int> ReferenceSpectrumData |
|
172 { |
|
173 get |
|
174 { |
|
175 return _referenceSpectrumData; |
|
176 } |
|
177 } |
|
178 |
|
179 private List<int> _questionSpectrumData = new List<int>(); |
|
180 public List<int> QuestionSpectrumData |
|
181 { |
|
182 get |
|
183 { |
|
184 return _questionSpectrumData; |
|
185 } |
|
186 } |
|
187 |
|
188 private List<int> _generalSpectrumData = new List<int>(); |
|
189 public List<int> GeneralSpectrumData |
|
190 { |
|
191 get |
|
192 { |
|
193 return _generalSpectrumData; |
|
194 } |
|
195 } |
|
196 |
|
197 /// <summary> |
|
198 /// Position du curseur de lecture |
|
199 /// </summary> |
|
200 private double _position; |
|
201 public double Position |
|
202 { |
|
203 get |
|
204 { |
|
205 return _position; |
|
206 } |
|
207 set |
|
208 { |
|
209 _position = value; |
|
210 OnPropertyChanged("Position"); |
|
211 } |
|
212 } |
|
213 |
|
214 /// <summary> |
|
215 /// Chargement des données et annalyse |
|
216 /// </summary> |
|
217 private void LoadData() |
|
218 { |
|
219 if (_selectedBook.Duration != TimeSpan.Zero) |
|
220 { |
|
221 |
|
222 for (double i = 0; i <= _selectedBook.Duration.TotalMilliseconds; i = (i + _selectedBook.Duration.TotalMilliseconds / 150)) |
|
223 { |
|
224 int[] Tem = new int[4]{0,0,0,0}; |
|
225 foreach (VideoChapter Ch in _selectedBook.Chapters) |
|
226 { |
|
227 foreach (Annotation An in Ch.Annotations) |
|
228 { |
|
229 if (An.TimerIn.TotalMilliseconds <= i && An.TimerOut.TotalMilliseconds >= i) |
|
230 { |
|
231 switch (An.Type) |
|
232 { |
|
233 case PolemicElementType.Polemic: |
|
234 Tem[0]++; |
|
235 break; |
|
236 case PolemicElementType.Adhesion: |
|
237 Tem[1]++; |
|
238 break; |
|
239 case PolemicElementType.Reference: |
|
240 Tem[2]++; |
|
241 break; |
|
242 case PolemicElementType.Question: |
|
243 Tem[3]++; |
|
244 break; |
|
245 default: |
|
246 break; |
|
247 } |
|
248 } |
|
249 } |
|
250 } |
|
251 _polemicSpectrumData.Add(Tem[0]); |
|
252 _adhesionSpectrumData.Add(Tem[1]); |
|
253 _referenceSpectrumData.Add(Tem[2]); |
|
254 _questionSpectrumData.Add(Tem[3]); |
|
255 _generalSpectrumData.Add((Tem[0]+Tem[1]+Tem[2]+Tem[3])); |
|
256 } |
|
257 } |
|
258 |
|
259 |
|
260 } |
|
261 |
|
262 /// <summary> |
|
263 /// Constructeur |
|
264 /// </summary> |
|
265 /// <param name="bookParam">VideoLivre à étudier</param> |
|
266 public BookTimeLineVM(VideoBook bookParam) |
|
267 { |
|
268 _selectedBook = bookParam; |
|
269 _title = bookParam.Title; |
|
270 _author = bookParam.Author; |
|
271 _chapters = bookParam.Chapters; |
|
272 _totalDuration = bookParam.Duration; |
|
273 LoadData(); |
|
274 LoadElements(); |
|
275 Commands.TimeChange.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(TimeChange_Executed); |
|
276 |
|
277 } |
|
278 |
|
279 void TimeChange_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) |
|
280 { |
|
281 // Position = ((Slider)e.Parameter).Value; |
|
282 //Commands.VideoViewer.Pause.Execute(); |
|
283 Commands.GoToTime.Execute(((Slider)e.Parameter).Value); |
|
284 //Commands.VideoViewer.Play.Execute(); |
|
285 } |
|
286 |
|
287 |
|
288 /// <summary> |
|
289 /// Chargement des éléments du livre (Index et Annotations) |
|
290 /// </summary> |
|
291 private void LoadElements() |
|
292 { |
|
293 for(int key=0;key< _selectedBook.Chapters.Length;key++) |
|
294 { |
|
295 _segmentIndex[key] = _selectedBook.Chapters[key].Index; |
|
296 _annotations[key] = _selectedBook.Chapters[key].Annotations; |
|
297 } |
|
298 } |
|
299 |
|
300 } |
|
301 } |