diff -r cde7fe7f284e -r de7ba61f66c7 client/src/Iri.Modernisation.Controls/ViewModel/NavigationBar/ChutierVM.cs --- a/client/src/Iri.Modernisation.Controls/ViewModel/NavigationBar/ChutierVM.cs Fri Nov 20 13:58:39 2009 +0100 +++ b/client/src/Iri.Modernisation.Controls/ViewModel/NavigationBar/ChutierVM.cs Mon Nov 23 10:17:33 2009 +0100 @@ -13,14 +13,16 @@ using Iri.Modernisation.BaseMVVM.ViewModel; using Iri.Modernisation.Data.Models; using System.Collections.Generic; +using SLExtensions.Collections.ObjectModel; + using System.Linq; namespace Iri.Modernisation.Controls.ViewModel { public class ChutierVM : BaseMVVM.ViewModel.ViewModel { - protected List _annotations = new List(); - protected List list = new List(); - public List Annotations + protected ObservableCollection _annotations = new ObservableCollection(); + protected ObservableCollection list = new ObservableCollection(); + public ObservableCollection Annotations { get { @@ -61,10 +63,12 @@ } private void InitializeCommands() - { - } + { + } - public ChutierVM(List argList) + + + public ChutierVM(ObservableCollection argList) { _annotations = argList; InitializeCommands(); @@ -72,10 +76,11 @@ protected void Search() { + var query = from c in _annotations where c.Title.Contains(_searchWord) select c; - Annotations = query.ToList(); + Annotations = new ObservableCollection(query.ToList()); } public void ClickAnnotation_Executed(object sender, ExecutedEventArgs e) { @@ -92,7 +97,7 @@ } public class PersonnalChutierVM : ChutierVM { - public PersonnalChutierVM(List argList) + public PersonnalChutierVM(ObservableCollection argList) : base( argList) { InitializeCommands(); @@ -109,7 +114,7 @@ public class ReferencesChutierVM : ChutierVM { - public ReferencesChutierVM(List argList) + public ReferencesChutierVM(ObservableCollection argList) : base(argList) { InitializeCommands(); @@ -117,9 +122,23 @@ private void InitializeCommands() { + Commands.ReferencesChutier.RefChutierAdd.Executed += new EventHandler(RefChutierAdd_Executed); + Commands.ReferencesChutier.Search.Executed += new EventHandler(ChutierSearch_Executed); Commands.ReferencesChutier.ClickAnnotation.Executed += new EventHandler(ClickAnnotation_Executed); } + void RefChutierAdd_Executed(object sender, ExecutedEventArgs e) + { + if(!_annotations.Contains((PolemicElement)e.Parameter)) + { + _annotations.Add((PolemicElement)e.Parameter); + } + else + { + MessageBox.Show("Element déjà sauvegardé"); + } + + } }