client/src/Iri.Modernisation.Controls/ViewModel/ConsultationView/ConsultationViewVM.cs
--- a/client/src/Iri.Modernisation.Controls/ViewModel/ConsultationView/ConsultationViewVM.cs Wed Feb 10 14:56:46 2010 +0100
+++ b/client/src/Iri.Modernisation.Controls/ViewModel/ConsultationView/ConsultationViewVM.cs Thu Feb 11 17:29:23 2010 +0100
@@ -71,7 +71,14 @@
{
_selectedVideoBookIndex= value;
OnPropertyChanged("SelectedVideoBookIndex");
- ConsultationBookViewContextMenu.SelectedBookVM = (_selectedVideoBooks[value]);
+ if (_selectedVideoBooks.Count > value && value >= 0)
+ {
+ ConsultationBookViewContextMenu.SelectedBookVM = (_selectedVideoBooks[value]);
+ }
+ else
+ {
+ ConsultationBookViewContextMenu.SelectedBookVM = null;
+ }
}
}
@@ -121,6 +128,13 @@
Commands.PolemicElement.SelectPolemicElement.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(SelectPolemicElement_Executed);
Commands.AnnotationMaker.NewAnnotationFinished.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(NewAnnotationFinished_Executed);
Commands.BookTimeLine.LeftClickOnElement.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(LeftClickOnElement_Executed);
+ Commands.BookTimeLine.CloseBookTimeLine.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(CloseBookTimeLine_Executed);
+ }
+
+ void CloseBookTimeLine_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e)
+ {
+ SelectedVideoBooks.Remove((BookTimeLineVM)e.Parameter);
+ BookDeleted(this,new ConsultationVieVMSelectBookArg(((BookTimeLineVM)e.Parameter).SelectedBook));
}
void LeftClickOnElement_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e)
@@ -142,7 +156,9 @@
}
-
+
+ List<String> InDownloadFile { get; set; }
+
/// <summary>
/// Evenement lors d'un click sur un livre de la liste
/// </summary>
@@ -152,23 +168,25 @@
{
bool CanAdd = true;
+ VideoBook clickedVideoBook = ((VideoBook)e.Parameter);
//On regarde si le VideoLivre qu'on à choisis n'est pas déjà dans la liste des VideoLivres sélectionné
foreach (BookTimeLineVM BookTLVM in SelectedVideoBooks)
{
- if (BookTLVM.SelectedBook.LdtPath == ((VideoBook)e.Parameter).LdtPath)
+ if (BookTLVM.SelectedBook.LdtPath == clickedVideoBook.LdtPath)
{
CanAdd = false;
}
}
- if (CanAdd)
+ if (CanAdd && !InDownloadFile.Contains(clickedVideoBook.LdtPath))
{
//Préparation du loader
/* _loaderVideoBook = new Loader<VideoBook>(LDTFileReader.ConvertToVideoBook);
_loaderVideoBook.LoaderFinished += new EventHandler<EventArgs>(LoaderVideoBook_LoaderFinished);
_loaderVideoBook.Load(((VideoBook)e.Parameter).LdtPath);*/
+ InDownloadFile.Add(clickedVideoBook .LdtPath);
_loaderVideoBook = new VideoBookLoader();
_loaderVideoBook.LoaderFinished += new EventHandler<LoaderEventArgs<VideoBook>>(_loaderVideoBook_LoaderFinished);
- _loaderVideoBook.Load(((VideoBook)e.Parameter).LdtPath);
+ _loaderVideoBook.Load(clickedVideoBook.LdtPath);
}
@@ -179,25 +197,15 @@
VideoBook addedVideoBook = ((LoaderEventArgs<VideoBook>)e).CreatedObject;
BookTimeLineVM temp = new BookTimeLineVM(addedVideoBook);
temp.ViewModelVideoViewer = ConsultationBookViewContextMenu.ActualVideoSourceVM;
- SelectedVideoBooks.Add(temp); ;
+ SelectedVideoBooks.Add(temp);
+ InDownloadFile.Remove(addedVideoBook.LdtPath);
+
+ if(BookDownloaded!=null)
+ BookDownloaded(this,new ConsultationVieVMSelectBookArg(addedVideoBook));
}
- /// <summary>
- /// Fonction une fois que le fichier .ldt à été chargé
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- /* private void LoaderVideoBook_LoaderFinished(object sender, EventArgs e)
- {
- VideoBook addedVideoBook = ((LoaderEventArgs<VideoBook>)e).CreatedObject;
- ///------- ///
- addedVideoBook.LdtPath = _loaderVideoBook.Path;
- ///-----------------///
- BookTimeLineVM temp = new BookTimeLineVM(addedVideoBook);
- temp.ViewModelVideoViewer = ConsultationBookViewContextMenu.ActualVideoSourceVM;
- SelectedVideoBooks.Add(temp);
-
- }*/
+ public event EventHandler<ConsultationVieVMSelectBookArg> BookDownloaded;
+ public event EventHandler<ConsultationVieVMSelectBookArg> BookDeleted;
private void CreateNewTextualAnnotation_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e)
@@ -208,6 +216,7 @@
public ConsultationViewVM()
{
InitializeCommands();
+ InDownloadFile = new List<string>();
_consultationBookViewContextMenu = new ConsultationBookViewVM();
ViewModelAnnotationMaker = new AnnotationMakerVM();
SelectedVideoBooks = new SLExtensions.Collections.ObjectModel.ObservableCollection<BookTimeLineVM>();
@@ -225,4 +234,12 @@
}
}
}
+ public class ConsultationVieVMSelectBookArg : EventArgs
+ {
+ public VideoBook Book {get;private set;}
+ public ConsultationVieVMSelectBookArg (VideoBook book)
+ {
+ Book=book;
+ }
+ }
}