diff -r 3d66ca73df55 -r 9f157d9c725b src/FingersDance.Control.Player/UserControlPlayer.xaml.cs --- a/src/FingersDance.Control.Player/UserControlPlayer.xaml.cs Tue Oct 13 19:09:46 2009 +0200 +++ b/src/FingersDance.Control.Player/UserControlPlayer.xaml.cs Tue Oct 13 19:33:13 2009 +0200 @@ -10,6 +10,15 @@ using System.Windows.Navigation; using System.ComponentModel; using System.Reflection; +using System.Collections.Generic; + +using Microsoft.Surface.Presentation; +using Microsoft.Surface.Presentation.Controls; +using FingersDance.ActionFactory; +using FingersDance.Actions; +using FingersDance.Control.TimeLine; +using FingersDance.Views; +using FingersDance.ViewModels; namespace FingersDance.Control.Player { @@ -171,5 +180,78 @@ if(PlayerOpened!=null) PlayerOpened(this, new EventArgs()); } + + private void Play_Pause_area_DragEnter(object sender, SurfaceDragDropEventArgs e) + { + //Console.WriteLine("Enter"); + + // If the TimelineAnnotationView comes from a user control different from the current one, + // it means that we want to add the annotation to the current list. + // So we check if the dragged annotation can be dragged or if it will recover any existant annotation (in this case it will not be accepted) + // e.Cursor.DragSource is the SurfaceListBox where the drag started from + SurfaceListBox slb = (SurfaceListBox)e.Cursor.DragSource; + // We get the instance of the UserControlSyncSource + UserControl syncSrc = (UserControl)((Grid)((Grid)this.Parent).Parent).Parent; + // and its UserControlTimeline + UserControlTimeLine tl = (UserControlTimeLine)((Grid)((Grid)syncSrc.Content).Children[0]).Children[0]; + if (((Grid)((UserControl)((Grid)slb.Parent).Parent).Parent).Parent != tl) + { + // e.Cursor.Visual is the ContentControl, so its Content is the dragged TimelineAnnotationView + AnnotationViewModel annotationDataVM = (AnnotationViewModel)((TimelineAnnotationView)((ContentControl)e.Cursor.Visual).Content).DataContext; + Play_Pause_area.Background = tl.isAnnotationAccepted(annotationDataVM) ? new SolidColorBrush(Colors.Green) : new SolidColorBrush(Colors.Red); + } + else + { + Play_Pause_area.Background = new SolidColorBrush(Colors.White); + } + Play_Pause_area.Opacity = 0.3; + + } + + private void Play_Pause_area_DragLeave(object sender, SurfaceDragDropEventArgs e) + { + //Console.WriteLine("Leave"); + Play_Pause_area.Opacity = 0; + } + + private void Play_Pause_area_DragOver(object sender, SurfaceDragDropEventArgs e) + { + //Console.WriteLine("Over"); + } + + private void Play_Pause_area_Drop(object sender, SurfaceDragDropEventArgs e) + { + //Console.WriteLine("Drop"); + Play_Pause_area.Opacity = 0; + // e.Cursor.Visual is the ContentControl, so its Content is the dragged TimelineAnnotationView + AnnotationViewModel annotationDataVM = (AnnotationViewModel)((TimelineAnnotationView)((ContentControl)e.Cursor.Visual).Content).DataContext; + int nbSeconds = (int)annotationDataVM.TcBegin; + int nbMilliSec = (int)((annotationDataVM.TcBegin * 1000)%1000); + MediaElementVideo.Position = new TimeSpan(0, 0, 0, nbSeconds, nbMilliSec); + + + // If the TimelineAnnotationView comes from a user control different from the current one, + // it means that we want to add the annotation to the current list. + // So we generate the ActionAddAnnotation + // e.Cursor.DragSource is the SurfaceListBox where the drag started from + SurfaceListBox slb = (SurfaceListBox)e.Cursor.DragSource; + // We get the instance of the UserControlSyncSource + UserControl syncSrc = (UserControl)((Grid)((Grid)this.Parent).Parent).Parent; + // and its UserControlTimeline + UserControl tl = (UserControl)((Grid)((Grid)syncSrc.Content).Children[0]).Children[0]; + if (((Grid)((UserControl)((Grid)slb.Parent).Parent).Parent).Parent != tl) + { + // Now we build the action arguments : a list holding the timeline and the annotation view models + List actionsArgs = new List(); + actionsArgs.Add(tl); + actionsArgs.Add(annotationDataVM); + + ActionGenerator ag = new ActionGenerator(); + ActionBase ab = ag.GetAction("ActionAddAnnotation", actionsArgs); + if (ab != null) + ab.Execute(); + } + + } } } \ No newline at end of file