--- a/src/FingersDance.ActionFactory/ActionFactory.cs Sun Oct 11 20:14:02 2009 +0200
+++ b/src/FingersDance.ActionFactory/ActionFactory.cs Sun Oct 11 20:38:22 2009 +0200
@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
-using FingersDance.Control.Player;
namespace FingersDance.ActionFactory
{
--- a/src/FingersDance.ActionFactory/ActionGenerator.cs Sun Oct 11 20:14:02 2009 +0200
+++ b/src/FingersDance.ActionFactory/ActionGenerator.cs Sun Oct 11 20:38:22 2009 +0200
@@ -17,6 +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("ActionAddAnnotation", typeof(FingersDance.Actions.ActionAddAnnotation));
}
--- a/src/FingersDance.ActionFactory/FingersDance.ActionFactory.csproj Sun Oct 11 20:14:02 2009 +0200
+++ b/src/FingersDance.ActionFactory/FingersDance.ActionFactory.csproj Sun Oct 11 20:38:22 2009 +0200
@@ -3,7 +3,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.21022</ProductVersion>
+ <ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{C7B905EA-0678-4DA0-8EF8-7F9CBD22818E}</ProjectGuid>
<OutputType>Library</OutputType>
@@ -74,10 +74,6 @@
<Project>{1E80D5A1-C45C-443B-8992-4A4D78D280FC}</Project>
<Name>FingersDance.Actions</Name>
</ProjectReference>
- <ProjectReference Include="..\FingersDance.Control.Player\FingersDance.Control.Player.csproj">
- <Project>{D5625AA4-362F-4E46-9916-65F3B173ECBE}</Project>
- <Name>FingersDance.Control.Player</Name>
- </ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
--- a/src/FingersDance.Actions/ActionAddAnnotation.cs Sun Oct 11 20:14:02 2009 +0200
+++ b/src/FingersDance.Actions/ActionAddAnnotation.cs Sun Oct 11 20:38:22 2009 +0200
@@ -4,6 +4,7 @@
using System.Text;
using FingersDance.Control.TimeLine;
+using FingersDance.ViewModels;
namespace FingersDance.Actions
{
@@ -11,6 +12,7 @@
{
private string _Text = "";
private UserControlTimeLine myTimeline;
+ private AnnotationViewModel myAnnotationViewModel;
public ActionAddAnnotation()
{
@@ -22,15 +24,16 @@
_Text = text;
}
- public ActionAddAnnotation(UserControlTimeLine uct)
+ public ActionAddAnnotation(List<Object> args)
{
- myTimeline = uct;
+ myTimeline = (UserControlTimeLine)args[0];
+ myAnnotationViewModel = (AnnotationViewModel)args[1];
}
public void Execute()
{
if (myTimeline != null)
- myTimeline.addAnnotation();
+ myTimeline.addAnnotation(myAnnotationViewModel);
}
}
}
--- a/src/FingersDance.Actions/FingersDance.Actions.csproj Sun Oct 11 20:14:02 2009 +0200
+++ b/src/FingersDance.Actions/FingersDance.Actions.csproj Sun Oct 11 20:38:22 2009 +0200
@@ -121,6 +121,10 @@
<Project>{2BCEE1BF-D3AC-478C-A26B-DFDB7420E965}</Project>
<Name>FingersDance.Control.TimeLine</Name>
</ProjectReference>
+ <ProjectReference Include="..\FingersDance.ViewModel\FingersDance.ViewModels.csproj">
+ <Project>{E81BB080-0598-43AC-90CE-54D6570C4E9E}</Project>
+ <Name>FingersDance.ViewModels</Name>
+ </ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
--- a/src/FingersDance.Control.Player/FingersDance.Control.Player.csproj Sun Oct 11 20:14:02 2009 +0200
+++ b/src/FingersDance.Control.Player/FingersDance.Control.Player.csproj Sun Oct 11 20:38:22 2009 +0200
@@ -142,10 +142,26 @@
<Resource Include="Resources\WindowBackground.jpg" />
</ItemGroup>
<ItemGroup>
+ <ProjectReference Include="..\FingersDance.ActionFactory\FingersDance.ActionFactory.csproj">
+ <Project>{C7B905EA-0678-4DA0-8EF8-7F9CBD22818E}</Project>
+ <Name>FingersDance.ActionFactory</Name>
+ </ProjectReference>
<ProjectReference Include="..\FingersDance.Actions\FingersDance.Actions.csproj">
<Project>{1E80D5A1-C45C-443B-8992-4A4D78D280FC}</Project>
<Name>FingersDance.Actions</Name>
</ProjectReference>
+ <ProjectReference Include="..\FingersDance.Control.TimeLine\FingersDance.Control.TimeLine.csproj">
+ <Project>{2BCEE1BF-D3AC-478C-A26B-DFDB7420E965}</Project>
+ <Name>FingersDance.Control.TimeLine</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\FingersDance.ViewModel\FingersDance.ViewModels.csproj">
+ <Project>{E81BB080-0598-43AC-90CE-54D6570C4E9E}</Project>
+ <Name>FingersDance.ViewModels</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\FingersDance.Views\FingersDance.Views.csproj">
+ <Project>{0B308B6E-7B1E-46C0-ACC7-0B7EFC4D0B2C}</Project>
+ <Name>FingersDance.Views</Name>
+ </ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
--- a/src/FingersDance.Control.Player/UserControlPlayer.xaml Sun Oct 11 20:14:02 2009 +0200
+++ b/src/FingersDance.Control.Player/UserControlPlayer.xaml Sun Oct 11 20:38:22 2009 +0200
@@ -6,7 +6,7 @@
mc:Ignorable="d"
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.Player.UserControlPlayer"
- x:Name="UserControl"
+ x:Name="UserControl" AllowDrop="True" Custom:SurfaceDragDrop.DragOver="Play_Pause_area_DragOver" Custom:SurfaceDragDrop.DragEnter="Play_Pause_area_DragEnter" Custom:SurfaceDragDrop.DragLeave="Play_Pause_area_DragLeave" Custom:SurfaceDragDrop.Drop="Play_Pause_area_Drop"
Width="560" Height="400">
<UserControl.Resources>
<Storyboard x:Key="OnClick1"/>
@@ -125,20 +125,25 @@
</Style.BasedOn>
</Style>
</UserControl.Resources>
- <Grid x:Name="LayoutRoot" Width="{Binding ActualWidth, ElementName=UserControl, Mode=Default}" Height="{Binding ActualHeight, ElementName=UserControl, Mode=Default}" Background="{x:Null}" >
- <Viewbox Margin="0,0,0,0" Width="{Binding ActualWidth, ElementName=UserControl, Mode=Default}" Height="{Binding ActualHeight, ElementName=UserControl, Mode=Default}" Stretch="Uniform">
- <Grid Width="560" Height="400" HorizontalAlignment="Left" x:Name="GridPlayer">
- <MediaElement x:Name="MediaElementVideo" MediaOpened="MediaElementVideo_MediaOpened" Stretch="Fill" ScrubbingEnabled="False" StretchDirection="Both" Margin="0,0,50,0" />
- <Custom:SurfaceButton x:Name="Rewind_area" Content="" ContactDown="ButtonRewind_ContactDown" Click="ButtonRewind_Click" Foreground="{x:Null}" Background="#FFFFFFFF" BorderBrush="{x:Null}" Opacity="0" Width="72" HorizontalAlignment="Left" Style="{DynamicResource FingersDance.Control.PlayerButton}" Margin="0,0,0,196"/>
- <Custom:SurfaceButton x:Name="Fast_Forward_area" Content="" ContactDown="ButtonFastForward_ContactDown" Click="ButtonFastForward_Click" Foreground="{x:Null}" Background="#FFFFFFFF" BorderBrush="{x:Null}" Opacity="0" Width="72" HorizontalAlignment="Right" Style="{DynamicResource FingersDance.Control.PlayerButton}" Margin="0,0,54,196"/>
- <Custom:SurfaceButton x:Name="Play_Pause_area" ContactDown="ButtonPlayPause_ContactDown" Click="ButtonPlayPause_Click" Foreground="{x:Null}" Background="#FFFFFFFF" BorderBrush="{x:Null}" Margin="72,0,126,196" Style="{DynamicResource FingersDance.Control.PlayerButton}" Opacity="0"/>
- <StackPanel Opacity="1" HorizontalAlignment="Right" Width="50" Background="#FF0046F6" x:Name="StackPanelAnnotation" VerticalAlignment="Bottom" Height="Auto">
- <Rectangle Width="50" Height="50" Fill="#FFFFFFFF" Stroke="#FF000000"/>
- <Rectangle Width="50" Height="50" Fill="#FFFFFFFF" Stroke="#FF000000"/>
- <Rectangle Width="50" Height="50" Fill="#FFFFFFFF" Stroke="#FF000000"/>
- <Rectangle Width="50" Height="50" Fill="#FFFFFFFF" Stroke="#FF000000" VerticalAlignment="Bottom"/>
- </StackPanel>
- </Grid>
- </Viewbox>
- </Grid>
+ <Grid x:Name="LayoutRoot" Width="{Binding ActualWidth, ElementName=UserControl, Mode=Default}" Height="{Binding ActualHeight, ElementName=UserControl, Mode=Default}" Background="{x:Null}">
+ <Viewbox Margin="0,0,0,0" Width="{Binding ActualWidth, ElementName=UserControl, Mode=Default}" Height="{Binding ActualHeight, ElementName=UserControl, Mode=Default}" Stretch="Uniform" AllowDrop="True">
+ <Grid Width="560" Height="400" HorizontalAlignment="Left" x:Name="GridPlayer">
+ <MediaElement x:Name="MediaElementVideo" MediaOpened="MediaElementVideo_MediaOpened" Stretch="Fill" ScrubbingEnabled="False" StretchDirection="Both" Margin="0,0,50,0" />
+ <Custom:SurfaceButton x:Name="Rewind_area" Content="" ContactDown="ButtonRewind_ContactDown"
+ Click="ButtonRewind_Click" Foreground="{x:Null}" Background="#FFFFFFFF" BorderBrush="{x:Null}"
+ Opacity="0" Width="72" HorizontalAlignment="Left" Style="{DynamicResource FingersDance.Control.PlayerButton}" Margin="0,0,0,0"/>
+ <Custom:SurfaceButton x:Name="Fast_Forward_area" Content="" ContactDown="ButtonFastForward_ContactDown" Click="ButtonFastForward_Click"
+ Foreground="{x:Null}" Background="#FFFFFFFF" BorderBrush="{x:Null}" Opacity="0" Width="72" HorizontalAlignment="Right"
+ Style="{DynamicResource FingersDance.Control.PlayerButton}" Margin="0,0,54,0"/>
+ <Custom:SurfaceButton x:Name="Play_Pause_area" ContactDown="ButtonPlayPause_ContactDown" Click="ButtonPlayPause_Click" Foreground="{x:Null}"
+ Background="#FFFFFFFF" BorderBrush="{x:Null}" Margin="72,0,126,0" Style="{DynamicResource FingersDance.Control.PlayerButton}" Opacity="0"/>
+ <StackPanel Opacity="1" HorizontalAlignment="Right" Width="50" Background="#FF0046F6" x:Name="StackPanelAnnotation" VerticalAlignment="Bottom" Height="Auto">
+ <Rectangle Width="50" Height="50" Fill="#FFFFFFFF" Stroke="#FF000000"/>
+ <Rectangle Width="50" Height="50" Fill="#FFFFFFFF" Stroke="#FF000000"/>
+ <Rectangle Width="50" Height="50" Fill="#FFFFFFFF" Stroke="#FF000000"/>
+ <Rectangle Width="50" Height="50" Fill="#FFFFFFFF" Stroke="#FF000000" VerticalAlignment="Bottom"/>
+ </StackPanel>
+ </Grid>
+ </Viewbox>
+ </Grid>
</UserControl>
\ No newline at end of file
--- a/src/FingersDance.Control.Player/UserControlPlayer.xaml.cs Sun Oct 11 20:14:02 2009 +0200
+++ b/src/FingersDance.Control.Player/UserControlPlayer.xaml.cs Sun Oct 11 20:38:22 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<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
--- a/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs Sun Oct 11 20:14:02 2009 +0200
+++ b/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs Sun Oct 11 20:38:22 2009 +0200
@@ -5,15 +5,18 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
+using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Navigation;
using System.Windows.Controls.Primitives;
using Microsoft.Surface.Presentation.Controls;
+using Microsoft.Surface.Presentation;
using System.Windows.Threading;
using FingersDance.Data;
using FingersDance.ViewModels;
+using FingersDance.Views;
namespace FingersDance.Control.TimeLine
{
@@ -118,7 +121,13 @@
CuttingVM = new CuttingViewModel(cut, AnnotWidth);
tv.DataContext = CuttingVM;
- slider_ContactTapGesture(this,null);
+ tv.listview.PreviewContactDown += listview_PreviewContactDown;
+ SurfaceDragDrop.AddDragCanceledHandler(tv.listview, onDragCanceled);
+
+ UserControlTimeLine_SizeChanged(null, null);
+
+ slider_ContactTapGesture(this, null);
+
}
@@ -182,8 +191,7 @@
DragStarted(this, new EventArgs());
}
- private void sliderPosition_DragCompleted(
- object sender, DragCompletedEventArgs e)
+ private void sliderPosition_DragCompleted(object sender, DragCompletedEventArgs e)
{
finishedDragging = true;
OnDragCompleted();
@@ -196,10 +204,78 @@
private void slider_ContactTapGesture(object sender, Microsoft.Surface.Presentation.ContactEventArgs e)
{
- //addAnnotation();
+ //startOrEndAnnotation();
+ }
+
+ public Boolean isAnnotationAccepted(AnnotationViewModel avm)
+ {
+ Boolean annotOk = true;
+ // We check if the annotation's begin and end timecodes allow a new annotation creation
+ if (CuttingVM != null && AnnotWaiting == false)
+ {
+ 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 <= avm.TcBegin && avm.TcBegin <= (a.TcBegin + a.Dur))
+ {
+ annotOk = false;
+ }
+ // Check end tc and if the new annotation will not cover any other
+ float endTC = avm.TcBegin + avm.Dur;
+ //Console.WriteLine("a.TcBegin = " + a.TcBegin + ", tcOut = " + (a.TcBegin + a.Dur) + ", AnnotTcBegin = " + AnnotTcBegin + ", currentTC = " + currentTC);
+ if (a.TcBegin <= endTC && endTC <= (a.TcBegin + a.Dur) || (avm.TcBegin < a.TcBegin && (a.TcBegin + a.Dur) < endTC))
+ {
+ annotOk = false;
+ }
+ }
+ }
+ else
+ {
+ annotOk = false;
+ }
+ return annotOk;
+
}
- public void addAnnotation()
+ public void addAnnotation(AnnotationViewModel avm)
+ {
+ //Console.WriteLine("addAnnotation = " + avm.TcBegin + ", " + avm.Dur + ", " + avm.GestureType);
+ Boolean annotOk = true;
+ // We check if the annotation's begin and end timecodes allow a new annotation creation
+ if (CuttingVM != null && AnnotWaiting == false)
+ {
+ 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 <= avm.TcBegin && avm.TcBegin <= (a.TcBegin + a.Dur))
+ {
+ annotOk = false;
+ }
+ // Check end tc and if the new annotation will not cover any other
+ float endTC = avm.TcBegin + avm.Dur;
+ //Console.WriteLine("a.TcBegin = " + a.TcBegin + ", tcOut = " + (a.TcBegin + a.Dur) + ", AnnotTcBegin = " + AnnotTcBegin + ", currentTC = " + currentTC);
+ if (a.TcBegin <= endTC && endTC <= (a.TcBegin + a.Dur) || (avm.TcBegin < a.TcBegin && (a.TcBegin + a.Dur) < endTC))
+ {
+ annotOk = false;
+ }
+ }
+ // If everything's fine, we create the new one
+ if (annotOk == true)
+ {
+ AnnotList.Add(new Annotation(avm.TcBegin, avm.Dur, avm.GestureType));
+ CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth);
+ tv.DataContext = null;
+ tv.DataContext = CuttingVM;
+ AnnotWaiting = false;
+ }
+
+ }
+
+ }
+
+ public void startOrEndAnnotation()
{
Boolean annotOk = true;
// We open a new annotation
@@ -257,5 +333,98 @@
}
}
+
+ 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
+ }
+ };
+
+ // We apply the current scale to the dragged annotation
+ ((TimelineAnnotationView)cursorVisual.Content).RenderTransform = this.RenderTransform;
+
+ // Add a handler. This will enable the application to change the visual cues. (NOT USEFUL IN FINGERSDANCE CASE)
+ //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<InputDevice> devices = new List<InputDevice>();
+ 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;
+ }
+
+ 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;
+ // We check if the annotation is well one of the current annotations
+ if (CuttingVM != null)
+ {
+ 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)
+ {
+ // We found the good annotation so we can delete it
+ AnnotList.Remove(a);
+ // We redisplay the timeline
+ CuttingVM.setListFromAnnotations(AnnotList, AnnotWidth);
+ tv.DataContext = null;
+ tv.DataContext = CuttingVM;
+ return;
+ }
+ }
+ }
+ }
+
+
}
}
\ No newline at end of file
--- a/src/FingersDance.ViewModel/AnnotationViewModel.cs Sun Oct 11 20:14:02 2009 +0200
+++ b/src/FingersDance.ViewModel/AnnotationViewModel.cs Sun Oct 11 20:38:22 2009 +0200
@@ -20,8 +20,6 @@
this._dur = a.Dur;
this._gestureType = a.GestureType;
this._marginLeft = marginLeft;
-
- Console.WriteLine("_tcBegin = " + _tcBegin + ", _marginLeft = " + _marginLeft);
}
public float TcBegin
--- a/src/FingersDance.Views/FingersDance.Views.csproj Sun Oct 11 20:14:02 2009 +0200
+++ b/src/FingersDance.Views/FingersDance.Views.csproj Sun Oct 11 20:38:22 2009 +0200
@@ -123,6 +123,10 @@
</Page>
</ItemGroup>
<ItemGroup>
+ <ProjectReference Include="..\FingersDance.Data\FingersDance.Data.csproj">
+ <Project>{EAF384DB-2AE4-4132-839D-60F9DAFDEAD8}</Project>
+ <Name>FingersDance.Data</Name>
+ </ProjectReference>
<ProjectReference Include="..\FingersDance.ViewModel\FingersDance.ViewModels.csproj">
<Project>{E81BB080-0598-43AC-90CE-54D6570C4E9E}</Project>
<Name>FingersDance.ViewModels</Name>
--- a/src/FingersDance.Views/TimelineView.xaml Sun Oct 11 20:14:02 2009 +0200
+++ b/src/FingersDance.Views/TimelineView.xaml Sun Oct 11 20:38:22 2009 +0200
@@ -17,9 +17,9 @@
</ItemsPanelTemplate>
</UserControl.Resources>
<Grid>
- <Custom:SurfaceListBox Background="{x:Null}" x:Name="listview" ScrollViewer.HorizontalScrollBarVisibility="Hidden" BorderThickness="2"
+ <Custom:SurfaceListBox Background="{x:Null}" x:Name="listview" x:FieldModifier="public" ScrollViewer.HorizontalScrollBarVisibility="Hidden" BorderThickness="2"
ItemsSource="{Binding Path=AnnotList}" ItemTemplate="{StaticResource slbDataTemplate}" ItemsPanel="{StaticResource slbItemsPanelTemplate}"
- PreviewContactDown="listview_PreviewContactDown">
+ >
</Custom:SurfaceListBox>
<!--ListView DataContext="{Binding Path=AnnotList}"
--- a/src/FingersDance.Views/TimelineView.xaml.cs Sun Oct 11 20:14:02 2009 +0200
+++ b/src/FingersDance.Views/TimelineView.xaml.cs Sun Oct 11 20:38:22 2009 +0200
@@ -6,16 +6,14 @@
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.Navigation;
using System.Windows.Shapes;
-using Microsoft.Surface.Presentation.Controls;
-using Microsoft.Surface.Presentation;
+using FingersDance.Data;
+using FingersDance.ViewModels;
using FingersDance.Views;
-using FingersDance.ViewModels;
namespace FingersDance.Views
{
@@ -24,76 +22,15 @@
/// </summary>
public partial class TimelineView : UserControl
{
+
+ private Boolean hasDragCanceledHandler = false;
+
public TimelineView()
{
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
- }
- };
-
- // We apply the current scale to the dragged annotation
- ((TimelineAnnotationView)cursorVisual.Content).RenderTransform = this.RenderTransform;
-
- // 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<InputDevice> devices = new List<InputDevice>();
- 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;
-
- }
+
}
}
--- a/src/FingersDance/FingersDance.csproj Sun Oct 11 20:14:02 2009 +0200
+++ b/src/FingersDance/FingersDance.csproj Sun Oct 11 20:38:22 2009 +0200
@@ -183,6 +183,10 @@
<Project>{E6A3A067-1CB4-43D2-BB9C-DC72361F7E22}</Project>
<Name>FingersDance.Control.UserPanel</Name>
</ProjectReference>
+ <ProjectReference Include="..\FingersDance.ViewModel\FingersDance.ViewModels.csproj">
+ <Project>{E81BB080-0598-43AC-90CE-54D6570C4E9E}</Project>
+ <Name>FingersDance.ViewModels</Name>
+ </ProjectReference>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
--- a/src/FingersDance/Resources/menu.xml Sun Oct 11 20:14:02 2009 +0200
+++ b/src/FingersDance/Resources/menu.xml Sun Oct 11 20:38:22 2009 +0200
@@ -68,13 +68,13 @@
<Name>Saut 1</Name>
<Items/>
<Ressource>FingersDanceAnnotationButtonNiveau3</Ressource>
- <Action>ActionAddAnnotation</Action>
+ <Action>ActionStartOrEndAnnotation</Action>
</Item>
<Item>
<Name>Pirouette 2</Name>
<Items/>
<Ressource>FingersDanceAnnotationButtonNiveau3</Ressource>
- <Action>ActionAddAnnotation</Action>
+ <Action>ActionStartOrEndAnnotation</Action>
</Item>
</Items>
<Ressource>FingersDanceAnnotationButtonNiveau2</Ressource>