mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
add drag and drop for folders
This commit is contained in:
parent
b47206e359
commit
9bbd01a1d7
1 changed files with 10 additions and 6 deletions
|
|
@ -60,7 +60,7 @@ namespace Flow.Launcher
|
||||||
|
|
||||||
|
|
||||||
private Point start;
|
private Point start;
|
||||||
private string file;
|
private string path;
|
||||||
private string query;
|
private string query;
|
||||||
|
|
||||||
private void ResultList_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
private void ResultList_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||||
|
|
@ -68,7 +68,7 @@ namespace Flow.Launcher
|
||||||
if (Mouse.DirectlyOver is not FrameworkElement { DataContext: ResultViewModel result })
|
if (Mouse.DirectlyOver is not FrameworkElement { DataContext: ResultViewModel result })
|
||||||
return;
|
return;
|
||||||
|
|
||||||
file = result.Result.CopyText;
|
path = result.Result.CopyText;
|
||||||
query = result.Result.OriginQuery.RawQuery;
|
query = result.Result.OriginQuery.RawQuery;
|
||||||
start = e.GetPosition(null);
|
start = e.GetPosition(null);
|
||||||
}
|
}
|
||||||
|
|
@ -78,24 +78,28 @@ namespace Flow.Launcher
|
||||||
if (e.LeftButton != MouseButtonState.Pressed)
|
if (e.LeftButton != MouseButtonState.Pressed)
|
||||||
{
|
{
|
||||||
start = default;
|
start = default;
|
||||||
file = null;
|
path = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!File.Exists(path) && !Directory.Exists(path))
|
||||||
|
return;
|
||||||
|
|
||||||
Point mousePosition = e.GetPosition(null);
|
Point mousePosition = e.GetPosition(null);
|
||||||
Vector diff = this.start - mousePosition;
|
Vector diff = this.start - mousePosition;
|
||||||
|
|
||||||
if (Math.Abs(diff.X) < SystemParameters.MinimumHorizontalDragDistance
|
if (Math.Abs(diff.X) < SystemParameters.MinimumHorizontalDragDistance
|
||||||
|| Math.Abs(diff.Y) < SystemParameters.MinimumVerticalDragDistance
|
|| Math.Abs(diff.Y) < SystemParameters.MinimumVerticalDragDistance)
|
||||||
|| !File.Exists(file))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var data = new DataObject(DataFormats.FileDrop, new[]
|
var data = new DataObject(DataFormats.FileDrop, new[]
|
||||||
{
|
{
|
||||||
file
|
path
|
||||||
});
|
});
|
||||||
DragDrop.DoDragDrop((DependencyObject)sender, data, DragDropEffects.Move | DragDropEffects.Copy);
|
DragDrop.DoDragDrop((DependencyObject)sender, data, DragDropEffects.Move | DragDropEffects.Copy);
|
||||||
|
|
||||||
App.API.ChangeQuery(query, true);
|
App.API.ChangeQuery(query, true);
|
||||||
|
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue