diff -r b51a10574e7f -r 594fdedecf7f 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(SelectPolemicElement_Executed); Commands.AnnotationMaker.NewAnnotationFinished.Executed += new EventHandler(NewAnnotationFinished_Executed); Commands.BookTimeLine.LeftClickOnElement.Executed += new EventHandler(LeftClickOnElement_Executed); + Commands.BookTimeLine.CloseBookTimeLine.Executed += new EventHandler(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 InDownloadFile { get; set; } + /// /// Evenement lors d'un click sur un livre de la liste /// @@ -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(LDTFileReader.ConvertToVideoBook); _loaderVideoBook.LoaderFinished += new EventHandler(LoaderVideoBook_LoaderFinished); _loaderVideoBook.Load(((VideoBook)e.Parameter).LdtPath);*/ + InDownloadFile.Add(clickedVideoBook .LdtPath); _loaderVideoBook = new VideoBookLoader(); _loaderVideoBook.LoaderFinished += new EventHandler>(_loaderVideoBook_LoaderFinished); - _loaderVideoBook.Load(((VideoBook)e.Parameter).LdtPath); + _loaderVideoBook.Load(clickedVideoBook.LdtPath); } @@ -179,25 +197,15 @@ VideoBook addedVideoBook = ((LoaderEventArgs)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)); } - /// - /// Fonction une fois que le fichier .ldt à été chargé - /// - /// - /// - /* private void LoaderVideoBook_LoaderFinished(object sender, EventArgs e) - { - VideoBook addedVideoBook = ((LoaderEventArgs)e).CreatedObject; - ///------- /// - addedVideoBook.LdtPath = _loaderVideoBook.Path; - ///-----------------/// - BookTimeLineVM temp = new BookTimeLineVM(addedVideoBook); - temp.ViewModelVideoViewer = ConsultationBookViewContextMenu.ActualVideoSourceVM; - SelectedVideoBooks.Add(temp); - - }*/ + public event EventHandler BookDownloaded; + public event EventHandler BookDeleted; private void CreateNewTextualAnnotation_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) @@ -208,6 +216,7 @@ public ConsultationViewVM() { InitializeCommands(); + InDownloadFile = new List(); _consultationBookViewContextMenu = new ConsultationBookViewVM(); ViewModelAnnotationMaker = new AnnotationMakerVM(); SelectedVideoBooks = new SLExtensions.Collections.ObjectModel.ObservableCollection(); @@ -225,4 +234,12 @@ } } } + public class ConsultationVieVMSelectBookArg : EventArgs + { + public VideoBook Book {get;private set;} + public ConsultationVieVMSelectBookArg (VideoBook book) + { + Book=book; + } + } }