Skip to content

Commit 2cdca89

Browse files
committed
Minor changes
1 parent 63490f5 commit 2cdca89

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

src/Files.App/Helpers/AutomaticDragHelper.cs

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
using Microsoft.UI.Input;
22
using Microsoft.UI.Xaml;
33
using Microsoft.UI.Xaml.Input;
4-
using System;
5-
using System.Collections.Generic;
6-
using System.Linq;
7-
using System.Text;
8-
using System.Text.RegularExpressions;
9-
using System.Threading.Tasks;
104
using Windows.ApplicationModel.DataTransfer;
115
using Windows.Foundation;
126
using Windows.Win32;
@@ -16,6 +10,7 @@ namespace Files.App.Helpers
1610
// https://github.com/microsoft/microsoft-ui-xaml/blob/winui3/release/1.6.3/src/dxaml/xcp/dxaml/lib/AutomaticDragHelper.cpp
1711
public class AutomaticDragHelper : DependencyObject
1812
{
13+
// Added attached dependency property to unregister event handlers
1914
public static AutomaticDragHelper GetDragHelper(DependencyObject obj)
2015
{
2116
return (AutomaticDragHelper)obj.GetValue(DragHelperProperty);
@@ -44,10 +39,11 @@ private static void OnDragHelperChanged(DependencyObject d, DependencyPropertyCh
4439
private readonly bool m_shouldAddInputHandlers;
4540
private bool m_isCheckingForMouseDrag;
4641
private Point m_lastMouseRightButtonDownPosition;
47-
private bool m_dragDropPointerPressedToken, m_dragDropPointerMovedToken, m_dragDropPointerReleasedToken, m_dragDropPointerCaptureLostToken, m_dragDropHoldingToken;
48-
private PointerPoint m_spPointerPoint;
49-
private Pointer m_spPointer;
50-
private bool m_isHoldingCompleted, m_isRightButtonPressed;
42+
private bool m_dragDropPointerPressedToken, m_dragDropPointerMovedToken, m_dragDropPointerReleasedToken, m_dragDropPointerCaptureLostToken/*, m_dragDropHoldingToken*/;
43+
//private PointerPoint m_spPointerPoint;
44+
//private Pointer m_spPointer;
45+
//private bool m_isHoldingCompleted;
46+
private bool m_isRightButtonPressed;
5147

5248
public AutomaticDragHelper(UIElement pUIElement, bool shouldAddInputHandlers)
5349
{
@@ -59,7 +55,6 @@ public AutomaticDragHelper(UIElement pUIElement, bool shouldAddInputHandlers)
5955
// moves a certain distance away from m_lastMouseRightButtonDownPosition.
6056
public void BeginCheckingForMouseDrag(Pointer pPointer)
6157
{
62-
6358
bool captured = m_pOwnerNoRef.CapturePointer(pPointer);
6459

6560
m_isCheckingForMouseDrag = !!captured;
@@ -84,13 +79,11 @@ bool ShouldStartMouseDrag(Point newMousePosition)
8479
return m_isCheckingForMouseDrag && IsOutsideDragRectangle(newMousePosition, m_lastMouseRightButtonDownPosition);
8580
}
8681

87-
8882
// Returns true if testPoint is outside of the rectangle
8983
// defined by the SM_CXDRAG and SM_CYDRAG system metrics and
9084
// dragRectangleCenter.
9185
bool IsOutsideDragRectangle(Point testPoint, Point dragRectangleCenter)
9286
{
93-
9487
double dx = Math.Abs(testPoint.X - dragRectangleCenter.X);
9588
double dy = Math.Abs(testPoint.Y - dragRectangleCenter.Y);
9689

@@ -153,8 +146,8 @@ public void HandlePointerPressedEventArgs(object sender, PointerRoutedEventArgs
153146
PointerDeviceType pointerDeviceType = PointerDeviceType.Touch;
154147
PointerPoint spPointerPoint;
155148

156-
m_spPointerPoint = null;
157-
m_spPointer = null;
149+
//m_spPointerPoint = null;
150+
//m_spPointer = null;
158151
//m_isHoldingCompleted = false;
159152

160153
spPointer = pArgs.Pointer;
@@ -172,7 +165,7 @@ public void HandlePointerPressedEventArgs(object sender, PointerRoutedEventArgs
172165
spPointerProperties = spPointerPoint.Properties;
173166
isRightButtonPressed = spPointerProperties.IsRightButtonPressed;
174167

175-
// If the left mouse button was the one pressed...
168+
// If the right mouse button was the one pressed...
176169
if (!m_isRightButtonPressed && isRightButtonPressed)
177170
{
178171
m_isRightButtonPressed = true;
@@ -227,7 +220,6 @@ public void HandlePointerMovedEventArgs(object sender, PointerRoutedEventArgs pA
227220
}
228221
}
229222

230-
231223
public void HandlePointerReleasedEventArgs(object sender, PointerRoutedEventArgs pArgs)
232224
{
233225
Pointer spPointer;
@@ -247,7 +239,7 @@ public void HandlePointerReleasedEventArgs(object sender, PointerRoutedEventArgs
247239
spPointerProperties = spPointerPoint.Properties;
248240
isRightButtonPressed = spPointerProperties.IsRightButtonPressed;
249241

250-
// if the mouse left button was the one released...
242+
// if the mouse right button was the one released...
251243
if (m_isRightButtonPressed && !isRightButtonPressed)
252244
{
253245
m_isRightButtonPressed = false;

0 commit comments

Comments
 (0)