| author | totetm <> |
| Wed, 10 Feb 2010 14:56:46 +0100 | |
| changeset 41 | b51a10574e7f |
| parent 39 | 0f2bde8fdfeb |
| child 42 | 594fdedecf7f |
| permissions | -rw-r--r-- |
| 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); |
|
41
b51a10574e7f
LeftClick on an element in BookTimeLine set time at begining of the element.
totetm <>
parents:
39
diff
changeset
|
123 |
Commands.BookTimeLine.LeftClickOnElement.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(LeftClickOnElement_Executed); |
|
b51a10574e7f
LeftClick on an element in BookTimeLine set time at begining of the element.
totetm <>
parents:
39
diff
changeset
|
124 |
} |
|
b51a10574e7f
LeftClick on an element in BookTimeLine set time at begining of the element.
totetm <>
parents:
39
diff
changeset
|
125 |
|
|
b51a10574e7f
LeftClick on an element in BookTimeLine set time at begining of the element.
totetm <>
parents:
39
diff
changeset
|
126 |
void LeftClickOnElement_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) |
|
b51a10574e7f
LeftClick on an element in BookTimeLine set time at begining of the element.
totetm <>
parents:
39
diff
changeset
|
127 |
{ |
|
b51a10574e7f
LeftClick on an element in BookTimeLine set time at begining of the element.
totetm <>
parents:
39
diff
changeset
|
128 |
TimeSpan TimeToGo = (TimeSpan)e.Parameter; |
|
b51a10574e7f
LeftClick on an element in BookTimeLine set time at begining of the element.
totetm <>
parents:
39
diff
changeset
|
129 |
PolemicElementVM ClickedElement = (PolemicElementVM)e.Source; |
|
b51a10574e7f
LeftClick on an element in BookTimeLine set time at begining of the element.
totetm <>
parents:
39
diff
changeset
|
130 |
if(ConsultationBookViewContextMenu.SelectedBook == ClickedElement.Chapter.Book) |
|
b51a10574e7f
LeftClick on an element in BookTimeLine set time at begining of the element.
totetm <>
parents:
39
diff
changeset
|
131 |
{ |
|
b51a10574e7f
LeftClick on an element in BookTimeLine set time at begining of the element.
totetm <>
parents:
39
diff
changeset
|
132 |
ConsultationBookViewContextMenu.ActualVideoSourceVM.GoTo(TimeToGo); |
|
b51a10574e7f
LeftClick on an element in BookTimeLine set time at begining of the element.
totetm <>
parents:
39
diff
changeset
|
133 |
} |
| 38 | 134 |
} |
135 |
||
136 |
void NewAnnotationFinished_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) |
|
137 |
{ |
|
138 |
Annotation createdAnnotation = ((Annotation)e.Parameter); |
|
139 |
PolemicElement refElement = ((PolemicElement)e.Source); |
|
| 39 | 140 |
// refElement.Chapter.Annotations.Add(createdAnnotation); |
| 38 | 141 |
//refElement.Chapter.Book.Save(); |
142 |
||
143 |
|
|
| 35 | 144 |
} |
145 |
|
|
146 |
/// <summary> |
|
147 |
/// Evenement lors d'un click sur un livre de la liste |
|
148 |
/// </summary> |
|
149 |
/// <param name="sender"></param> |
|
150 |
/// <param name="e"></param> |
|
151 |
private void ClickBook_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) |
|
152 |
{ |
|
153 |
||
154 |
bool CanAdd = true; |
|
155 |
//On regarde si le VideoLivre qu'on à choisis n'est pas déjà dans la liste des VideoLivres sélectionné |
|
156 |
foreach (BookTimeLineVM BookTLVM in SelectedVideoBooks) |
|
157 |
{ |
|
158 |
if (BookTLVM.SelectedBook.LdtPath == ((VideoBook)e.Parameter).LdtPath) |
|
159 |
{ |
|
160 |
CanAdd = false; |
|
161 |
} |
|
162 |
} |
|
163 |
if (CanAdd) |
|
164 |
{ |
|
165 |
//Préparation du loader |
|
| 38 | 166 |
/* _loaderVideoBook = new Loader<VideoBook>(LDTFileReader.ConvertToVideoBook); |
| 36 | 167 |
_loaderVideoBook.LoaderFinished += new EventHandler<EventArgs>(LoaderVideoBook_LoaderFinished); |
| 38 | 168 |
_loaderVideoBook.Load(((VideoBook)e.Parameter).LdtPath);*/ |
169 |
_loaderVideoBook = new VideoBookLoader(); |
|
170 |
_loaderVideoBook.LoaderFinished += new EventHandler<LoaderEventArgs<VideoBook>>(_loaderVideoBook_LoaderFinished); |
|
| 35 | 171 |
_loaderVideoBook.Load(((VideoBook)e.Parameter).LdtPath); |
172 |
} |
|
173 |
|
|
174 |
||
175 |
} |
|
176 |
||
| 38 | 177 |
void _loaderVideoBook_LoaderFinished(object sender, LoaderEventArgs<VideoBook> e) |
178 |
{ |
|
179 |
VideoBook addedVideoBook = ((LoaderEventArgs<VideoBook>)e).CreatedObject; |
|
180 |
BookTimeLineVM temp = new BookTimeLineVM(addedVideoBook); |
|
181 |
temp.ViewModelVideoViewer = ConsultationBookViewContextMenu.ActualVideoSourceVM; |
|
182 |
SelectedVideoBooks.Add(temp); ; |
|
183 |
} |
|
184 |
||
| 35 | 185 |
/// <summary> |
186 |
/// Fonction une fois que le fichier .ldt à été chargé |
|
187 |
/// </summary> |
|
188 |
/// <param name="sender"></param> |
|
189 |
/// <param name="e"></param> |
|
| 38 | 190 |
/* private void LoaderVideoBook_LoaderFinished(object sender, EventArgs e) |
| 35 | 191 |
{ |
| 36 | 192 |
VideoBook addedVideoBook = ((LoaderEventArgs<VideoBook>)e).CreatedObject; |
| 35 | 193 |
///------- /// |
194 |
addedVideoBook.LdtPath = _loaderVideoBook.Path; |
|
195 |
///-----------------/// |
|
196 |
BookTimeLineVM temp = new BookTimeLineVM(addedVideoBook); |
|
197 |
temp.ViewModelVideoViewer = ConsultationBookViewContextMenu.ActualVideoSourceVM; |
|
198 |
SelectedVideoBooks.Add(temp); |
|
199 |
|
|
| 38 | 200 |
}*/ |
| 35 | 201 |
|
202 |
|
|
| 25 | 203 |
private void CreateNewTextualAnnotation_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) |
| 0 | 204 |
{ |
| 30 | 205 |
ViewModelAnnotationMaker.RefElement=SelectedElement; |
| 38 | 206 |
|
| 0 | 207 |
} |
208 |
public ConsultationViewVM() |
|
209 |
{ |
|
210 |
InitializeCommands(); |
|
211 |
_consultationBookViewContextMenu = new ConsultationBookViewVM(); |
|
| 30 | 212 |
ViewModelAnnotationMaker = new AnnotationMakerVM(); |
| 0 | 213 |
SelectedVideoBooks = new SLExtensions.Collections.ObjectModel.ObservableCollection<BookTimeLineVM>(); |
214 |
} |
|
215 |
||
| 25 | 216 |
private void SelectPolemicElement_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) |
| 0 | 217 |
{ |
218 |
SelectedElement= (PolemicElement)e.Parameter; |
|
219 |
try |
|
220 |
{ |
|
221 |
ConsultationBookViewContextMenu.SelectedIndex = (SegmentIndex)SelectedElement; |
|
222 |
} |
|
223 |
catch |
|
224 |
{ |
|
225 |
} |
|
226 |
} |
|
227 |
} |
|
228 |
} |