src/FingersDance.Control.Player/UserControlPlayer.xaml.cs
changeset 135 84b3bf5ee3d2
parent 134 f5108a598aa7
child 136 8b513df1b446
equal deleted inserted replaced
134:f5108a598aa7 135:84b3bf5ee3d2
     8 using System.Windows.Media.Imaging;
     8 using System.Windows.Media.Imaging;
     9 using System.Windows.Media.Animation;
     9 using System.Windows.Media.Animation;
    10 using System.Windows.Navigation;
    10 using System.Windows.Navigation;
    11 using System.ComponentModel;
    11 using System.ComponentModel;
    12 using System.Reflection;
    12 using System.Reflection;
       
    13 using System.Collections.Generic;
    13 
    14 
    14 using Microsoft.Surface.Presentation;
    15 using Microsoft.Surface.Presentation;
       
    16 using Microsoft.Surface.Presentation.Controls;
       
    17 using FingersDance.ActionFactory;
       
    18 using FingersDance.Actions;
    15 using FingersDance.Views;
    19 using FingersDance.Views;
    16 using FingersDance.ViewModels;
    20 using FingersDance.ViewModels;
    17 
    21 
    18 namespace FingersDance.Control.Player
    22 namespace FingersDance.Control.Player
    19 {
    23 {
   177         }
   181         }
   178 
   182 
   179         private void Play_Pause_area_DragEnter(object sender, SurfaceDragDropEventArgs e)
   183         private void Play_Pause_area_DragEnter(object sender, SurfaceDragDropEventArgs e)
   180         {
   184         {
   181             //Console.WriteLine("Enter");
   185             //Console.WriteLine("Enter");
   182             //Play_Pause_area.Opacity = 0.5;
   186             Play_Pause_area.Opacity = 0.5;
   183         }
   187         }
   184 
   188 
   185         private void Play_Pause_area_DragLeave(object sender, SurfaceDragDropEventArgs e)
   189         private void Play_Pause_area_DragLeave(object sender, SurfaceDragDropEventArgs e)
   186         {
   190         {
   187             //Console.WriteLine("Leave");
   191             //Console.WriteLine("Leave");
   188             //Play_Pause_area.Opacity = 0;
   192             Play_Pause_area.Opacity = 0;
   189         }
   193         }
   190 
   194 
   191         private void Play_Pause_area_DragOver(object sender, SurfaceDragDropEventArgs e)
   195         private void Play_Pause_area_DragOver(object sender, SurfaceDragDropEventArgs e)
   192         {
   196         {
   193             //Console.WriteLine("Over");
   197             //Console.WriteLine("Over");
   194         }
   198         }
   195 
   199 
   196         private void Play_Pause_area_Drop(object sender, SurfaceDragDropEventArgs e)
   200         private void Play_Pause_area_Drop(object sender, SurfaceDragDropEventArgs e)
   197         {
   201         {
   198             //Console.WriteLine("Drop");
   202             //Console.WriteLine("Drop");
       
   203             Play_Pause_area.Opacity = 0;
   199             // e.Cursor.Visual is the ContentControl, so its Content is the dragged TimelineAnnotationView
   204             // e.Cursor.Visual is the ContentControl, so its Content is the dragged TimelineAnnotationView
   200             AnnotationViewModel annotationDataVM = (AnnotationViewModel)((TimelineAnnotationView)((ContentControl)e.Cursor.Visual).Content).DataContext;
   205             AnnotationViewModel annotationDataVM = (AnnotationViewModel)((TimelineAnnotationView)((ContentControl)e.Cursor.Visual).Content).DataContext;
   201             int nbSeconds = (int)annotationDataVM.TcBegin;
   206             int nbSeconds = (int)annotationDataVM.TcBegin;
   202             int nbMilliSec = (int)((annotationDataVM.TcBegin * 1000)%1000);
   207             int nbMilliSec = (int)((annotationDataVM.TcBegin * 1000)%1000);
   203             MediaElementVideo.Position = new TimeSpan(0, 0, 0, nbSeconds, nbMilliSec);
   208             MediaElementVideo.Position = new TimeSpan(0, 0, 0, nbSeconds, nbMilliSec);
       
   209 
       
   210 
       
   211             // If the TimelineAnnotationView comes from a user control different from the current one, 
       
   212             // it means that we want to add the annotation to the current list.
       
   213             // So we generate the ActionAddAnnotation
       
   214             // e.Cursor.DragSource is the SurfaceListBox where the drag started from
       
   215             SurfaceListBox slb = (SurfaceListBox)e.Cursor.DragSource;
       
   216             // We get the instance of the UserControlSyncSource
       
   217             UserControl syncSrc = (UserControl)((Grid)((Grid)this.Parent).Parent).Parent;
       
   218             // and its UserControlTimeline
       
   219             UserControl tl = (UserControl)((Grid)((Grid)syncSrc.Content).Children[0]).Children[0];
       
   220             if (((Grid)((UserControl)((Grid)slb.Parent).Parent).Parent).Parent != tl)
       
   221             {
       
   222                 // Now we build the action arguments : a list holding the timeline and the annotation view models
       
   223                 List<Object> actionsArgs = new List<Object>();
       
   224                 actionsArgs.Add(tl);
       
   225                 actionsArgs.Add(annotationDataVM);
       
   226 
       
   227                 ActionGenerator ag = new ActionGenerator();
       
   228                 ActionBase ab = ag.GetAction("ActionAddAnnotation", actionsArgs);
       
   229                 if (ab != null)
       
   230                     ab.Execute();
       
   231             }
       
   232 
   204         }
   233         }
   205 	}
   234 	}
   206 }
   235 }