Skip to content

Commit d0c281e

Browse files
committed
- Add "Move"
- Adjust Function Name
1 parent dde5a51 commit d0c281e

File tree

2 files changed

+16
-24
lines changed

2 files changed

+16
-24
lines changed

Flow.Launcher/MainWindow.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,8 @@
264264
<flowlauncher:ResultListBox
265265
x:Name="ResultListBox"
266266
DataContext="{Binding Results}"
267-
MouseMove="FileView_MouseMove"
268-
PreviewMouseLeftButtonDown="FileView_PreviewMouseLeftButtonDown"
267+
MouseMove="ResultList_MouseMove"
268+
PreviewMouseLeftButtonDown="ResultList_PreviewMouseLeftButtonDown"
269269
PreviewMouseLeftButtonUp="OnPreviewMouseButtonDown" />
270270
</ContentControl>
271271
</Border>

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -390,42 +390,34 @@ private void OnPreviewDragOver(object sender, DragEventArgs e)
390390

391391
private Point start;
392392

393-
private void FileView_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
393+
private void ResultList_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
394394
{
395395
this.start = e.GetPosition(null);
396396
}
397397

398-
private void FileView_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
398+
private void ResultList_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
399399
{
400+
if (this.ResultListBox.SelectedItems.Count == 0)
401+
{
402+
return;
403+
}
404+
400405
Point mpos = e.GetPosition(null);
401406
Vector diff = this.start - mpos;
402407

408+
var r = (ResultListBox)sender;
409+
var d = (DependencyObject)e.OriginalSource;
410+
var item = ItemsControl.ContainerFromElement(r, d) as ListBoxItem;
411+
var result = (ResultViewModel)item?.DataContext;
412+
403413
if (e.LeftButton == MouseButtonState.Pressed &&
404414
Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance &&
405415
Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance)
406416
{
407-
408-
if (this.ResultListBox.SelectedItems.Count == 0)
409-
{
410-
return;
411-
}
412-
413-
var r = (ResultListBox)sender;
414-
var d = (DependencyObject)e.OriginalSource;
415-
var item = ItemsControl.ContainerFromElement(r, d) as ListBoxItem;
416-
var result = (ResultViewModel)item?.DataContext;
417-
418-
419417
string copyText = string.IsNullOrEmpty(result.Result.CopyText) ? result.Result.SubTitle : result.Result.CopyText;
420-
var isFile = File.Exists(copyText);
421-
var isFolder = Directory.Exists(copyText);
422-
423-
//string path = @"D:\test.png";
424-
string path = Convert.ToString(copyText);
425-
string[] files = { path };
418+
string[] files = { copyText };
426419
var data = new DataObject(System.Windows.DataFormats.FileDrop, files);
427-
//data.SetData(System.Windows.DataFormats.FileDrop, files[0]);
428-
DragDrop.DoDragDrop(this.ResultListBox, data, System.Windows.DragDropEffects.Copy);
420+
DragDrop.DoDragDrop(this.ResultListBox, data, System.Windows.DragDropEffects.Copy | System.Windows.DragDropEffects.Move);
429421
e.Handled = true;
430422
}
431423
}

0 commit comments

Comments
 (0)