Skip to content

Commit c1be1cf

Browse files
committed
less eager dragging
1 parent 9a3c68f commit c1be1cf

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

DWBox/MainWindow.xaml.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,16 +406,36 @@ private void OnRenderingsDrop(object sender, DragEventArgs e)
406406
}
407407
}
408408

409+
private Point _itemMouseDown;
410+
409411
private void OnItemMouseMove(object sender, MouseEventArgs e)
410412
{
411413
if (e.LeftButton == MouseButtonState.Pressed)
414+
{
412415
if (sender is FrameworkElement el)
416+
{
417+
if (_itemMouseDown == default)
418+
{
419+
_itemMouseDown = e.GetPosition(el);
420+
return;
421+
}
422+
423+
Vector movement = e.GetPosition(el) - _itemMouseDown;
424+
425+
if (Math.Abs(movement.X) < SystemParameters.MinimumHorizontalDragDistance &&
426+
Math.Abs(movement.Y) < SystemParameters.MinimumVerticalDragDistance)
427+
return;
428+
413429
if (el.DataContext is BoxItem item && item.FilePath is string path)
414430
{
415431
DataObject data = new DataObject();
416432
data.SetFileDropList(new StringCollection { path });
417433
DragDrop.DoDragDrop(el, data, DragDropEffects.Copy);
418434
}
435+
}
436+
}
437+
438+
_itemMouseDown = default;
419439
}
420440

421441
private void OnTextAnalysis(object sender, RoutedEventArgs e)

0 commit comments

Comments
 (0)