11
11
using Path = System . IO . Path ;
12
12
using System . Windows . Controls ;
13
13
using Flow . Launcher . Plugin . Explorer . Views ;
14
+ using Peter ;
14
15
15
16
namespace Flow . Launcher . Plugin . Explorer . Search
16
17
{
@@ -70,6 +71,27 @@ public static Result CreateResult(Query query, SearchResult result)
70
71
} ;
71
72
}
72
73
74
+ internal static void ShowNativeContextMenu ( string path , ResultType type )
75
+ {
76
+ var screenWithMouseCursor = System . Windows . Forms . Screen . FromPoint ( System . Windows . Forms . Cursor . Position ) ;
77
+ var xOfScreenCenter = screenWithMouseCursor . WorkingArea . Left + screenWithMouseCursor . WorkingArea . Width / 2 ;
78
+ var yOfScreenCenter = screenWithMouseCursor . WorkingArea . Top + screenWithMouseCursor . WorkingArea . Height / 2 ;
79
+ var showPosition = new System . Drawing . Point ( xOfScreenCenter , yOfScreenCenter ) ;
80
+
81
+ switch ( type )
82
+ {
83
+ case ResultType . File :
84
+ var fileInfo = new FileInfo [ ] { new ( path ) } ;
85
+ new ShellContextMenu ( ) . ShowContextMenu ( fileInfo , showPosition ) ;
86
+ break ;
87
+
88
+ case ResultType . Folder :
89
+ var folderInfo = new System . IO . DirectoryInfo [ ] { new ( path ) } ;
90
+ new ShellContextMenu ( ) . ShowContextMenu ( folderInfo , showPosition ) ;
91
+ break ;
92
+ }
93
+ }
94
+
73
95
internal static Result CreateFolderResult ( string title , string subtitle , string path , Query query , int score = 0 , bool windowsIndexed = false )
74
96
{
75
97
return new Result
@@ -82,6 +104,11 @@ internal static Result CreateFolderResult(string title, string subtitle, string
82
104
CopyText = path ,
83
105
Action = c =>
84
106
{
107
+ if ( c . SpecialKeyState . ToModifierKeys ( ) == ModifierKeys . Alt )
108
+ {
109
+ ShowNativeContextMenu ( path , ResultType . Folder ) ;
110
+ return false ;
111
+ }
85
112
// open folder
86
113
if ( c . SpecialKeyState . ToModifierKeys ( ) == ( ModifierKeys . Control | ModifierKeys . Shift ) )
87
114
{
@@ -218,8 +245,13 @@ internal static Result CreateOpenCurrentFolderResult(string path, string actionK
218
245
IcoPath = folderPath ,
219
246
Score = 500 ,
220
247
CopyText = folderPath ,
221
- Action = _ =>
248
+ Action = c =>
222
249
{
250
+ if ( c . SpecialKeyState . ToModifierKeys ( ) == ModifierKeys . Alt )
251
+ {
252
+ ShowNativeContextMenu ( folderPath , ResultType . Folder ) ;
253
+ return false ;
254
+ }
223
255
OpenFolder ( folderPath ) ;
224
256
return true ;
225
257
} ,
@@ -251,6 +283,11 @@ internal static Result CreateFileResult(string filePath, Query query, int score
251
283
PreviewPanel = new Lazy < UserControl > ( ( ) => new PreviewPanel ( Settings , filePath ) ) ,
252
284
Action = c =>
253
285
{
286
+ if ( c . SpecialKeyState . ToModifierKeys ( ) == ModifierKeys . Alt )
287
+ {
288
+ ShowNativeContextMenu ( filePath , ResultType . File ) ;
289
+ return false ;
290
+ }
254
291
try
255
292
{
256
293
if ( c . SpecialKeyState . ToModifierKeys ( ) == ( ModifierKeys . Control | ModifierKeys . Shift ) )
0 commit comments