aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs')
-rw-r--r--Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs37
1 files changed, 27 insertions, 10 deletions
diff --git a/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs b/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs
index 606e8a2e5..60da36590 100644
--- a/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs
+++ b/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs
@@ -11,6 +11,7 @@ using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Threading;
+using Tango.Core.EventArguments;
using Tango.SharedUI.Helpers;
namespace Tango.DragAndDrop
@@ -489,9 +490,14 @@ namespace Tango.DragAndDrop
{
_dragElements.Add(element);
- element.PreviewMouseDown += Draggable_PreviewMouseDown;
- element.MouseMove += Draggable_MouseMove;
+ element.RegisterForPreviewMouseOrTouchDown(Draggable_PreviewMouseDown);
+ element.RegisterForMouseOrTouchMove(Draggable_MouseMove);
element.PreviewMouseUp += Draggable_PreviewMouseUp;
+ element.IsManipulationEnabled = true;
+
+ //element.AddHandler(FrameworkElement.PreviewMouseDownEvent, (MouseButtonEventHandler)Draggable_PreviewMouseDown, true);
+ //element.AddHandler(FrameworkElement.MouseMoveEvent, (MouseEventHandler)Draggable_MouseMove, true);
+ //element.AddHandler(FrameworkElement.PreviewMouseUpEvent, (MouseButtonEventHandler)Draggable_PreviewMouseUp, true);
element.Unloaded += Element_Unloaded;
}
}
@@ -630,14 +636,14 @@ namespace Tango.DragAndDrop
#region Draggable Event Handlers
- /// <summary>
- /// Handles the PreviewMouseDown event of the Draggable control.
- /// </summary>
- /// <param name="sender">The source of the event.</param>
- /// <param name="e">The <see cref="System.Windows.Input.MouseButtonEventArgs"/> instance containing the event data.</param>
- private static void Draggable_PreviewMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
+ private static void Draggable_PreviewMouseDown(object sender, MouseOrTouchEventArgs e)
{
- if (e.Source != sender) return;
+ var dragThumb = (sender as FrameworkElement).FindChild<DragThumb>();
+
+ if ((e.Source != sender && dragThumb == null) || (dragThumb != null && dragThumb != e.OriginalSource))
+ {
+ return;
+ }
FrameworkElement element = sender as FrameworkElement;
@@ -652,13 +658,17 @@ namespace Tango.DragAndDrop
_isMouseDown = true;
}
+
+
/// <summary>
/// Handles the MouseMove event of the Draggable control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.Windows.Input.MouseEventArgs"/> instance containing the event data.</param>
- private static void Draggable_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
+ private static void Draggable_MouseMove(object sender, MouseOrTouchEventArgs e)
{
+ Debug.WriteLine(e.GetPosition(_currentDragedElement));
+
if (_isMouseDown)
{
FrameworkElement element = _currentDragedElement;
@@ -673,6 +683,13 @@ namespace Tango.DragAndDrop
{
element.ReleaseMouseCapture();
surface.ReleaseMouseCapture();
+
+ if (e.TouchDevice != null)
+ {
+ element.ReleaseTouchCapture(e.TouchDevice);
+ surface.ReleaseTouchCapture(e.TouchDevice);
+ }
+
_isMouseDown = false;
CreateDraggingElement();
_dragTimer.Start();