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