1
- using System ;
1
+ using System ;
2
2
using System . ComponentModel ;
3
3
using System . Threading . Tasks ;
4
4
using System . Windows ;
20
20
using System . Windows . Media ;
21
21
using Flow . Launcher . Infrastructure . Hotkey ;
22
22
using Flow . Launcher . Plugin . SharedCommands ;
23
+ using System . Text ;
24
+ using DataObject = System . Windows . DataObject ;
25
+ using System . Diagnostics ;
23
26
24
27
namespace Flow . Launcher
25
28
{
@@ -383,6 +386,52 @@ private void OnPreviewDragOver(object sender, DragEventArgs e)
383
386
e . Handled = true ;
384
387
}
385
388
389
+ private Point start ;
390
+
391
+ private void FileView_PreviewMouseLeftButtonDown ( object sender , MouseButtonEventArgs e )
392
+ {
393
+ this . start = e . GetPosition ( null ) ;
394
+ }
395
+
396
+ private void FileView_MouseMove ( object sender , System . Windows . Input . MouseEventArgs e )
397
+ {
398
+ Point mpos = e . GetPosition ( null ) ;
399
+ Vector diff = this . start - mpos ;
400
+
401
+ if ( e . LeftButton == MouseButtonState . Pressed &&
402
+ Math . Abs ( diff . X ) > SystemParameters . MinimumHorizontalDragDistance &&
403
+ Math . Abs ( diff . Y ) > SystemParameters . MinimumVerticalDragDistance )
404
+ {
405
+
406
+ if ( this . ResultListBox . SelectedItems . Count == 0 )
407
+ {
408
+ return ;
409
+ }
410
+
411
+ var r = ( ResultListBox ) sender ;
412
+ var d = ( DependencyObject ) e . OriginalSource ;
413
+ var item = ItemsControl . ContainerFromElement ( r , d ) as ListBoxItem ;
414
+ var result = ( ResultViewModel ) item ? . DataContext ;
415
+ Console . WriteLine ( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" ) ;
416
+ Console . WriteLine ( "result" ) ;
417
+
418
+ // right about here you get the file urls of the selected items.
419
+ // should be quite easy, if not, ask.
420
+ //string[] files = "asdf.txt";
421
+
422
+ string path = @"D:\test.png" ;
423
+ string [ ] files = { path } ;
424
+ var data = new DataObject ( System . Windows . DataFormats . FileDrop , files ) ;
425
+ data . SetData ( System . Windows . DataFormats . Text , files [ 0 ] ) ;
426
+ DragDrop . DoDragDrop ( this , data , System . Windows . DragDropEffects . Copy ) ;
427
+ e . Handled = true ;
428
+ // string dataFormat = System.Windows.DataFormats.FileDrop;
429
+ //System.Windows.DataObject dataObject = new System.Windows.DataObject(dataFormat, files);
430
+ //DragDrop.DoDragDrop(this.ResultListBox, dataObject, System.Windows.DragDropEffects.Copy);
431
+ }
432
+ }
433
+
434
+
386
435
private async void OnContextMenusForSettingsClick ( object sender , RoutedEventArgs e )
387
436
{
388
437
_viewModel . Hide ( ) ;
@@ -556,4 +605,4 @@ public void InitializeColorScheme()
556
605
}
557
606
}
558
607
}
559
- }
608
+ }
0 commit comments