8 using System.Windows.Input; |
8 using System.Windows.Input; |
9 using System.Windows.Media; |
9 using System.Windows.Media; |
10 using System.Windows.Media.Animation; |
10 using System.Windows.Media.Animation; |
11 using System.Windows.Navigation; |
11 using System.Windows.Navigation; |
12 using System.Windows.Controls.Primitives; |
12 using System.Windows.Controls.Primitives; |
|
13 using Microsoft.Surface.Presentation; |
13 using Microsoft.Surface.Presentation.Controls; |
14 using Microsoft.Surface.Presentation.Controls; |
14 using Microsoft.Surface.Presentation; |
|
15 using System.Windows.Threading; |
15 using System.Windows.Threading; |
16 |
16 |
17 using FingersDance.Data; |
17 using FingersDance.Data; |
18 using FingersDance.ViewModels; |
18 using FingersDance.ViewModels; |
19 using FingersDance.Views; |
19 using FingersDance.Views; |
|
20 using FingersDance.Control.Close; |
20 |
21 |
21 namespace FingersDance.Control.TimeLine |
22 namespace FingersDance.Control.TimeLine |
22 { |
23 { |
23 public partial class UserControlTimeLine |
24 public partial class UserControlTimeLine |
24 { |
25 { |
26 #region Variables |
27 #region Variables |
27 private DispatcherTimer timer; |
28 private DispatcherTimer timer; |
28 private bool isDragging = false; |
29 private bool isDragging = false; |
29 private bool finishedDragging = false; |
30 private bool finishedDragging = false; |
30 #endregion |
31 #endregion |
31 |
32 |
32 public event EventHandler DragStarted; |
33 public event EventHandler DragStarted; |
33 public event EventHandler DragCompleted; |
34 public event EventHandler DragCompleted; |
34 public event EventHandler TimerTick; |
35 public event EventHandler TimerTick; |
35 |
36 |
36 private double totalmilliseconds; |
37 private double totalmilliseconds; |
39 private float AnnotWidth = 300 + 15; // The surfaceListBox adds 15 pixels between each item |
40 private float AnnotWidth = 300 + 15; // The surfaceListBox adds 15 pixels between each item |
40 private CuttingViewModel CuttingVM; |
41 private CuttingViewModel CuttingVM; |
41 private Boolean AnnotWaiting = false; |
42 private Boolean AnnotWaiting = false; |
42 private float AnnotTcBegin; |
43 private float AnnotTcBegin; |
43 |
44 |
|
45 private AnnotationViewModel canceledAnnotationVM; |
|
46 |
44 #region Properties |
47 #region Properties |
45 |
48 |
46 public SurfaceSlider Slider |
49 public SurfaceSlider Slider |
47 { |
50 { |
48 get |
51 get |
359 Content = new TimelineAnnotationView() |
362 Content = new TimelineAnnotationView() |
360 { |
363 { |
361 DataContext = findSource.DataContext |
364 DataContext = findSource.DataContext |
362 } |
365 } |
363 }; |
366 }; |
364 |
367 |
365 // We apply the current scale to the dragged annotation |
368 // We apply the current scale to the dragged annotation |
366 ((TimelineAnnotationView)cursorVisual.Content).RenderTransform = this.RenderTransform; |
369 ((TimelineAnnotationView)cursorVisual.Content).RenderTransform = this.RenderTransform; |
367 |
370 |
368 // Add a handler. This will enable the application to change the visual cues. (NOT USEFUL IN FINGERSDANCE CASE) |
371 // Add a handler. This will enable the application to change the visual cues. (NOT USEFUL IN FINGERSDANCE CASE) |
369 //SurfaceDragDrop.AddTargetChangedHandler(cursorVisual, OnTargetChanged); |
372 //SurfaceDragDrop.AddTargetChangedHandler(cursorVisual, OnTargetChanged); |
399 e.Handled = startDragOkay; |
402 e.Handled = startDragOkay; |
400 } |
403 } |
401 |
404 |
402 private void onDragCanceled(Object sender, SurfaceDragDropEventArgs e) |
405 private void onDragCanceled(Object sender, SurfaceDragDropEventArgs e) |
403 { |
406 { |
404 Console.WriteLine("onDragCanceled = " + sender + ", ((ContentControl)e.Cursor.Visual).Content = " + ((ContentControl)e.Cursor.Visual).Content); |
407 //Console.WriteLine("onDragCanceled = " + sender + ", ((ContentControl)e.Cursor.Visual).Content = " + ((ContentControl)e.Cursor.Visual).Content); |
405 // e.Cursor.Visual is the ContentControl, so its Content is the dragged TimelineAnnotationView |
|
406 AnnotationViewModel annotationDataVM = (AnnotationViewModel)((TimelineAnnotationView)((ContentControl)e.Cursor.Visual).Content).DataContext; |
|
407 // We check if the annotation is well one of the current annotations |
408 // We check if the annotation is well one of the current annotations |
408 if (CuttingVM != null) |
409 if (CuttingVM != null) |
409 { |
410 { |
|
411 // e.Cursor.Visual is the ContentControl, so its Content is the dragged TimelineAnnotationView |
|
412 canceledAnnotationVM = (AnnotationViewModel)((TimelineAnnotationView)((ContentControl)e.Cursor.Visual).Content).DataContext; |
|
413 confirmCancelPopup.Visibility = Visibility.Visible; |
|
414 } |
|
415 } |
|
416 |
|
417 private void confirmCancelPopup_ConfirmYesOrNo(object sender, ConfirmEventArgs e) |
|
418 { |
|
419 //Console.WriteLine("Confirm = " + e.Confirmed); |
|
420 // We check if the annotation is well one of the current annotations |
|
421 if (CuttingVM != null && canceledAnnotationVM != null && e.Confirmed == true) |
|
422 { |
410 foreach (Annotation a in AnnotList) |
423 foreach (Annotation a in AnnotList) |
411 { |
424 { |
412 //Console.WriteLine("a.TcBegin = " + a.TcBegin + ", avm.TcBegin = " + avm.TcBegin + ", tcOut = " + (a.TcBegin + a.Dur)); |
425 // Check begin TcBegin, duration and gesture type |
413 // Check begin TC |
426 if (a.TcBegin == canceledAnnotationVM.TcBegin && a.Dur == canceledAnnotationVM.Dur && a.GestureType == canceledAnnotationVM.GestureType) |
414 if (a.TcBegin == annotationDataVM.TcBegin && a.Dur == annotationDataVM.Dur && a.GestureType==annotationDataVM.GestureType) |
427 { |
415 { |
428 // We found the good annotation so we can remove it |
416 // We found the good annotation so we can delete it |
|
417 AnnotList.Remove(a); |
429 AnnotList.Remove(a); |
418 // We redisplay the timeline |
430 // We redisplay the timeline |
419 CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth); |
431 CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth); |
420 tv.DataContext = null; |
432 tv.DataContext = null; |
421 tv.DataContext = CuttingVM; |
433 tv.DataContext = CuttingVM; |
|
434 // We close the popup and return as soon as we removed the annotation to avoid an error on AnnotList, which is just modified |
|
435 confirmCancelPopup.Visibility = Visibility.Hidden; |
|
436 canceledAnnotationVM = null; |
422 return; |
437 return; |
423 } |
438 } |
424 } |
439 } |
425 } |
440 } |
|
441 confirmCancelPopup.Visibility = Visibility.Hidden; |
|
442 canceledAnnotationVM = null; |
426 } |
443 } |
427 |
444 |
428 |
445 |
429 } |
446 } |
430 } |
447 } |