aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.DragAndDrop
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-05-29 19:44:54 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-05-29 19:44:54 +0300
commitac9090470eba25bb3c789f0e87ecf70e6a7be55f (patch)
tree0b26051e6af32d7c7181024ef942da6c36c7467e /Software/Visual_Studio/Tango.DragAndDrop
parent378789e4c4bc694736965cb8c620883bf91b8f08 (diff)
downloadTango-ac9090470eba25bb3c789f0e87ecf70e6a7be55f.tar.gz
Tango-ac9090470eba25bb3c789f0e87ecf70e6a7be55f.zip
Working on Mouse/Touch synchronization!
Diffstat (limited to 'Software/Visual_Studio/Tango.DragAndDrop')
-rw-r--r--Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs37
-rw-r--r--Software/Visual_Studio/Tango.DragAndDrop/DragThumb.cs20
-rw-r--r--Software/Visual_Studio/Tango.DragAndDrop/Tango.DragAndDrop.csproj5
3 files changed, 52 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();
diff --git a/Software/Visual_Studio/Tango.DragAndDrop/DragThumb.cs b/Software/Visual_Studio/Tango.DragAndDrop/DragThumb.cs
new file mode 100644
index 000000000..952c35bb5
--- /dev/null
+++ b/Software/Visual_Studio/Tango.DragAndDrop/DragThumb.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Controls;
+using System.Windows.Input;
+using System.Windows.Media;
+
+namespace Tango.DragAndDrop
+{
+ public class DragThumb : Grid
+ {
+ public DragThumb()
+ {
+ Background = Brushes.Transparent;
+ IsHitTestVisible = true;
+ }
+ }
+}
diff --git a/Software/Visual_Studio/Tango.DragAndDrop/Tango.DragAndDrop.csproj b/Software/Visual_Studio/Tango.DragAndDrop/Tango.DragAndDrop.csproj
index 324bf9f90..771ed8079 100644
--- a/Software/Visual_Studio/Tango.DragAndDrop/Tango.DragAndDrop.csproj
+++ b/Software/Visual_Studio/Tango.DragAndDrop/Tango.DragAndDrop.csproj
@@ -69,6 +69,7 @@
</Compile>
<Compile Include="DragAndDropService.cs" />
<Compile Include="DraggingSurface.cs" />
+ <Compile Include="DragThumb.cs" />
<Compile Include="DropEventArgs.cs" />
</ItemGroup>
<ItemGroup>
@@ -98,6 +99,10 @@
<AppDesigner Include="Properties\" />
</ItemGroup>
<ItemGroup>
+ <ProjectReference Include="..\Tango.Core\Tango.Core.csproj">
+ <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project>
+ <Name>Tango.Core</Name>
+ </ProjectReference>
<ProjectReference Include="..\Tango.SharedUI\Tango.SharedUI.csproj">
<Project>{8491d07b-c1f6-4b62-a412-41b9fd2d6538}</Project>
<Name>Tango.SharedUI</Name>