client/src/Iri.Modernisation.Controls/View/VideoViewer/VideoViewer.xaml.cs
changeset 0 249d70e7b32d
child 15 3f70aee2432f
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.Controls.ViewModel;
       
    12 namespace Iri.Modernisation.Controls.View
       
    13 {
       
    14 	public partial class VideoViewer : UserControl
       
    15 	{
       
    16 
       
    17    
       
    18 
       
    19         public String MediaSource
       
    20         {
       
    21             get
       
    22             { 
       
    23                 return (String)GetValue(SourceProperty); 
       
    24             }
       
    25             set 
       
    26             { 
       
    27                 SetValue(SourceProperty, value);
       
    28                 if(DataContext != null)
       
    29                 ((VideoViewerVM)DataContext).Source = value;
       
    30             }
       
    31         }
       
    32 
       
    33         // Using a DependencyProperty as the backing store for Source.  This enables animation, styling, binding, etc...
       
    34         public static readonly DependencyProperty SourceProperty =
       
    35             DependencyProperty.Register("MediaSource", typeof(String), typeof(VideoViewer), new PropertyMetadata(""));
       
    36 
       
    37 
       
    38 		public VideoViewer()
       
    39 		{
       
    40 			// Required to initialize variables
       
    41 			InitializeComponent();
       
    42             Commands.VideoPositionTimer.Tick += new EventHandler(VideoPositionTimer_Tick);
       
    43             Commands.GoToTime.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(GoToTime_Executed);
       
    44             Commands.VideoViewer.Pause.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(Pause_Executed);
       
    45             Commands.VideoViewer.Play.Executed +=new EventHandler<SLExtensions.Input.ExecutedEventArgs>(Play_Executed);
       
    46 		}
       
    47 
       
    48         void GoToTime_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e)
       
    49         {
       
    50             VideoScreen.Position = TimeSpan.FromMilliseconds((double)e.Parameter);
       
    51         }
       
    52 
       
    53         void VideoPositionTimer_Tick(object sender, EventArgs e)
       
    54         {
       
    55            Commands.VideoViewer.SendPosition.Execute(VideoScreen.Position);
       
    56         }
       
    57         public void ChangePosition(TimeSpan TS)
       
    58         {
       
    59             VideoScreen.Position = TS;
       
    60             
       
    61         }
       
    62         void Pause_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e)
       
    63         {
       
    64             VideoScreen.Pause();
       
    65             Commands.VideoPositionTimer.Stop();
       
    66             if (Commands.VideoPositionTimer.IsEnabled)
       
    67             {
       
    68                 MessageBox.Show("Click Time IS NOT STOPPED");
       
    69             }
       
    70         }
       
    71 
       
    72         void Play_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e)
       
    73         {
       
    74             if (e.Parameter == DataContext || e.Parameter == null)
       
    75             {
       
    76                 
       
    77                 VideoScreen.Play();
       
    78                 Commands.VideoPositionTimer.Start();
       
    79             }
       
    80         }
       
    81 
       
    82 		private void VideoScreen_MediaFailed(object sender, System.Windows.ExceptionRoutedEventArgs e)
       
    83 		{
       
    84 			MessageBox.Show(e.ErrorException.ToString());
       
    85 		}
       
    86 
       
    87 		private void VideoScreen_CurrentStateChanged(object sender, System.Windows.RoutedEventArgs e)
       
    88 		{
       
    89             
       
    90 		}
       
    91 
       
    92 		private void VideoScreen_MarkerReached(object sender, System.Windows.Media.TimelineMarkerRoutedEventArgs e)
       
    93 		{
       
    94             MessageBox.Show("toto");
       
    95 		}
       
    96 	}
       
    97 }