aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.DragAndDrop
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-06-11 18:42:25 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-06-11 18:42:25 +0300
commit79097a5b33fbe082bd7680fd4ed5a44f99224820 (patch)
tree900936d23a4559e2a7e68efa5b3cca2b14c41b49 /Software/Visual_Studio/Tango.DragAndDrop
parentc4e821defadd93453b59200ea18784ea9d5dd630 (diff)
downloadTango-79097a5b33fbe082bd7680fd4ed5a44f99224820.tar.gz
Tango-79097a5b33fbe082bd7680fd4ed5a44f99224820.zip
Working on PPC LightTouchGrid !!
Diffstat (limited to 'Software/Visual_Studio/Tango.DragAndDrop')
-rw-r--r--Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs30
1 files changed, 26 insertions, 4 deletions
diff --git a/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs b/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs
index 9efd9f5a6..4473e2879 100644
--- a/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs
+++ b/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs
@@ -31,6 +31,7 @@ namespace Tango.DragAndDrop
private static bool _isMouseDown;
private static DispatcherTimer _dragTimer;
private static Border _dragBorder;
+ private static TouchDevice _touchDevice;
//private const int MIN_DRAG_OFFSET = 8;
#region Events
@@ -445,15 +446,24 @@ namespace Tango.DragAndDrop
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
private static void DragTimer_Tick(object sender, EventArgs e)
{
- if ((Mouse.LeftButton == MouseButtonState.Pressed) && _currentDragedElement != null)
+ if ((Mouse.LeftButton == MouseButtonState.Pressed || (_touchDevice != null && _touchDevice.IsActive)) && _currentDragedElement != null)
{
DragStarted?.Invoke(_currentDragedElement, _currentDragedElement);
var surface = GetDraggingSurface(_currentDragedElement);
var rootElement = surface.Parent as FrameworkElement;
- DraggingSurface.SetLeft(_dragBorder, Mouse.GetPosition(surface).X - _mouseDownLocation.X);
- DraggingSurface.SetTop(_dragBorder, Mouse.GetPosition(surface).Y - _mouseDownLocation.Y);
+ if (_touchDevice != null)
+ {
+ DraggingSurface.SetLeft(_dragBorder, _touchDevice.GetTouchPoint(surface).Position.X - _mouseDownLocation.X);
+ DraggingSurface.SetTop(_dragBorder, _touchDevice.GetTouchPoint(surface).Position.Y - _mouseDownLocation.Y);
+ }
+ else
+ {
+ DraggingSurface.SetLeft(_dragBorder, Mouse.GetPosition(surface).X - _mouseDownLocation.X);
+ DraggingSurface.SetTop(_dragBorder, Mouse.GetPosition(surface).Y - _mouseDownLocation.Y);
+ }
+
_dragBorder.Visibility = Visibility.Visible;
bool found = false;
@@ -475,7 +485,16 @@ namespace Tango.DragAndDrop
Rect dropRect = new Rect(dropPoint, new Size(dropElementScaledSize.X, dropElementScaledSize.Y));
Rect dragRect = new Rect(Canvas.GetLeft(_dragBorder), Canvas.GetTop(_dragBorder), _dragBorder.Width / 2, _dragBorder.Height);
- Point mousePoint = rootElement.PointToScreen(Mouse.GetPosition(rootElement));
+ Point mousePoint = new Point();
+
+ if (_touchDevice != null)
+ {
+ mousePoint = rootElement.PointToScreen(_touchDevice.GetTouchPoint(rootElement).Position);
+ }
+ else
+ {
+ mousePoint = rootElement.PointToScreen(Mouse.GetPosition(rootElement));
+ }
if (dropRect.IntersectsWith(new Rect(mousePoint, new Size(1, 1))))
{
@@ -723,6 +742,7 @@ namespace Tango.DragAndDrop
_isMouseDown = false;
CreateDraggingElement();
+ _touchDevice = e.TouchDevice;
_dragTimer.Start();
SetIsDragging(element, true);
}
@@ -742,6 +762,8 @@ namespace Tango.DragAndDrop
if (element != null)
{
+ e.Handled = true;
+
if ((e.GetPosition(element).X > _mouseDownLocation.X + 10 || e.GetPosition(element).X < _mouseDownLocation.X - 10) || (e.GetPosition(element).Y > _mouseDownLocation.Y + 10 || e.GetPosition(element).Y < _mouseDownLocation.Y - 10))
{
DropDraggable();