aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.DragAndDrop
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-05-30 19:12:04 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-05-30 19:12:04 +0300
commit9169a318121f8919e9b54cc076f63ef9a65d5b2b (patch)
tree1dd46f263b835225a930255687583e3f2fd1e7f6 /Software/Visual_Studio/Tango.DragAndDrop
parentcf5d8ed0f510792196e0153d9f9008cdce02d523 (diff)
downloadTango-9169a318121f8919e9b54cc076f63ef9a65d5b2b.tar.gz
Tango-9169a318121f8919e9b54cc076f63ef9a65d5b2b.zip
Implemented SQLite db on PPC.
Working on PPC.
Diffstat (limited to 'Software/Visual_Studio/Tango.DragAndDrop')
-rw-r--r--Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs41
-rw-r--r--Software/Visual_Studio/Tango.DragAndDrop/DragThumb.cs12
2 files changed, 48 insertions, 5 deletions
diff --git a/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs b/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs
index 60da36590..9efd9f5a6 100644
--- a/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs
+++ b/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs
@@ -31,7 +31,7 @@ namespace Tango.DragAndDrop
private static bool _isMouseDown;
private static DispatcherTimer _dragTimer;
private static Border _dragBorder;
- private const int MIN_DRAG_OFFSET = 8;
+ //private const int MIN_DRAG_OFFSET = 8;
#region Events
@@ -70,6 +70,37 @@ namespace Tango.DragAndDrop
#region Attached Properties
+ #region MinDragOffset
+
+ /// <summary>
+ /// Determines whether an element is MinDragOffset by the drag and drop service.
+ /// </summary>
+ public static readonly DependencyProperty MinDragOffsetProperty =
+ DependencyProperty.RegisterAttached("MinDragOffset",
+ typeof(int), typeof(DragAndDropService),
+ new FrameworkPropertyMetadata(8));
+ /// <summary>
+ /// Sets the MinDragOffset attached property.
+ /// </summary>
+ /// <param name="element">The element.</param>
+ /// <param name="value">if set to <c>true</c> [value].</param>
+ public static void SetMinDragOffset(FrameworkElement element, int value)
+ {
+ element.SetValue(MinDragOffsetProperty, value);
+ }
+
+ /// <summary>
+ /// Gets the MinDragOffset attached property.
+ /// </summary>
+ /// <param name="element">The element.</param>
+ /// <returns></returns>
+ public static int GetMinDragOffset(FrameworkElement element)
+ {
+ return (int)element.GetValue(MinDragOffsetProperty);
+ }
+
+ #endregion
+
#region Draggable
/// <summary>
@@ -414,7 +445,7 @@ 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) && _currentDragedElement != null)
{
DragStarted?.Invoke(_currentDragedElement, _currentDragedElement);
@@ -667,19 +698,19 @@ namespace Tango.DragAndDrop
/// <param name="e">The <see cref="System.Windows.Input.MouseEventArgs"/> instance containing the event data.</param>
private static void Draggable_MouseMove(object sender, MouseOrTouchEventArgs e)
{
- Debug.WriteLine(e.GetPosition(_currentDragedElement));
-
if (_isMouseDown)
{
FrameworkElement element = _currentDragedElement;
+ int minDragOffset = GetMinDragOffset(element);
+
if (element != null)
{
var surface = GetDraggingSurface(element);
if (surface != null)
{
- if ((e.GetPosition(element).X > _mouseDownLocation.X + MIN_DRAG_OFFSET || e.GetPosition(element).X < _mouseDownLocation.X - MIN_DRAG_OFFSET) || (e.GetPosition(element).Y > _mouseDownLocation.Y + MIN_DRAG_OFFSET || e.GetPosition(element).Y < _mouseDownLocation.Y - MIN_DRAG_OFFSET))
+ if ((e.GetPosition(element).X > _mouseDownLocation.X + minDragOffset || e.GetPosition(element).X < _mouseDownLocation.X - minDragOffset) || (e.GetPosition(element).Y > _mouseDownLocation.Y + minDragOffset || e.GetPosition(element).Y < _mouseDownLocation.Y - minDragOffset))
{
element.ReleaseMouseCapture();
surface.ReleaseMouseCapture();
diff --git a/Software/Visual_Studio/Tango.DragAndDrop/DragThumb.cs b/Software/Visual_Studio/Tango.DragAndDrop/DragThumb.cs
index 952c35bb5..355ce9997 100644
--- a/Software/Visual_Studio/Tango.DragAndDrop/DragThumb.cs
+++ b/Software/Visual_Studio/Tango.DragAndDrop/DragThumb.cs
@@ -16,5 +16,17 @@ namespace Tango.DragAndDrop
Background = Brushes.Transparent;
IsHitTestVisible = true;
}
+
+ protected override void OnMouseDown(MouseButtonEventArgs e)
+ {
+ base.OnMouseDown(e);
+ e.Handled = true;
+ }
+
+ protected override void OnPreviewMouseDown(MouseButtonEventArgs e)
+ {
+ base.OnPreviewMouseDown(e);
+ e.Handled = true;
+ }
}
}