@@ -57,8 +57,8 @@ public List<Result> Query(Query query)
5757 IcoPath = "Images\\ warning.png" ,
5858 Action = _ =>
5959 {
60- if ( FilesFolders . FileExists ( _settings . EverythingInstalledPath ) )
61- FilesFolders . OpenPath ( _settings . EverythingInstalledPath ) ;
60+ if ( _settings . EverythingInstalledPath . FileExists ( ) )
61+ _context . API . OpenDirectory ( _settings . EverythingInstalledPath ) ;
6262
6363 return true ;
6464 }
@@ -109,23 +109,25 @@ private Result CreateResult(string keyword, SearchResult searchResult)
109109 case ResultType . Folder :
110110 if ( ! _settings . LaunchHidden )
111111 {
112- Process . Start ( _settings . ExplorerPath ,
113- _settings . ExplorerArgs . Replace ( Settings . DirectoryPathPlaceHolder , $ "\" { path } \" ") ) ;
112+ _context . API . OpenDirectory ( path ) ;
114113 }
115114 else
116115 {
116+ // Launch hidden is no longer supported due to API change.
117+ // This the default behaviour kept
117118 ProcessStartInfo startInfo = new ProcessStartInfo ( ) ;
118119 //Hide the process
119120 startInfo . UseShellExecute = false ;
120121 startInfo . RedirectStandardOutput = true ;
121122 startInfo . WindowStyle = ProcessWindowStyle . Hidden ;
122123 startInfo . CreateNoWindow = true ;
123124 //Set file and args
124- startInfo . FileName = _settings . ExplorerPath ;
125- startInfo . Arguments = _settings . ExplorerArgs . Replace ( Settings . DirectoryPathPlaceHolder , $ "\" { path } \" ") ;
125+ startInfo . FileName = "explorer" ;
126+ startInfo . Arguments = $ "\" { path } \" ";
126127 //Start the process
127128 Process proc = Process . Start ( startInfo ) ;
128129 }
130+
129131 break ;
130132 case ResultType . Volume :
131133 case ResultType . File :
@@ -158,34 +160,6 @@ private Result CreateResult(string keyword, SearchResult searchResult)
158160 return r ;
159161 }
160162
161- private List < ContextMenu > GetDefaultContextMenu ( )
162- {
163- List < ContextMenu > defaultContextMenus = new List < ContextMenu > ( ) ;
164- ContextMenu openFolderContextMenu = new ContextMenu
165- {
166- Name = _context . API . GetTranslation ( "flowlauncher_plugin_everything_open_containing_folder" ) ,
167- Command = _settings . ExplorerPath ,
168- Argument = $ "{ _settings . ExplorerArgs } ",
169- ImagePath = "Images\\ folder.png"
170- } ;
171-
172- defaultContextMenus . Add ( openFolderContextMenu ) ;
173-
174- string editorPath = string . IsNullOrEmpty ( _settings . EditorPath ) ? "notepad.exe" : _settings . EditorPath ;
175-
176- ContextMenu openWithEditorContextMenu = new ContextMenu
177- {
178- Name = string . Format ( _context . API . GetTranslation ( "flowlauncher_plugin_everything_open_with_editor" ) , Path . GetFileNameWithoutExtension ( editorPath ) ) ,
179- Command = editorPath ,
180- Argument = $ " { Settings . FilePathPlaceHolder } ",
181- ImagePath = editorPath
182- } ;
183-
184- defaultContextMenus . Add ( openWithEditorContextMenu ) ;
185-
186- return defaultContextMenus ;
187- }
188-
189163 public void Init ( PluginInitContext context )
190164 {
191165 _context = context ;
@@ -279,80 +253,87 @@ public string GetTranslatedPluginDescription()
279253
280254 public List < Result > LoadContextMenus ( Result selectedResult )
281255 {
282- SearchResult record = selectedResult . ContextData as SearchResult ;
283- List < Result > contextMenus = new List < Result > ( ) ;
284- if ( record == null ) return contextMenus ;
256+ if ( selectedResult . ContextData is not SearchResult record )
257+ return new List < Result > ( ) ;
285258
286- List < ContextMenu > availableContextMenus = new List < ContextMenu > ( ) ;
287- availableContextMenus . AddRange ( GetDefaultContextMenu ( ) ) ;
288- availableContextMenus . AddRange ( _settings . ContextMenus ) ;
259+ var icoPath = record . Type == ResultType . File ? "Images\\ file.png" : "Images\\ folder.png" ;
289260
290- if ( record . Type == ResultType . File )
261+ List < Result > contextMenus = new List < Result >
291262 {
292- foreach ( ContextMenu contextMenu in availableContextMenus )
263+ new ( )
293264 {
294- var menu = contextMenu ;
295- contextMenus . Add ( new Result
265+ Title = _context . API . GetTranslation ( "flowlauncher_plugin_everything_open_containing_folder" ) ,
266+ Action = _ =>
296267 {
297- Title = contextMenu . Name ,
298- Action = _ =>
299- {
300- var parentPath = Directory . GetParent ( record . FullPath ) ;
301-
302- if ( ( menu . Argument . Trim ( ) == Settings . DirectoryPathPlaceHolder || string . IsNullOrWhiteSpace ( menu . Argument ) ) && _settings . ExplorerPath . Trim ( ) == Settings . Explorer )
303- menu . Argument = Settings . DefaultExplorerArgsWithFilePath ;
304-
305- string argument = menu . Argument . Replace ( Settings . FilePathPlaceHolder , '"' + record . FullPath + '"' )
306- . Replace ( Settings . DirectoryPathPlaceHolder , '"' + parentPath . ToString ( ) + '"' ) ;
307-
308-
309- try
310- {
311- Process . Start ( menu . Command , argument ) ;
312- }
313- catch
314- {
315- _context . API . ShowMsg ( string . Format ( _context . API . GetTranslation ( "flowlauncher_plugin_everything_canot_start" ) , record . FullPath ) , string . Empty , string . Empty ) ;
316- return false ;
317- }
318- return true ;
319- } ,
320- IcoPath = contextMenu . ImagePath
321- } ) ;
268+ _context . API . OpenDirectory ( Path . GetDirectoryName ( record . FullPath ) , record . FullPath ) ;
269+ return true ;
270+ } ,
271+ IcoPath = icoPath ,
272+ Glyph = new GlyphInfo ( "/Resources/#Segoe Fluent Icons" , "\ue8de " )
322273 }
323- }
274+ } ;
324275
325- var icoPath = ( record . Type == ResultType . File ) ? "Images\\ file.png" : "Images\\ folder.png" ;
326- contextMenus . Add ( new Result
276+ if ( record . Type is ResultType . File )
327277 {
328- Title = _context . API . GetTranslation ( "flowlauncher_plugin_everything_copy_path" ) ,
329- Action = ( context ) =>
278+ var notepadPath = string . IsNullOrEmpty ( _settings . EditorPath ) ? "notepad.exe" : _settings . EditorPath ;
279+ contextMenus . Add ( new Result
330280 {
331- Clipboard . SetDataObject ( record . FullPath ) ;
332- return true ;
333- } ,
334- IcoPath = icoPath
335- } ) ;
281+ Title = string . Format (
282+ _context . API . GetTranslation ( "flowlauncher_plugin_everything_open_with_editor" ) ,
283+ Path . GetFileNameWithoutExtension ( notepadPath )
284+ ) ,
285+ Action = state =>
286+ {
287+ using var notepad = new Process ( ) ;
288+ notepad . StartInfo = new ProcessStartInfo ( )
289+ {
290+ FileName = notepadPath ,
291+ Arguments = record . FullPath
292+ } ;
293+ if ( state . SpecialKeyState . CtrlPressed && state . SpecialKeyState . ShiftPressed )
294+ {
295+ notepad . StartInfo . Verb = "runAs" ;
296+ }
297+ Task . Run ( ( ) => notepad . Start ( ) ) ;
298+ return true ;
299+ } ,
300+ Glyph = new GlyphInfo ( "/Resources/#Segoe Fluent Icons" , "\ue932 " )
301+ } ) ;
302+ }
336303
337- contextMenus . Add ( new Result
338- {
339- Title = _context . API . GetTranslation ( "flowlauncher_plugin_everything_copy" ) ,
340- Action = ( context ) =>
304+ contextMenus . Add (
305+ new ( )
341306 {
342- Clipboard . SetFileDropList ( new System . Collections . Specialized . StringCollection
307+ Title = _context . API . GetTranslation ( "flowlauncher_plugin_everything_copy_path" ) ,
308+ Action = _ =>
343309 {
344- record . FullPath
345- } ) ;
346- return true ;
347- } ,
348- IcoPath = icoPath
349- } ) ;
310+ Clipboard . SetDataObject ( record . FullPath ) ;
311+ return true ;
312+ } ,
313+ IcoPath = icoPath ,
314+ Glyph = new GlyphInfo ( "/Resources/#Segoe Fluent Icons" , "\ue8c8 " )
315+ } ) ;
316+ contextMenus . Add (
317+ new Result
318+ {
319+ Title = _context . API . GetTranslation ( "flowlauncher_plugin_everything_copy" ) ,
320+ Action = _ =>
321+ {
322+ Clipboard . SetFileDropList ( new System . Collections . Specialized . StringCollection
323+ {
324+ record . FullPath
325+ } ) ;
326+ return true ;
327+ } ,
328+ IcoPath = icoPath ,
329+ Glyph = new GlyphInfo ( "/Resources/#Segoe Fluent Icons" , "\ue8c8 " )
330+ } ) ;
350331
351- if ( record . Type == ResultType . File || record . Type == ResultType . Folder )
332+ if ( record . Type is ResultType . File or ResultType . Folder )
352333 contextMenus . Add ( new Result
353334 {
354335 Title = _context . API . GetTranslation ( "flowlauncher_plugin_everything_delete" ) ,
355- Action = ( context ) =>
336+ Action = _ =>
356337 {
357338 try
358339 {
@@ -369,9 +350,9 @@ public List<Result> LoadContextMenus(Result selectedResult)
369350
370351 return true ;
371352 } ,
372- IcoPath = icoPath
353+ IcoPath = icoPath ,
354+ Glyph = new ( "/Resources/#Segoe Fluent Icons" , "\ue74d " )
373355 } ) ;
374-
375356 return contextMenus ;
376357 }
377358
@@ -380,4 +361,5 @@ public Control CreateSettingPanel()
380361 return new EverythingSettings ( _settings , new SettingsViewModel ( _api , _settings , _context ) ) ;
381362 }
382363 }
383- }
364+
365+ }
0 commit comments