client/src/Iri.Modernisation.Controls/View/ProductionTimeLine/ProductionTimeLine.xaml.cs
changeset 0 249d70e7b32d
child 17 0e4e63f6f567
equal deleted inserted replaced
-1:000000000000 0:249d70e7b32d
       
     1 using System;
       
     2 using System.Windows;
       
     3 using System.Windows.Controls;
       
     4 using System.Windows.Documents;
       
     5 using System.Windows.Ink;
       
     6 using System.Windows.Input;
       
     7 using System.Windows.Media;
       
     8 using System.Windows.Media.Animation;
       
     9 using System.Windows.Shapes;
       
    10 using Iri.Modernisation.BaseMVVM.Commands;
       
    11 using Iri.Modernisation.Data.Models;
       
    12 using Iri.Modernisation.Controls.ViewModel;
       
    13 namespace Iri.Modernisation.Controls.View
       
    14 {
       
    15   
       
    16 	public partial class ProductionTimeLine : UserControl
       
    17 	{
       
    18         public static double ScaleTime
       
    19         {
       
    20             get
       
    21             {
       
    22                 return 0.0001;
       
    23             }
       
    24         }
       
    25 		public ProductionTimeLine()
       
    26 		{
       
    27 			// Required to initialize variables
       
    28 			InitializeComponent();
       
    29             Commands.Action.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(Action_Executed);
       
    30           
       
    31 		}
       
    32 
       
    33         void Action_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e)
       
    34         {
       
    35             AddSequenceButton.Content = ((MouseEventArgs)e.Parameter).GetPosition(this).X;
       
    36         }
       
    37 
       
    38         private void AddSequenceButton_Click(object sender, System.Windows.RoutedEventArgs e)
       
    39         {
       
    40             Random rndNumbers = new Random();
       
    41        
       
    42 
       
    43             CustomableVideoElement _temp = new CustomableVideoElement()
       
    44                                      {
       
    45                                          DataContext = new CustomableVideoElementVM(new VideoSequence()
       
    46                                          {
       
    47 
       
    48                                              RunTime = new TimeSpan(0, rndNumbers.Next(10,60), 0),
       
    49                                              BeginTrim = new TimeSpan(0, 0, 0),
       
    50                                              EndTrim = new TimeSpan(0, 0, 0)
       
    51                                          }),
       
    52                                        // Width = 200
       
    53                                      };
       
    54             _temp.MouseMove += new MouseEventHandler(CustomableVideoElement_MouseMove);
       
    55             _temp.MouseLeftButtonDown += new MouseButtonEventHandler(CustomableVideoElement_MouseLeftButtonDown);
       
    56             _temp.MouseLeftButtonUp += new MouseButtonEventHandler(CustomableVideoElement_MouseLeftButtonUp);
       
    57             TimeStrip.Children.Add(_temp  );// TODO: Add event handler implementation here.
       
    58         }
       
    59 
       
    60         
       
    61 
       
    62         private void slider_ValueChanged(object sender, System.Windows.RoutedPropertyChangedEventArgs<double> e)
       
    63         {
       
    64         	 AddSequenceButton.Content = e.NewValue;
       
    65 			// TODO: Add event handler implementation here.
       
    66         }
       
    67 
       
    68 
       
    69 
       
    70         private Point _comePoint; 
       
    71         private bool _isTrimRightCapturated = false;
       
    72         private bool _isTrimLeftCapturated = false;
       
    73 
       
    74         private CustomableVideoElement _selected;
       
    75         void CustomableVideoElement_MouseMove(object sender, MouseEventArgs e)
       
    76         {
       
    77 
       
    78             _selected = ((CustomableVideoElement)sender);
       
    79             if (_isTrimRightCapturated && ((CustomableVideoElement)sender).CaptureMouse())
       
    80             {
       
    81                 ((CustomableVideoElement)sender).TrimRight = _comePoint.X  - e.GetPosition(((CustomableVideoElement)sender)).X;
       
    82                 _comePoint = e.GetPosition(((CustomableVideoElement)sender));
       
    83             }
       
    84             else if (_isTrimLeftCapturated && ((CustomableVideoElement)sender).CaptureMouse())
       
    85             {
       
    86                 ((CustomableVideoElement)sender).TrimLeft = e.GetPosition(((CustomableVideoElement)sender)).X - _comePoint.X;
       
    87                 _comePoint = e.GetPosition(((CustomableVideoElement)sender));
       
    88             }
       
    89            
       
    90         }
       
    91         void CustomableVideoElement_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
       
    92         {
       
    93             _isTrimRightCapturated = false;
       
    94             _isTrimLeftCapturated = false;
       
    95         }
       
    96 
       
    97         void CustomableVideoElement_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
       
    98         {
       
    99             if (e.GetPosition(((CustomableVideoElement)sender)).X >= ((CustomableVideoElement)sender).Width - 5)
       
   100             {
       
   101                 _comePoint = e.GetPosition(((CustomableVideoElement)sender));
       
   102                 _isTrimRightCapturated = true;
       
   103             }
       
   104             if (e.GetPosition(((CustomableVideoElement)sender)).X <= 5)
       
   105             {
       
   106                 _comePoint = e.GetPosition(((CustomableVideoElement)sender));
       
   107                 _isTrimLeftCapturated = true;
       
   108             }
       
   109         }
       
   110 
       
   111         private void DeleteSequenceButton_Click(object sender, System.Windows.RoutedEventArgs e)
       
   112         {
       
   113             TimeStrip.Children.Remove(_selected);
       
   114         }
       
   115 	}
       
   116 }