# HG changeset patch # User cavaliet # Date 1255423419 -7200 # Node ID fc7c12f9da30332f39984972eb917a0135ade761 # Parent 7eb5f979d0865eb34ca5626a47a637e341185e53 Add a confirm dialog box before deleting an annotation by drag and drop. Now the UserControlClose is a generic confirm dialog box sending a ConfirmYesOrNo Event. diff -r 7eb5f979d086 -r fc7c12f9da30 src/FingersDance.ActionFactory/ActionGenerator.cs --- a/src/FingersDance.ActionFactory/ActionGenerator.cs Sun Oct 11 20:38:22 2009 +0200 +++ b/src/FingersDance.ActionFactory/ActionGenerator.cs Tue Oct 13 10:43:39 2009 +0200 @@ -17,7 +17,7 @@ actionDict.Add("ActionOpenMedia", typeof(FingersDance.Actions.ActionOpenMedia)); actionDict.Add("ActionStopMedia", typeof(FingersDance.Actions.ActionStopMedia)); - //actionDict.Add("ActionStartOrEndAnnotation", typeof(FingersDance.Actions.ActionStartOrEndAnnotation)); + actionDict.Add("ActionStartOrEndAnnotation", typeof(FingersDance.Actions.ActionStartOrEndAnnotation)); actionDict.Add("ActionAddAnnotation", typeof(FingersDance.Actions.ActionAddAnnotation)); } diff -r 7eb5f979d086 -r fc7c12f9da30 src/FingersDance.Actions/FingersDance.Actions.csproj --- a/src/FingersDance.Actions/FingersDance.Actions.csproj Sun Oct 11 20:38:22 2009 +0200 +++ b/src/FingersDance.Actions/FingersDance.Actions.csproj Tue Oct 13 10:43:39 2009 +0200 @@ -82,6 +82,7 @@ + diff -r 7eb5f979d086 -r fc7c12f9da30 src/FingersDance.Control.Close/FingersDance.Control.Close.csproj --- a/src/FingersDance.Control.Close/FingersDance.Control.Close.csproj Sun Oct 11 20:38:22 2009 +0200 +++ b/src/FingersDance.Control.Close/FingersDance.Control.Close.csproj Tue Oct 13 10:43:39 2009 +0200 @@ -104,9 +104,6 @@ True Settings.settings - - SurfaceWindow1.xaml - @@ -121,11 +118,5 @@ - - - MSBuild:Compile - Designer - - \ No newline at end of file diff -r 7eb5f979d086 -r fc7c12f9da30 src/FingersDance.Control.Close/SurfaceWindow1.xaml --- a/src/FingersDance.Control.Close/SurfaceWindow1.xaml Sun Oct 11 20:38:22 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ - - - - - - - - - diff -r 7eb5f979d086 -r fc7c12f9da30 src/FingersDance.Control.Close/SurfaceWindow1.xaml.cs --- a/src/FingersDance.Control.Close/SurfaceWindow1.xaml.cs Sun Oct 11 20:38:22 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,103 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; -using System.Windows.Threading; -using Microsoft.Surface; -using Microsoft.Surface.Presentation; -using Microsoft.Surface.Presentation.Controls; - -namespace FingersDance.Control.Close -{ - /// - /// Interaction logic for SurfaceWindow1.xaml - /// - public partial class SurfaceWindow1 : SurfaceWindow - { - /// - /// Default constructor. - /// - public SurfaceWindow1() - { - InitializeComponent(); - - // Add handlers for Application activation events - AddActivationHandlers(); - } - - - /// - /// Occurs when the window is about to close. - /// - /// - protected override void OnClosed(EventArgs e) - { - base.OnClosed(e); - - // Remove handlers for Application activation events - RemoveActivationHandlers(); - } - - /// - /// Adds handlers for Application activation events. - /// - private void AddActivationHandlers() - { - // Subscribe to surface application activation events - ApplicationLauncher.ApplicationActivated += OnApplicationActivated; - ApplicationLauncher.ApplicationPreviewed += OnApplicationPreviewed; - ApplicationLauncher.ApplicationDeactivated += OnApplicationDeactivated; - } - - /// - /// Removes handlers for Application activation events. - /// - private void RemoveActivationHandlers() - { - // Unsubscribe from surface application activation events - ApplicationLauncher.ApplicationActivated -= OnApplicationActivated; - ApplicationLauncher.ApplicationPreviewed -= OnApplicationPreviewed; - ApplicationLauncher.ApplicationDeactivated -= OnApplicationDeactivated; - } - - /// - /// This is called when application has been activated. - /// - /// - /// - private void OnApplicationActivated(object sender, EventArgs e) - { - //TODO: enable audio, animations here - } - - /// - /// This is called when application is in preview mode. - /// - /// - /// - private void OnApplicationPreviewed(object sender, EventArgs e) - { - //TODO: Disable audio here if it is enabled - - //TODO: optionally enable animations here - } - - /// - /// This is called when application has been deactivated. - /// - /// - /// - private void OnApplicationDeactivated(object sender, EventArgs e) - { - //TODO: disable audio, animations here - } - } -} \ No newline at end of file diff -r 7eb5f979d086 -r fc7c12f9da30 src/FingersDance.Control.Close/UserControlClose.xaml --- a/src/FingersDance.Control.Close/UserControlClose.xaml Sun Oct 11 20:38:22 2009 +0200 +++ b/src/FingersDance.Control.Close/UserControlClose.xaml Tue Oct 13 10:43:39 2009 +0200 @@ -5,12 +5,14 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="FingersDance.Control.Close.UserControlClose" - x:Name="UserControl" - Width="359.284" Height="210.955" xmlns:Custom="http://schemas.microsoft.com/surface/2008" BorderBrush="White"> - - - + + {D579FDB5-D412-4797-A0FF-C5873AE08BB8} + FingersDance.Control.Close + {EAF384DB-2AE4-4132-839D-60F9DAFDEAD8} FingersDance.Data @@ -138,5 +141,8 @@ FingersDance.Views + + + \ No newline at end of file diff -r 7eb5f979d086 -r fc7c12f9da30 src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml --- a/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml Sun Oct 11 20:38:22 2009 +0200 +++ b/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml Tue Oct 13 10:43:39 2009 +0200 @@ -5,8 +5,9 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" xmlns:vw="clr-namespace:FingersDance.Views;assembly=FingersDance.Views" + xmlns:popup="clr-namespace:FingersDance.Control.Close;assembly=FingersDance.Control.Close" xmlns:Custom="http://schemas.microsoft.com/surface/2008" xmlns:Microsoft_Surface_Presentation_Generic="clr-namespace:Microsoft.Surface.Presentation.Generic;assembly=Microsoft.Surface.Presentation.Generic" - x:Class="FingersDance.Control.TimeLine.UserControlTimeLine" + x:Class="FingersDance.Control.TimeLine.UserControlTimeLine" x:Name="UserControl" d:DesignWidth="383" Background="{x:Null}" d:DesignHeight="33"> @@ -781,5 +782,6 @@ + \ No newline at end of file diff -r 7eb5f979d086 -r fc7c12f9da30 src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs --- a/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs Sun Oct 11 20:38:22 2009 +0200 +++ b/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs Tue Oct 13 10:43:39 2009 +0200 @@ -10,13 +10,14 @@ using System.Windows.Media.Animation; using System.Windows.Navigation; using System.Windows.Controls.Primitives; +using Microsoft.Surface.Presentation; using Microsoft.Surface.Presentation.Controls; -using Microsoft.Surface.Presentation; using System.Windows.Threading; using FingersDance.Data; using FingersDance.ViewModels; using FingersDance.Views; +using FingersDance.Control.Close; namespace FingersDance.Control.TimeLine { @@ -28,7 +29,7 @@ private bool isDragging = false; private bool finishedDragging = false; #endregion - + public event EventHandler DragStarted; public event EventHandler DragCompleted; public event EventHandler TimerTick; @@ -41,6 +42,8 @@ private Boolean AnnotWaiting = false; private float AnnotTcBegin; + private AnnotationViewModel canceledAnnotationVM; + #region Properties public SurfaceSlider Slider @@ -98,7 +101,7 @@ public UserControlTimeLine() { this.InitializeComponent(); - + // Insert code required on object creation below this point. } @@ -361,7 +364,7 @@ DataContext = findSource.DataContext } }; - + // We apply the current scale to the dragged annotation ((TimelineAnnotationView)cursorVisual.Content).RenderTransform = this.RenderTransform; @@ -401,28 +404,42 @@ private void onDragCanceled(Object sender, SurfaceDragDropEventArgs e) { - Console.WriteLine("onDragCanceled = " + sender + ", ((ContentControl)e.Cursor.Visual).Content = " + ((ContentControl)e.Cursor.Visual).Content); - // e.Cursor.Visual is the ContentControl, so its Content is the dragged TimelineAnnotationView - AnnotationViewModel annotationDataVM = (AnnotationViewModel)((TimelineAnnotationView)((ContentControl)e.Cursor.Visual).Content).DataContext; + //Console.WriteLine("onDragCanceled = " + sender + ", ((ContentControl)e.Cursor.Visual).Content = " + ((ContentControl)e.Cursor.Visual).Content); // We check if the annotation is well one of the current annotations if (CuttingVM != null) { + // e.Cursor.Visual is the ContentControl, so its Content is the dragged TimelineAnnotationView + canceledAnnotationVM = (AnnotationViewModel)((TimelineAnnotationView)((ContentControl)e.Cursor.Visual).Content).DataContext; + confirmCancelPopup.Visibility = Visibility.Visible; + } + } + + private void confirmCancelPopup_ConfirmYesOrNo(object sender, ConfirmEventArgs e) + { + //Console.WriteLine("Confirm = " + e.Confirmed); + // We check if the annotation is well one of the current annotations + if (CuttingVM != null && canceledAnnotationVM != null && e.Confirmed == true) + { foreach (Annotation a in AnnotList) { - //Console.WriteLine("a.TcBegin = " + a.TcBegin + ", avm.TcBegin = " + avm.TcBegin + ", tcOut = " + (a.TcBegin + a.Dur)); - // Check begin TC - if (a.TcBegin == annotationDataVM.TcBegin && a.Dur == annotationDataVM.Dur && a.GestureType==annotationDataVM.GestureType) + // Check begin TcBegin, duration and gesture type + if (a.TcBegin == canceledAnnotationVM.TcBegin && a.Dur == canceledAnnotationVM.Dur && a.GestureType == canceledAnnotationVM.GestureType) { - // We found the good annotation so we can delete it + // We found the good annotation so we can remove it AnnotList.Remove(a); // We redisplay the timeline CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth); tv.DataContext = null; tv.DataContext = CuttingVM; + // We close the popup and return as soon as we removed the annotation to avoid an error on AnnotList, which is just modified + confirmCancelPopup.Visibility = Visibility.Hidden; + canceledAnnotationVM = null; return; } } } + confirmCancelPopup.Visibility = Visibility.Hidden; + canceledAnnotationVM = null; } diff -r 7eb5f979d086 -r fc7c12f9da30 src/FingersDance.Views/TimelineView.xaml.cs --- a/src/FingersDance.Views/TimelineView.xaml.cs Sun Oct 11 20:38:22 2009 +0200 +++ b/src/FingersDance.Views/TimelineView.xaml.cs Tue Oct 13 10:43:39 2009 +0200 @@ -23,8 +23,6 @@ public partial class TimelineView : UserControl { - private Boolean hasDragCanceledHandler = false; - public TimelineView() { InitializeComponent(); diff -r 7eb5f979d086 -r fc7c12f9da30 src/FingersDance/MainSurfaceWindow.xaml.cs --- a/src/FingersDance/MainSurfaceWindow.xaml.cs Sun Oct 11 20:38:22 2009 +0200 +++ b/src/FingersDance/MainSurfaceWindow.xaml.cs Tue Oct 13 10:43:39 2009 +0200 @@ -271,10 +271,10 @@ { if (Panel1 != null && Grid1.Children.Count == 2) { - UserControlClose UCclose = new UserControlClose(1); + UserControlClose UCclose = new UserControlClose(1, "Êtes-vous sûr de vouloir quitter ?"); UCclose.Name = "CloseAlert1"; Grid1.Children.Add(UCclose); - UCclose.EH_SurfaceButtonClose_ContactDown += new EventHandler(CloseAlert_EH_SurfaceButton_ContactDown); + UCclose.ConfirmYesOrNo += new EventHandler(CloseAlert_EH_SurfaceButton_ContactDown); } } break; @@ -294,10 +294,10 @@ { if (Panel2 != null && Grid2.Children.Count == 2) { - UserControlClose UCclose = new UserControlClose(2); + UserControlClose UCclose = new UserControlClose(2, "Êtes-vous sûr de vouloir quitter ?"); UCclose.Name = "CloseAlert2"; Grid2.Children.Add(UCclose); - UCclose.EH_SurfaceButtonClose_ContactDown += new EventHandler(CloseAlert_EH_SurfaceButton_ContactDown); + UCclose.ConfirmYesOrNo += new EventHandler(CloseAlert_EH_SurfaceButton_ContactDown); } } break; @@ -317,10 +317,10 @@ { if (Panel3 != null && Grid3.Children.Count == 2) { - UserControlClose UCclose = new UserControlClose(3); + UserControlClose UCclose = new UserControlClose(3, "Êtes-vous sûr de vouloir quitter ?"); UCclose.Name = "CloseAlert3"; Grid3.Children.Add(UCclose); - UCclose.EH_SurfaceButtonClose_ContactDown += new EventHandler(CloseAlert_EH_SurfaceButton_ContactDown); + UCclose.ConfirmYesOrNo += new EventHandler(CloseAlert_EH_SurfaceButton_ContactDown); } } break; @@ -340,10 +340,10 @@ { if (Panel4 != null && Grid4.Children.Count == 2) { - UserControlClose UCclose = new UserControlClose(4); + UserControlClose UCclose = new UserControlClose(4, "Êtes-vous sûr de vouloir quitter ?"); UCclose.Name = "CloseAlert4"; Grid4.Children.Add(UCclose); - UCclose.EH_SurfaceButtonClose_ContactDown += new EventHandler(CloseAlert_EH_SurfaceButton_ContactDown); + UCclose.ConfirmYesOrNo += new EventHandler(CloseAlert_EH_SurfaceButton_ContactDown); } } break;