| author | totetm <> |
| Fri, 12 Feb 2010 15:57:01 +0100 | |
| changeset 46 | ab3057b82260 |
| parent 42 | 594fdedecf7f |
| child 47 | 9b26023b8c83 |
| 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"); |
|
| 42 | 74 |
if (_selectedVideoBooks.Count > value && value >= 0) |
75 |
{ |
|
76 |
ConsultationBookViewContextMenu.SelectedBookVM = (_selectedVideoBooks[value]); |
|
77 |
} |
|
78 |
else |
|
79 |
{ |
|
80 |
ConsultationBookViewContextMenu.SelectedBookVM = null; |
|
81 |
} |
|
| 0 | 82 |
|
83 |
} |
|
84 |
} |
|
85 |
||
86 |
private ConsultationBookViewVM _consultationBookViewContextMenu; |
|
| 25 | 87 |
/// <summary> |
88 |
/// ViewModel de ConsultationBook |
|
89 |
/// </summary> |
|
| 0 | 90 |
public ConsultationBookViewVM ConsultationBookViewContextMenu |
91 |
{ |
|
92 |
get |
|
93 |
{ |
|
94 |
return _consultationBookViewContextMenu; |
|
95 |
} |
|
96 |
set |
|
97 |
{ |
|
98 |
_consultationBookViewContextMenu = value; |
|
99 |
OnPropertyChanged(null); |
|
100 |
} |
|
101 |
} |
|
| 35 | 102 |
/// <summary> |
103 |
/// Loader pour chargement à la volée des VideoLivres selectionnés |
|
104 |
/// </summary> |
|
| 38 | 105 |
//private Loader<VideoBook> _loaderVideoBook { get; set; } |
106 |
private VideoBookLoader _loaderVideoBook { get; set; } |
|
| 0 | 107 |
private AnnotationMakerVM _annotationMakerVM; |
| 25 | 108 |
/// <summary> |
109 |
/// ViewModel de AnnotationMaker |
|
110 |
/// </summary> |
|
| 0 | 111 |
public AnnotationMakerVM ViewModelAnnotationMaker |
112 |
{ |
|
113 |
get |
|
114 |
{ |
|
115 |
return _annotationMakerVM; |
|
116 |
} |
|
| 30 | 117 |
set |
118 |
{ |
|
119 |
_annotationMakerVM = value; |
|
120 |
OnPropertyChanged("ViewModelAnnotationMaker"); |
|
121 |
} |
|
| 0 | 122 |
} |
| 35 | 123 |
|
124 |
private void InitializeCommands() |
|
125 |
{ |
|
| 38 | 126 |
Commands.ClickMenu.CreateNewTextualAnnotation.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(CreateNewTextualAnnotation_Executed); |
| 35 | 127 |
Commands.ConsultMenu.ClickBook.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(ClickBook_Executed); |
128 |
Commands.PolemicElement.SelectPolemicElement.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(SelectPolemicElement_Executed); |
|
| 38 | 129 |
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
|
130 |
Commands.BookTimeLine.LeftClickOnElement.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(LeftClickOnElement_Executed); |
| 42 | 131 |
Commands.BookTimeLine.CloseBookTimeLine.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(CloseBookTimeLine_Executed); |
132 |
} |
|
133 |
||
134 |
void CloseBookTimeLine_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) |
|
135 |
{ |
|
|
46
ab3057b82260
Fixed|pas de chaise musical pour la fonction tetris
totetm <>
parents:
42
diff
changeset
|
136 |
((BookTimeLineVM)e.Parameter).ViewModelVideoViewer.Pause(); |
| 42 | 137 |
SelectedVideoBooks.Remove((BookTimeLineVM)e.Parameter); |
138 |
BookDeleted(this,new ConsultationVieVMSelectBookArg(((BookTimeLineVM)e.Parameter).SelectedBook)); |
|
|
41
b51a10574e7f
LeftClick on an element in BookTimeLine set time at begining of the element.
totetm <>
parents:
39
diff
changeset
|
139 |
} |
|
b51a10574e7f
LeftClick on an element in BookTimeLine set time at begining of the element.
totetm <>
parents:
39
diff
changeset
|
140 |
|
|
b51a10574e7f
LeftClick on an element in BookTimeLine set time at begining of the element.
totetm <>
parents:
39
diff
changeset
|
141 |
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
|
142 |
{ |
|
b51a10574e7f
LeftClick on an element in BookTimeLine set time at begining of the element.
totetm <>
parents:
39
diff
changeset
|
143 |
TimeSpan TimeToGo = (TimeSpan)e.Parameter; |
|
b51a10574e7f
LeftClick on an element in BookTimeLine set time at begining of the element.
totetm <>
parents:
39
diff
changeset
|
144 |
PolemicElementVM ClickedElement = (PolemicElementVM)e.Source; |
|
b51a10574e7f
LeftClick on an element in BookTimeLine set time at begining of the element.
totetm <>
parents:
39
diff
changeset
|
145 |
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
|
146 |
{ |
|
b51a10574e7f
LeftClick on an element in BookTimeLine set time at begining of the element.
totetm <>
parents:
39
diff
changeset
|
147 |
ConsultationBookViewContextMenu.ActualVideoSourceVM.GoTo(TimeToGo); |
|
b51a10574e7f
LeftClick on an element in BookTimeLine set time at begining of the element.
totetm <>
parents:
39
diff
changeset
|
148 |
} |
| 38 | 149 |
} |
150 |
||
151 |
void NewAnnotationFinished_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) |
|
152 |
{ |
|
153 |
Annotation createdAnnotation = ((Annotation)e.Parameter); |
|
154 |
PolemicElement refElement = ((PolemicElement)e.Source); |
|
| 39 | 155 |
// refElement.Chapter.Annotations.Add(createdAnnotation); |
| 38 | 156 |
//refElement.Chapter.Book.Save(); |
157 |
||
158 |
|
|
| 35 | 159 |
} |
| 42 | 160 |
|
161 |
List<String> InDownloadFile { get; set; } |
|
162 |
||
| 35 | 163 |
/// <summary> |
164 |
/// Evenement lors d'un click sur un livre de la liste |
|
165 |
/// </summary> |
|
166 |
/// <param name="sender"></param> |
|
167 |
/// <param name="e"></param> |
|
168 |
private void ClickBook_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) |
|
169 |
{ |
|
170 |
||
171 |
bool CanAdd = true; |
|
| 42 | 172 |
VideoBook clickedVideoBook = ((VideoBook)e.Parameter); |
| 35 | 173 |
//On regarde si le VideoLivre qu'on à choisis n'est pas déjà dans la liste des VideoLivres sélectionné |
174 |
foreach (BookTimeLineVM BookTLVM in SelectedVideoBooks) |
|
175 |
{ |
|
| 42 | 176 |
if (BookTLVM.SelectedBook.LdtPath == clickedVideoBook.LdtPath) |
| 35 | 177 |
{ |
178 |
CanAdd = false; |
|
179 |
} |
|
180 |
} |
|
| 42 | 181 |
if (CanAdd && !InDownloadFile.Contains(clickedVideoBook.LdtPath)) |
| 35 | 182 |
{ |
183 |
//Préparation du loader |
|
| 38 | 184 |
/* _loaderVideoBook = new Loader<VideoBook>(LDTFileReader.ConvertToVideoBook); |
| 36 | 185 |
_loaderVideoBook.LoaderFinished += new EventHandler<EventArgs>(LoaderVideoBook_LoaderFinished); |
| 38 | 186 |
_loaderVideoBook.Load(((VideoBook)e.Parameter).LdtPath);*/ |
| 42 | 187 |
InDownloadFile.Add(clickedVideoBook .LdtPath); |
| 38 | 188 |
_loaderVideoBook = new VideoBookLoader(); |
189 |
_loaderVideoBook.LoaderFinished += new EventHandler<LoaderEventArgs<VideoBook>>(_loaderVideoBook_LoaderFinished); |
|
| 42 | 190 |
_loaderVideoBook.Load(clickedVideoBook.LdtPath); |
| 35 | 191 |
} |
192 |
|
|
193 |
||
194 |
} |
|
195 |
||
| 38 | 196 |
void _loaderVideoBook_LoaderFinished(object sender, LoaderEventArgs<VideoBook> e) |
197 |
{ |
|
198 |
VideoBook addedVideoBook = ((LoaderEventArgs<VideoBook>)e).CreatedObject; |
|
199 |
BookTimeLineVM temp = new BookTimeLineVM(addedVideoBook); |
|
200 |
temp.ViewModelVideoViewer = ConsultationBookViewContextMenu.ActualVideoSourceVM; |
|
| 42 | 201 |
SelectedVideoBooks.Add(temp); |
202 |
InDownloadFile.Remove(addedVideoBook.LdtPath); |
|
203 |
||
204 |
if(BookDownloaded!=null) |
|
205 |
BookDownloaded(this,new ConsultationVieVMSelectBookArg(addedVideoBook)); |
|
| 38 | 206 |
} |
207 |
||
| 42 | 208 |
public event EventHandler<ConsultationVieVMSelectBookArg> BookDownloaded; |
209 |
public event EventHandler<ConsultationVieVMSelectBookArg> BookDeleted; |
|
| 35 | 210 |
|
211 |
|
|
| 25 | 212 |
private void CreateNewTextualAnnotation_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) |
| 0 | 213 |
{ |
|
46
ab3057b82260
Fixed|pas de chaise musical pour la fonction tetris
totetm <>
parents:
42
diff
changeset
|
214 |
ViewModelAnnotationMaker.RefElement=SelectedElement; |
|
ab3057b82260
Fixed|pas de chaise musical pour la fonction tetris
totetm <>
parents:
42
diff
changeset
|
215 |
//ViewModelAnnotationMaker = new AnnotationMakerVM(SelectedElement); |
| 0 | 216 |
} |
217 |
public ConsultationViewVM() |
|
218 |
{ |
|
219 |
InitializeCommands(); |
|
| 42 | 220 |
InDownloadFile = new List<string>(); |
| 0 | 221 |
_consultationBookViewContextMenu = new ConsultationBookViewVM(); |
| 30 | 222 |
ViewModelAnnotationMaker = new AnnotationMakerVM(); |
| 0 | 223 |
SelectedVideoBooks = new SLExtensions.Collections.ObjectModel.ObservableCollection<BookTimeLineVM>(); |
224 |
} |
|
225 |
||
| 25 | 226 |
private void SelectPolemicElement_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) |
| 0 | 227 |
{ |
228 |
SelectedElement= (PolemicElement)e.Parameter; |
|
229 |
try |
|
230 |
{ |
|
231 |
ConsultationBookViewContextMenu.SelectedIndex = (SegmentIndex)SelectedElement; |
|
232 |
} |
|
233 |
catch |
|
234 |
{ |
|
235 |
} |
|
236 |
} |
|
237 |
} |
|
| 42 | 238 |
public class ConsultationVieVMSelectBookArg : EventArgs |
239 |
{ |
|
240 |
public VideoBook Book {get;private set;} |
|
241 |
public ConsultationVieVMSelectBookArg (VideoBook book) |
|
242 |
{ |
|
243 |
Book=book; |
|
244 |
} |
|
245 |
} |
|
| 0 | 246 |
} |