--- a/src/FingersDance.Control.Player/UserControlPlayer.xaml.cs Tue Oct 06 14:02:09 2009 +0200
+++ b/src/FingersDance.Control.Player/UserControlPlayer.xaml.cs Wed Oct 07 17:16:46 2009 +0200
@@ -10,8 +10,12 @@
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.Views;
using FingersDance.ViewModels;
@@ -179,13 +183,13 @@
private void Play_Pause_area_DragEnter(object sender, SurfaceDragDropEventArgs e)
{
//Console.WriteLine("Enter");
- //Play_Pause_area.Opacity = 0.5;
+ Play_Pause_area.Opacity = 0.5;
}
private void Play_Pause_area_DragLeave(object sender, SurfaceDragDropEventArgs e)
{
//Console.WriteLine("Leave");
- //Play_Pause_area.Opacity = 0;
+ Play_Pause_area.Opacity = 0;
}
private void Play_Pause_area_DragOver(object sender, SurfaceDragDropEventArgs e)
@@ -196,11 +200,36 @@
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<Object> actionsArgs = new List<Object>();
+ 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