--- /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
+{
+ /// <summary>
+ /// ViewModel d'un PolemicElement
+ /// </summary>
+ public class PolemicElementVM : MenuableViewModel
+ {
+ /// <summary>
+ /// Timer lançant le ClickMenu
+ /// </summary>
+ private System.Windows.Threading.DispatcherTimer DisplayTimer = new System.Windows.Threading.DispatcherTimer();
+ private MouseButtonEventArgs _selectedCoord;
+
+ /// <summary>
+ /// Temps d'entrée
+ /// </summary>
+ private TimeSpan _timerIn;
+ public TimeSpan TimerIn
+ {
+ get
+ {
+ return _timerIn;
+ }
+ set
+ {
+ _timerIn = value;
+ _element.TimerIn = value;
+ OnPropertyChanged("TimerIn");
+ }
+ }
+
+ /// <summary>
+ /// Temps de sortie
+ /// </summary>
+ private TimeSpan _timerOut;
+ public TimeSpan TimerOut
+ {
+ get
+ {
+ return _timerOut;
+ }
+ set
+ {
+ _timerOut = value;
+ _element.TimerOut = value;
+ OnPropertyChanged("TimerOut");
+ }
+ }
+
+ /// <summary>
+ /// Durée de l'élément
+ /// </summary>
+ public TimeSpan Duration
+ {
+ get
+ {
+ return TimerOut - TimerIn;
+ }
+ set
+ {
+ TimerOut = TimerIn + value;
+ }
+ }
+
+ /// <summary>
+ /// Titre de l'élément
+ /// </summary>
+ private String _title;
+ public String Title
+ {
+ get
+ {
+ return _title;
+ }
+ set
+ {
+ _title = value;
+ _element.Title = value;
+ OnPropertyChanged("Title");
+ }
+ }
+
+ /// <summary>
+ /// Description de l'élément
+ /// </summary>
+ private String _description;
+ public String Description
+ {
+ get
+ {
+ return _description;
+ }
+ set
+ {
+ _description = value;
+ _element.Description = value;
+ OnPropertyChanged("Description");
+ }
+ }
+
+ /// <summary>
+ /// Tags de l'élément
+ /// </summary>
+ private List<String> _tags;
+ public List<String> Tags
+ {
+ get
+ {
+ return _tags;
+ }
+ set
+ {
+ _tags = value;
+ _element.Tags = value;
+ OnPropertyChanged("Tags");
+ }
+ }
+
+ /// <summary>
+ /// Chapitre référent de l'élément
+ /// </summary>
+ private VideoChapter _chapter;
+ public VideoChapter Chapter
+ {
+ get
+ {
+ return _chapter;
+ }
+ set
+ {
+ _chapter = value;
+ _element.Chapter = value;
+ OnPropertyChanged("Chapter");
+ }
+ }
+
+ /// <summary>
+ /// Auteur de l'élément
+ /// </summary>
+ 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;
+ }
+
+ }
+
+ }
+
+ /// <summary>
+ /// PolemicType de l'élément
+ /// </summary>
+ public PolemicElementType Type
+ {
+ get
+ {
+ if (_element is Annotation)
+ {
+ return ((Annotation)_element).Type;
+ }
+ else
+ {
+ return PolemicElementType.Basic;
+ }
+ }
+ }
+ private PolemicElement _element { get; set; }
+
+ /// <summary>
+ /// Constructeur
+ /// </summary>
+ /// <param name="element">PolémicElement</param>
+ 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);
+ }
+
+ /// <summary>
+ /// Lors d'un Tick,c'est à dire, lors d'un appuie long sur un élément
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="e"></param>
+ 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);
+ }
+
+ }
+
+}