|
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 Iri.Modernisation.Data.Models; |
|
|
13 |
using Iri.Modernisation.Data.LDTClass; |
|
|
14 |
using Iri.Modernisation.BaseMVVM.Commands; |
|
|
15 |
using Iri.Modernisation.BaseMVVM.ViewModel; |
|
25
|
16 |
using System.Collections.ObjectModel; |
|
0
|
17 |
namespace Iri.Modernisation.Controls.ViewModel |
|
|
18 |
{ |
|
25
|
19 |
/// <summary> |
|
|
20 |
/// ViewModel de ConsultationView |
|
|
21 |
/// </summary> |
|
0
|
22 |
public class ConsultationViewVM : BaseMVVM.ViewModel.ViewModel |
|
|
23 |
{ |
|
35
|
24 |
|
|
0
|
25 |
private PolemicElement _selectedElement; |
|
25
|
26 |
/// <summary> |
|
|
27 |
/// PolemicElement sélectionné |
|
|
28 |
/// </summary> |
|
0
|
29 |
public PolemicElement SelectedElement |
|
|
30 |
{ |
|
|
31 |
get |
|
|
32 |
{ |
|
|
33 |
return _selectedElement; |
|
|
34 |
} |
|
|
35 |
set |
|
|
36 |
{ |
|
|
37 |
_selectedElement = value; |
|
|
38 |
OnPropertyChanged("SelectedElement"); |
|
|
39 |
} |
|
|
40 |
} |
|
|
41 |
|
|
25
|
42 |
private ObservableCollection<BookTimeLineVM> _selectedVideoBooks; |
|
|
43 |
/// <summary> |
|
|
44 |
/// Liste des Livres Sélectionnés |
|
|
45 |
/// </summary> |
|
|
46 |
public ObservableCollection<BookTimeLineVM> SelectedVideoBooks |
|
0
|
47 |
{ |
|
|
48 |
get |
|
|
49 |
{ |
|
|
50 |
|
|
|
51 |
return _selectedVideoBooks; |
|
|
52 |
} |
|
|
53 |
set |
|
|
54 |
{ |
|
|
55 |
_selectedVideoBooks = value; |
|
|
56 |
OnPropertyChanged("SelectedVideoBooks"); |
|
|
57 |
} |
|
|
58 |
} |
|
|
59 |
|
|
|
60 |
private int _selectedVideoBookIndex=-1; |
|
25
|
61 |
/// <summary> |
|
|
62 |
/// Index du livre sélectionné |
|
|
63 |
/// </summary> |
|
0
|
64 |
public int SelectedVideoBookIndex |
|
|
65 |
{ |
|
|
66 |
get |
|
|
67 |
{ |
|
|
68 |
return _selectedVideoBookIndex; |
|
|
69 |
} |
|
|
70 |
set |
|
|
71 |
{ |
|
|
72 |
_selectedVideoBookIndex= value; |
|
|
73 |
OnPropertyChanged("SelectedVideoBookIndex"); |
|
|
74 |
ConsultationBookViewContextMenu.SelectedBookVM = (_selectedVideoBooks[value]); |
|
|
75 |
|
|
|
76 |
} |
|
|
77 |
} |
|
|
78 |
|
|
|
79 |
private ConsultationBookViewVM _consultationBookViewContextMenu; |
|
25
|
80 |
/// <summary> |
|
|
81 |
/// ViewModel de ConsultationBook |
|
|
82 |
/// </summary> |
|
0
|
83 |
public ConsultationBookViewVM ConsultationBookViewContextMenu |
|
|
84 |
{ |
|
|
85 |
get |
|
|
86 |
{ |
|
|
87 |
return _consultationBookViewContextMenu; |
|
|
88 |
} |
|
|
89 |
set |
|
|
90 |
{ |
|
|
91 |
_consultationBookViewContextMenu = value; |
|
|
92 |
OnPropertyChanged(null); |
|
|
93 |
} |
|
|
94 |
} |
|
35
|
95 |
/// <summary> |
|
|
96 |
/// Loader pour chargement à la volée des VideoLivres selectionnés |
|
|
97 |
/// </summary> |
|
38
|
98 |
//private Loader<VideoBook> _loaderVideoBook { get; set; } |
|
|
99 |
private VideoBookLoader _loaderVideoBook { get; set; } |
|
0
|
100 |
private AnnotationMakerVM _annotationMakerVM; |
|
25
|
101 |
/// <summary> |
|
|
102 |
/// ViewModel de AnnotationMaker |
|
|
103 |
/// </summary> |
|
0
|
104 |
public AnnotationMakerVM ViewModelAnnotationMaker |
|
|
105 |
{ |
|
|
106 |
get |
|
|
107 |
{ |
|
|
108 |
return _annotationMakerVM; |
|
|
109 |
} |
|
30
|
110 |
set |
|
|
111 |
{ |
|
|
112 |
_annotationMakerVM = value; |
|
|
113 |
OnPropertyChanged("ViewModelAnnotationMaker"); |
|
|
114 |
} |
|
0
|
115 |
} |
|
35
|
116 |
|
|
|
117 |
private void InitializeCommands() |
|
|
118 |
{ |
|
38
|
119 |
Commands.ClickMenu.CreateNewTextualAnnotation.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(CreateNewTextualAnnotation_Executed); |
|
35
|
120 |
Commands.ConsultMenu.ClickBook.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(ClickBook_Executed); |
|
|
121 |
Commands.PolemicElement.SelectPolemicElement.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(SelectPolemicElement_Executed); |
|
38
|
122 |
Commands.AnnotationMaker.NewAnnotationFinished.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(NewAnnotationFinished_Executed); |
|
|
123 |
} |
|
|
124 |
|
|
|
125 |
void NewAnnotationFinished_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) |
|
|
126 |
{ |
|
|
127 |
Annotation createdAnnotation = ((Annotation)e.Parameter); |
|
|
128 |
PolemicElement refElement = ((PolemicElement)e.Source); |
|
|
129 |
refElement.Chapter.Annotations.Add(createdAnnotation); |
|
|
130 |
//refElement.Chapter.Book.Save(); |
|
|
131 |
|
|
|
132 |
|
|
35
|
133 |
} |
|
|
134 |
|
|
|
135 |
/// <summary> |
|
|
136 |
/// Evenement lors d'un click sur un livre de la liste |
|
|
137 |
/// </summary> |
|
|
138 |
/// <param name="sender"></param> |
|
|
139 |
/// <param name="e"></param> |
|
|
140 |
private void ClickBook_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) |
|
|
141 |
{ |
|
|
142 |
|
|
|
143 |
bool CanAdd = true; |
|
|
144 |
//On regarde si le VideoLivre qu'on à choisis n'est pas déjà dans la liste des VideoLivres sélectionné |
|
|
145 |
foreach (BookTimeLineVM BookTLVM in SelectedVideoBooks) |
|
|
146 |
{ |
|
|
147 |
if (BookTLVM.SelectedBook.LdtPath == ((VideoBook)e.Parameter).LdtPath) |
|
|
148 |
{ |
|
|
149 |
CanAdd = false; |
|
|
150 |
} |
|
|
151 |
} |
|
|
152 |
if (CanAdd) |
|
|
153 |
{ |
|
|
154 |
//Préparation du loader |
|
38
|
155 |
/* _loaderVideoBook = new Loader<VideoBook>(LDTFileReader.ConvertToVideoBook); |
|
36
|
156 |
_loaderVideoBook.LoaderFinished += new EventHandler<EventArgs>(LoaderVideoBook_LoaderFinished); |
|
38
|
157 |
_loaderVideoBook.Load(((VideoBook)e.Parameter).LdtPath);*/ |
|
|
158 |
_loaderVideoBook = new VideoBookLoader(); |
|
|
159 |
_loaderVideoBook.LoaderFinished += new EventHandler<LoaderEventArgs<VideoBook>>(_loaderVideoBook_LoaderFinished); |
|
35
|
160 |
_loaderVideoBook.Load(((VideoBook)e.Parameter).LdtPath); |
|
|
161 |
} |
|
|
162 |
|
|
|
163 |
|
|
|
164 |
} |
|
|
165 |
|
|
38
|
166 |
void _loaderVideoBook_LoaderFinished(object sender, LoaderEventArgs<VideoBook> e) |
|
|
167 |
{ |
|
|
168 |
VideoBook addedVideoBook = ((LoaderEventArgs<VideoBook>)e).CreatedObject; |
|
|
169 |
BookTimeLineVM temp = new BookTimeLineVM(addedVideoBook); |
|
|
170 |
temp.ViewModelVideoViewer = ConsultationBookViewContextMenu.ActualVideoSourceVM; |
|
|
171 |
SelectedVideoBooks.Add(temp); ; |
|
|
172 |
} |
|
|
173 |
|
|
35
|
174 |
/// <summary> |
|
|
175 |
/// Fonction une fois que le fichier .ldt à été chargé |
|
|
176 |
/// </summary> |
|
|
177 |
/// <param name="sender"></param> |
|
|
178 |
/// <param name="e"></param> |
|
38
|
179 |
/* private void LoaderVideoBook_LoaderFinished(object sender, EventArgs e) |
|
35
|
180 |
{ |
|
36
|
181 |
VideoBook addedVideoBook = ((LoaderEventArgs<VideoBook>)e).CreatedObject; |
|
35
|
182 |
///------- /// |
|
|
183 |
addedVideoBook.LdtPath = _loaderVideoBook.Path; |
|
|
184 |
///-----------------/// |
|
|
185 |
BookTimeLineVM temp = new BookTimeLineVM(addedVideoBook); |
|
|
186 |
temp.ViewModelVideoViewer = ConsultationBookViewContextMenu.ActualVideoSourceVM; |
|
|
187 |
SelectedVideoBooks.Add(temp); |
|
|
188 |
|
|
38
|
189 |
}*/ |
|
35
|
190 |
|
|
|
191 |
|
|
25
|
192 |
private void CreateNewTextualAnnotation_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) |
|
0
|
193 |
{ |
|
30
|
194 |
ViewModelAnnotationMaker.RefElement=SelectedElement; |
|
38
|
195 |
|
|
0
|
196 |
} |
|
|
197 |
public ConsultationViewVM() |
|
|
198 |
{ |
|
|
199 |
InitializeCommands(); |
|
|
200 |
_consultationBookViewContextMenu = new ConsultationBookViewVM(); |
|
30
|
201 |
ViewModelAnnotationMaker = new AnnotationMakerVM(); |
|
0
|
202 |
SelectedVideoBooks = new SLExtensions.Collections.ObjectModel.ObservableCollection<BookTimeLineVM>(); |
|
|
203 |
} |
|
|
204 |
|
|
25
|
205 |
private void SelectPolemicElement_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) |
|
0
|
206 |
{ |
|
|
207 |
SelectedElement= (PolemicElement)e.Parameter; |
|
|
208 |
try |
|
|
209 |
{ |
|
|
210 |
ConsultationBookViewContextMenu.SelectedIndex = (SegmentIndex)SelectedElement; |
|
|
211 |
} |
|
|
212 |
catch |
|
|
213 |
{ |
|
|
214 |
} |
|
|
215 |
} |
|
|
216 |
} |
|
|
217 |
} |