aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.DragAndDrop
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2019-05-01 12:57:24 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2019-05-01 12:57:24 +0300
commit488a8afab6fb62a0a16c7c49b24f8ad986cbab33 (patch)
tree74da6384001781097bd15133e389bd9b57d7a7a8 /Software/Visual_Studio/Tango.DragAndDrop
parentf7a90a31ca1536b2ff798f2a182194ffd221d6db (diff)
downloadTango-488a8afab6fb62a0a16c7c49b24f8ad986cbab33.tar.gz
Tango-488a8afab6fb62a0a16c7c49b24f8ad986cbab33.zip
Added weak reference implementation for MouseTouch registrations and DragAndDrop.
Dispose db context when loading new job (might be a problem later).. Added WeakList implementation.
Diffstat (limited to 'Software/Visual_Studio/Tango.DragAndDrop')
-rw-r--r--Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs22
1 files changed, 12 insertions, 10 deletions
diff --git a/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs b/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs
index e814985e6..8bd5e7e0b 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;
using Tango.Core.EventArguments;
@@ -23,8 +24,8 @@ namespace Tango.DragAndDrop
/// <seealso cref="DropEventArgs" />
public static class DragAndDropService
{
- private static List<FrameworkElement> _dragElements;
- private static List<FrameworkElement> _dropElements;
+ private static WeakList<FrameworkElement> _dragElements;
+ private static WeakList<FrameworkElement> _dropElements;
private static Point _mouseDownLocation;
private static FrameworkElement _currentDragedElement;
private static FrameworkElement _currentDropElement;
@@ -59,8 +60,8 @@ namespace Tango.DragAndDrop
/// </summary>
static DragAndDropService()
{
- _dragElements = new List<FrameworkElement>();
- _dropElements = new List<FrameworkElement>();
+ _dragElements = new WeakList<FrameworkElement>();
+ _dropElements = new WeakList<FrameworkElement>();
_dragTimer = new DispatcherTimer();
_dragTimer.Interval = TimeSpan.FromMilliseconds(30);
_dragTimer.Tick += DragTimer_Tick;
@@ -573,13 +574,14 @@ namespace Tango.DragAndDrop
element.RegisterForPreviewMouseOrTouchDown(Draggable_PreviewMouseDown);
element.RegisterForMouseOrTouchMove(Draggable_MouseMove);
- element.PreviewMouseUp += Draggable_PreviewMouseUp;
+ //element.PreviewMouseUp += Draggable_PreviewMouseUp;
+ element.AddHandler(FrameworkElement.PreviewMouseUpEvent, new MouseButtonEventHandler(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 += Draggable_Unloaded;
+ //element.Unloaded += Draggable_Unloaded;
}
}
@@ -592,7 +594,7 @@ namespace Tango.DragAndDrop
if (!_dropElements.Contains(element))
{
_dropElements.Add(element);
- element.Unloaded += Droppable_Unloaded;
+ //element.Unloaded += Droppable_Unloaded;
}
}
@@ -646,7 +648,7 @@ namespace Tango.DragAndDrop
{
if (_currentDragedElement != null)
{
- BitmapSource source = _currentDragedElement.TakeSnapshot();
+ BitmapSource source = _currentDragedElement.TakeSnapshot();
_dragBorder = new Border();
var surface = GetDraggingSurface(_currentDragedElement);
@@ -761,7 +763,7 @@ namespace Tango.DragAndDrop
FrameworkElement element = sender as FrameworkElement;
- if (!_dragElements.Exists(x => x == element))
+ if (!_dragElements.ToList().Exists(x => x == element))
{
e.Handled = false;
return;
@@ -772,7 +774,7 @@ namespace Tango.DragAndDrop
_isMouseDown = true;
}
-
+
/// <summary>
/// Handles the MouseMove event of the Draggable control.