client/src/Iri.Modernisation.Controls/View/ProductionTimeLine/ProductionTimeLine.xaml.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/client/src/Iri.Modernisation.Controls/View/ProductionTimeLine/ProductionTimeLine.xaml.cs Wed Nov 18 15:30:31 2009 +0100
@@ -0,0 +1,116 @@
+using System;
+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.Commands;
+using Iri.Modernisation.Data.Models;
+using Iri.Modernisation.Controls.ViewModel;
+namespace Iri.Modernisation.Controls.View
+{
+
+ public partial class ProductionTimeLine : UserControl
+ {
+ public static double ScaleTime
+ {
+ get
+ {
+ return 0.0001;
+ }
+ }
+ public ProductionTimeLine()
+ {
+ // Required to initialize variables
+ InitializeComponent();
+ Commands.Action.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(Action_Executed);
+
+ }
+
+ void Action_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e)
+ {
+ AddSequenceButton.Content = ((MouseEventArgs)e.Parameter).GetPosition(this).X;
+ }
+
+ private void AddSequenceButton_Click(object sender, System.Windows.RoutedEventArgs e)
+ {
+ Random rndNumbers = new Random();
+
+
+ CustomableVideoElement _temp = new CustomableVideoElement()
+ {
+ DataContext = new CustomableVideoElementVM(new VideoSequence()
+ {
+
+ RunTime = new TimeSpan(0, rndNumbers.Next(10,60), 0),
+ BeginTrim = new TimeSpan(0, 0, 0),
+ EndTrim = new TimeSpan(0, 0, 0)
+ }),
+ // Width = 200
+ };
+ _temp.MouseMove += new MouseEventHandler(CustomableVideoElement_MouseMove);
+ _temp.MouseLeftButtonDown += new MouseButtonEventHandler(CustomableVideoElement_MouseLeftButtonDown);
+ _temp.MouseLeftButtonUp += new MouseButtonEventHandler(CustomableVideoElement_MouseLeftButtonUp);
+ TimeStrip.Children.Add(_temp );// TODO: Add event handler implementation here.
+ }
+
+
+
+ private void slider_ValueChanged(object sender, System.Windows.RoutedPropertyChangedEventArgs<double> e)
+ {
+ AddSequenceButton.Content = e.NewValue;
+ // TODO: Add event handler implementation here.
+ }
+
+
+
+ private Point _comePoint;
+ private bool _isTrimRightCapturated = false;
+ private bool _isTrimLeftCapturated = false;
+
+ private CustomableVideoElement _selected;
+ void CustomableVideoElement_MouseMove(object sender, MouseEventArgs e)
+ {
+
+ _selected = ((CustomableVideoElement)sender);
+ if (_isTrimRightCapturated && ((CustomableVideoElement)sender).CaptureMouse())
+ {
+ ((CustomableVideoElement)sender).TrimRight = _comePoint.X - e.GetPosition(((CustomableVideoElement)sender)).X;
+ _comePoint = e.GetPosition(((CustomableVideoElement)sender));
+ }
+ else if (_isTrimLeftCapturated && ((CustomableVideoElement)sender).CaptureMouse())
+ {
+ ((CustomableVideoElement)sender).TrimLeft = e.GetPosition(((CustomableVideoElement)sender)).X - _comePoint.X;
+ _comePoint = e.GetPosition(((CustomableVideoElement)sender));
+ }
+
+ }
+ void CustomableVideoElement_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
+ {
+ _isTrimRightCapturated = false;
+ _isTrimLeftCapturated = false;
+ }
+
+ void CustomableVideoElement_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ if (e.GetPosition(((CustomableVideoElement)sender)).X >= ((CustomableVideoElement)sender).Width - 5)
+ {
+ _comePoint = e.GetPosition(((CustomableVideoElement)sender));
+ _isTrimRightCapturated = true;
+ }
+ if (e.GetPosition(((CustomableVideoElement)sender)).X <= 5)
+ {
+ _comePoint = e.GetPosition(((CustomableVideoElement)sender));
+ _isTrimLeftCapturated = true;
+ }
+ }
+
+ private void DeleteSequenceButton_Click(object sender, System.Windows.RoutedEventArgs e)
+ {
+ TimeStrip.Children.Remove(_selected);
+ }
+ }
+}
\ No newline at end of file