diff -r 000000000000 -r 249d70e7b32d client/src/Iri.Modernisation.Controls/ViewModel/PolemicElementVM.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/src/Iri.Modernisation.Controls/ViewModel/PolemicElementVM.cs Wed Nov 18 15:30:31 2009 +0100 @@ -0,0 +1,263 @@ +using System; +using System.Net; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Documents; +using System.Windows.Ink; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Animation; +using System.Windows.Shapes; +using Iri.Modernisation.BaseMVVM; +using Iri.Modernisation.BaseMVVM.ViewModel; +using Iri.Modernisation.BaseMVVM.Commands; +using Iri.Modernisation.Data.Models; +using System.Collections.Generic; +namespace Iri.Modernisation.Controls.ViewModel +{ + /// + /// ViewModel d'un PolemicElement + /// + public class PolemicElementVM : MenuableViewModel + { + /// + /// Timer lançant le ClickMenu + /// + private System.Windows.Threading.DispatcherTimer DisplayTimer = new System.Windows.Threading.DispatcherTimer(); + private MouseButtonEventArgs _selectedCoord; + + /// + /// Temps d'entrée + /// + private TimeSpan _timerIn; + public TimeSpan TimerIn + { + get + { + return _timerIn; + } + set + { + _timerIn = value; + _element.TimerIn = value; + OnPropertyChanged("TimerIn"); + } + } + + /// + /// Temps de sortie + /// + private TimeSpan _timerOut; + public TimeSpan TimerOut + { + get + { + return _timerOut; + } + set + { + _timerOut = value; + _element.TimerOut = value; + OnPropertyChanged("TimerOut"); + } + } + + /// + /// Durée de l'élément + /// + public TimeSpan Duration + { + get + { + return TimerOut - TimerIn; + } + set + { + TimerOut = TimerIn + value; + } + } + + /// + /// Titre de l'élément + /// + private String _title; + public String Title + { + get + { + return _title; + } + set + { + _title = value; + _element.Title = value; + OnPropertyChanged("Title"); + } + } + + /// + /// Description de l'élément + /// + private String _description; + public String Description + { + get + { + return _description; + } + set + { + _description = value; + _element.Description = value; + OnPropertyChanged("Description"); + } + } + + /// + /// Tags de l'élément + /// + private List _tags; + public List Tags + { + get + { + return _tags; + } + set + { + _tags = value; + _element.Tags = value; + OnPropertyChanged("Tags"); + } + } + + /// + /// Chapitre référent de l'élément + /// + private VideoChapter _chapter; + public VideoChapter Chapter + { + get + { + return _chapter; + } + set + { + _chapter = value; + _element.Chapter = value; + OnPropertyChanged("Chapter"); + } + } + + /// + /// Auteur de l'élément + /// + public User Contributer + { + get + { + try + { + return ((Annotation)_element).Contributer; + } + catch + { + return null; + } + } + + } + + public double Heigh + { + get + { + if(_element is SegmentIndex) + { + return 20; + } + else + { + return 10; + } + + } + + } + + /// + /// PolemicType de l'élément + /// + public PolemicElementType Type + { + get + { + if (_element is Annotation) + { + return ((Annotation)_element).Type; + } + else + { + return PolemicElementType.Basic; + } + } + } + private PolemicElement _element { get; set; } + + /// + /// Constructeur + /// + /// PolémicElement + public PolemicElementVM(PolemicElement element) + :base() + { + _element = element; + TimerIn = _element.TimerIn; + TimerOut = _element.TimerOut; + Title = _element.Title; + Description = _element.Description; + Tags = _element.Tags; + Chapter = _element.Chapter; + DisplayTimer.Interval = new TimeSpan(0, 0, 0, 0, 500); + DisplayTimer.Tick += new EventHandler(myDispatcherTimer_Tick); + } + + /// + /// Lors d'un Tick,c'est à dire, lors d'un appuie long sur un élément + /// + /// + /// + void myDispatcherTimer_Tick(object sender, EventArgs e) + { + DisplayTimer.Stop(); + Commands.PolemicElement.ElementSelected.Execute(_selectedCoord, _element); + } + + + public override void MenuableUserControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + + _selectedCoord = e; + Commands.PolemicElement.SelectPolemicElement.Execute(_element); + DisplayTimer.Start(); + + + } + public override void MenuableUserControl_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) + { + DisplayTimer.Stop(); + Commands.ContextualBinderLayer.EndBind.Execute(Type, _element); + + } + public override void MenuableUserControl_MouseLeave(object sender, MouseEventArgs e) + { + Commands.ContextualBinderLayer.UnSelectBind.Execute(); + } + public override void MenuableUserControl_MouseEnter(object sender, MouseEventArgs e) + { + Commands.ContextualBinderLayer.SelectBind.Execute(Type, _element); + } + + } + +}