--- 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<PolemicElement> _annotations = new List<PolemicElement>();
- protected List<PolemicElement> list = new List<PolemicElement>();
- public List<PolemicElement> Annotations
+ protected ObservableCollection<PolemicElement> _annotations = new ObservableCollection<PolemicElement>();
+ protected ObservableCollection<PolemicElement> list = new ObservableCollection<PolemicElement>();
+ public ObservableCollection<PolemicElement> Annotations
{
get
{
@@ -61,10 +63,12 @@
}
private void InitializeCommands()
- {
- }
+ {
+ }
- public ChutierVM(List<PolemicElement> argList)
+
+
+ public ChutierVM(ObservableCollection<PolemicElement> 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<PolemicElement>(query.ToList());
}
public void ClickAnnotation_Executed(object sender, ExecutedEventArgs e)
{
@@ -92,7 +97,7 @@
}
public class PersonnalChutierVM : ChutierVM
{
- public PersonnalChutierVM(List<PolemicElement> argList)
+ public PersonnalChutierVM(ObservableCollection<PolemicElement> argList)
: base( argList)
{
InitializeCommands();
@@ -109,7 +114,7 @@
public class ReferencesChutierVM : ChutierVM
{
- public ReferencesChutierVM(List<PolemicElement> argList)
+ public ReferencesChutierVM(ObservableCollection<PolemicElement> argList)
: base(argList)
{
InitializeCommands();
@@ -117,9 +122,23 @@
private void InitializeCommands()
{
+ Commands.ReferencesChutier.RefChutierAdd.Executed += new EventHandler<ExecutedEventArgs>(RefChutierAdd_Executed);
+
Commands.ReferencesChutier.Search.Executed += new EventHandler<ExecutedEventArgs>(ChutierSearch_Executed);
Commands.ReferencesChutier.ClickAnnotation.Executed += new EventHandler<ExecutedEventArgs>(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é");
+ }
+
+ }
}