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