# HG changeset patch # User cavaliet # Date 1254502147 -7200 # Node ID 90c29e979ef4c0f1725ddc8f59a909ec776dbce1 # Parent d2c42d42f504f8fcebd21d508c1195c16ef1eb62 Drag and drop of annotations from timeline, first step diff -r d2c42d42f504 -r 90c29e979ef4 src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs --- a/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs Wed Sep 30 16:58:58 2009 +0200 +++ b/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs Fri Oct 02 18:49:07 2009 +0200 @@ -33,7 +33,7 @@ private double totalmilliseconds; private List AnnotList = new List(); - private float AnnotWidth = 40+1; + private float AnnotWidth = 300 + 15; // The surfaceListBox adds 15 pixels between each item private CuttingViewModel CuttingVM; private Boolean AnnotWaiting = false; private float AnnotTcBegin; @@ -111,10 +111,10 @@ // TEMP FOR DATA BINDING AnnotList = new List(); AnnotList.Add(new Annotation(0, 10, "Axe Cam 1")); - //annotList.Add(new Annotation(20 - (1 * annotWidth), 30, "Mvt Cam 2")); - //annotList.Add(new Annotation(50 - (2 * annotWidth), 60, "Saut 3")); - //annotList.Add(new Annotation(100 - (3 * annotWidth), 20, "Saut 4")); - //annotList.Add(new Annotation(120 - (4 * annotWidth), 50, "Saut 5")); + //AnnotList.Add(new Annotation(100 - (1 * AnnotWidth), 70, "Mvt Cam 2")); + //AnnotList.Add(new Annotation(200 - (2 * AnnotWidth), 50, "Saut 3")); + //AnnotList.Add(new Annotation(100 - (3 * AnnotWidth), 20, "Saut 4")); + //AnnotList.Add(new Annotation(120 - (4 * AnnotWidth), 50, "Saut 5")); Cutting cut = new Cutting("titre de cutting", AnnotList); CuttingVM = new CuttingViewModel(cut); tv.DataContext = CuttingVM; @@ -171,8 +171,7 @@ #endregion - private void sliderPosition_DragStarted( - object sender, DragStartedEventArgs e) + private void sliderPosition_DragStarted(object sender, DragStartedEventArgs e) { isDragging = true; OnDragStarted(); @@ -208,6 +207,8 @@ { AnnotTcBegin = (float)slider.Value; lastAnnotVM = new AnnotationViewModel(new Annotation((AnnotTcBegin / 1000) - (CuttingVM.AnnotList.Count * AnnotWidth), 0, CuttingVM.AnnotList.Count.ToString())); + //lastAnnotVM = new AnnotationViewModel(new Annotation((AnnotTcBegin / 1000), 0, CuttingVM.AnnotList.Count.ToString())); + //lastAnnotVM = new AnnotationViewModel(new Annotation(0, 0, CuttingVM.AnnotList.Count.ToString())); CuttingVM.AnnotList.Add(lastAnnotVM); Console.WriteLine("BEGIN currentTimecode = " + (AnnotTcBegin / 1000) + ", nb = " + CuttingVM.AnnotList.Count + ", res = " + ((AnnotTcBegin / 1000) - (CuttingVM.AnnotList.Count * AnnotWidth))); tv.DataContext = null; @@ -221,6 +222,8 @@ float currentDuration = ((float)slider.Value - AnnotTcBegin) / 1000; CuttingVM.AnnotList.RemoveAt(CuttingVM.AnnotList.Count - 1); CuttingVM.AnnotList.Add(new AnnotationViewModel(new Annotation((AnnotTcBegin / 1000) - (CuttingVM.AnnotList.Count * AnnotWidth), currentDuration, CuttingVM.AnnotList.Count.ToString()))); + //CuttingVM.AnnotList.Add(new AnnotationViewModel(new Annotation((AnnotTcBegin / 1000), currentDuration, CuttingVM.AnnotList.Count.ToString()))); + //CuttingVM.AnnotList.Add(new AnnotationViewModel(new Annotation(0, currentDuration, CuttingVM.AnnotList.Count.ToString()))); Console.WriteLine("currentTimecode = " + (AnnotTcBegin / 1000) + ", curDur = " + currentDuration + ", nb = " + CuttingVM.AnnotList.Count + ", res = " + ((AnnotTcBegin / 1000) - (CuttingVM.AnnotList.Count * AnnotWidth))); tv.DataContext = null; tv.DataContext = CuttingVM; diff -r d2c42d42f504 -r 90c29e979ef4 src/FingersDance.Views/FingersDance.Views.csproj --- a/src/FingersDance.Views/FingersDance.Views.csproj Wed Sep 30 16:58:58 2009 +0200 +++ b/src/FingersDance.Views/FingersDance.Views.csproj Fri Oct 02 18:49:07 2009 +0200 @@ -3,7 +3,7 @@ Debug AnyCPU - 9.0.21022 + 9.0.30729 2.0 {0B308B6E-7B1E-46C0-ACC7-0B7EFC4D0B2C} Library @@ -122,6 +122,12 @@ MSBuild:Compile + + + {E81BB080-0598-43AC-90CE-54D6570C4E9E} + FingersDance.ViewModels + + + + + + - + + + - + diff -r d2c42d42f504 -r 90c29e979ef4 src/FingersDance.Views/TimelineView.xaml.cs --- a/src/FingersDance.Views/TimelineView.xaml.cs Wed Sep 30 16:58:58 2009 +0200 +++ b/src/FingersDance.Views/TimelineView.xaml.cs Fri Oct 02 18:49:07 2009 +0200 @@ -11,6 +11,11 @@ using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using Microsoft.Surface.Presentation.Controls; +using Microsoft.Surface.Presentation; + +using FingersDance.Views; +using FingersDance.ViewModels; namespace FingersDance.Views { @@ -23,5 +28,73 @@ { InitializeComponent(); } + + private void listview_PreviewContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e) + { + FrameworkElement findSource = e.OriginalSource as FrameworkElement; + SurfaceListBoxItem draggedElement = null; + + // Find the touched SurfaceListBoxItem object. + while (draggedElement == null && findSource != null) + { + if ((draggedElement = findSource as SurfaceListBoxItem) == null) + { + findSource = VisualTreeHelper.GetParent(findSource) as FrameworkElement; + } + } + + if (draggedElement == null) + { + return; + } + + // Create the cursor visual. + ContentControl cursorVisual = new ContentControl() + { + Content = new TimelineAnnotationView() + { + DataContext = findSource.DataContext + } + }; + + // TO DO : apply the good scale to the TAV because the dragged one has scale at 1. + + + // Add a handler. This will enable the application to change the visual cues. + //SurfaceDragDrop.AddTargetChangedHandler(cursorVisual, OnTargetChanged); + + // Create a list of input devices. Add the contacts that + // are currently captured within the dragged element and + // the current contact (if it isn't already in the list). + List devices = new List(); + devices.Add(e.Contact); + foreach (Contact contact in draggedElement.ContactsCapturedWithin) + { + if (contact != e.Contact) + { + devices.Add(contact); + } + } + + // Get the drag source object + ItemsControl dragSource = ItemsControl.ItemsControlFromItemContainer(draggedElement); + + bool startDragOkay = + SurfaceDragDrop.BeginDragDrop( + dragSource, // The SurfaceListBox object that the cursor is dragged out from. + draggedElement, // The SurfaceListBoxItem object that is dragged from the drag source. + cursorVisual, // The visual element of the cursor. + draggedElement.DataContext, // The data associated with the cursor. + devices, // The input devices that start dragging the cursor. + DragDropEffects.Move); // The allowed drag-and-drop effects of the operation. + + // If the drag began successfully, set e.Handled to true. + // Otherwise SurfaceListBoxItem captures the contact + // and causes the drag operation to fail. + e.Handled = startDragOkay; + + } + + } }