1
- using System . Windows ;
1
+ using System ;
2
+ using System . IO ;
3
+ using System . Windows ;
2
4
using System . Windows . Controls ;
3
5
using System . Windows . Input ;
6
+ using Flow . Launcher . ViewModel ;
4
7
5
8
namespace Flow . Launcher
6
9
{
@@ -24,7 +27,7 @@ private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
24
27
25
28
private void OnMouseEnter ( object sender , MouseEventArgs e )
26
29
{
27
- lock ( _lock )
30
+ lock ( _lock )
28
31
{
29
32
curItem = ( ListBoxItem ) sender ;
30
33
var p = e . GetPosition ( ( IInputElement ) sender ) ;
@@ -34,7 +37,7 @@ private void OnMouseEnter(object sender, MouseEventArgs e)
34
37
35
38
private void OnMouseMove ( object sender , MouseEventArgs e )
36
39
{
37
- lock ( _lock )
40
+ lock ( _lock )
38
41
{
39
42
var p = e . GetPosition ( ( IInputElement ) sender ) ;
40
43
if ( _lastpos != p )
@@ -46,13 +49,59 @@ private void OnMouseMove(object sender, MouseEventArgs e)
46
49
47
50
private void ListBox_PreviewMouseDown ( object sender , MouseButtonEventArgs e )
48
51
{
49
- lock ( _lock )
52
+ lock ( _lock )
50
53
{
51
54
if ( curItem != null )
52
55
{
53
56
curItem . IsSelected = true ;
54
57
}
55
58
}
56
59
}
60
+
61
+
62
+ private Point start ;
63
+ private string path ;
64
+ private string query ;
65
+
66
+ private void ResultList_PreviewMouseLeftButtonDown ( object sender , MouseButtonEventArgs e )
67
+ {
68
+ if ( Mouse . DirectlyOver is not FrameworkElement { DataContext : ResultViewModel result } )
69
+ return ;
70
+
71
+ path = result . Result . CopyText ;
72
+ query = result . Result . OriginQuery . RawQuery ;
73
+ start = e . GetPosition ( null ) ;
74
+ }
75
+
76
+ private void ResultList_MouseMove ( object sender , MouseEventArgs e )
77
+ {
78
+ if ( e . LeftButton != MouseButtonState . Pressed )
79
+ {
80
+ start = default ;
81
+ path = string . Empty ;
82
+ query = string . Empty ;
83
+ return ;
84
+ }
85
+
86
+ if ( ! File . Exists ( path ) && ! Directory . Exists ( path ) )
87
+ return ;
88
+
89
+ Point mousePosition = e . GetPosition ( null ) ;
90
+ Vector diff = this . start - mousePosition ;
91
+
92
+ if ( Math . Abs ( diff . X ) < SystemParameters . MinimumHorizontalDragDistance
93
+ || Math . Abs ( diff . Y ) < SystemParameters . MinimumVerticalDragDistance )
94
+ return ;
95
+
96
+ var data = new DataObject ( DataFormats . FileDrop , new [ ]
97
+ {
98
+ path
99
+ } ) ;
100
+ DragDrop . DoDragDrop ( ( DependencyObject ) sender , data , DragDropEffects . Move | DragDropEffects . Copy ) ;
101
+
102
+ App . API . ChangeQuery ( query , true ) ;
103
+
104
+ e . Handled = true ;
105
+ }
57
106
}
58
107
}
0 commit comments