99using System . Windows ;
1010using System . Windows . Forms ;
1111using CommunityToolkit . Mvvm . Input ;
12+ using Flow . Launcher . Plugin . Explorer . Helper ;
1213using Flow . Launcher . Plugin . Explorer . Search ;
1314using Flow . Launcher . Plugin . Explorer . Search . Everything ;
1415using Flow . Launcher . Plugin . Explorer . Search . Everything . Exceptions ;
@@ -328,14 +329,10 @@ public void AppendLink(string containerName, AccessLink link)
328329 }
329330
330331 [ RelayCommand ]
331- private void EditLink ( object commandParameter )
332+ private void EditIndexSearchExcludePaths ( )
332333 {
333- var ( selectedLink , collection ) = commandParameter switch
334- {
335- "QuickAccessLink" => ( SelectedQuickAccessLink , Settings . QuickAccessLinks ) ,
336- "IndexSearchExcludedPaths" => ( SelectedIndexSearchExcludedPath , Settings . IndexSearchExcludedSubdirectoryPaths ) ,
337- _ => throw new ArgumentOutOfRangeException ( nameof ( commandParameter ) )
338- } ;
334+ var selectedLink = SelectedIndexSearchExcludedPath ;
335+ var collection = Settings . IndexSearchExcludedSubdirectoryPaths ;
339336
340337 if ( selectedLink is null )
341338 {
@@ -354,45 +351,66 @@ private void EditLink(object commandParameter)
354351 collection . Remove ( selectedLink ) ;
355352 collection . Add ( new AccessLink
356353 {
357- Path = path , Type = selectedLink . Type ,
354+ Path = path , Type = selectedLink . Type , Name = path . GetPathName ( )
358355 } ) ;
359- }
360-
361- private void ShowUnselectedMessage ( )
362- {
363- var warning = Context . API . GetTranslation ( "plugin_explorer_make_selection_warning" ) ;
364- Context . API . ShowMsgBox ( warning ) ;
356+ Save ( ) ;
365357 }
366358
367359 [ RelayCommand ]
368- private void AddLink ( object commandParameter )
360+ private void AddIndexSearchExcludePaths ( )
369361 {
370- var container = commandParameter switch
371- {
372- "QuickAccessLink" => Settings . QuickAccessLinks ,
373- "IndexSearchExcludedPaths" => Settings . IndexSearchExcludedSubdirectoryPaths ,
374- _ => throw new ArgumentOutOfRangeException ( nameof ( commandParameter ) )
375- } ;
376-
377- ArgumentNullException . ThrowIfNull ( container ) ;
362+ var container = Settings . IndexSearchExcludedSubdirectoryPaths ;
378363
364+ if ( container is null ) return ;
365+
379366 var folderBrowserDialog = new FolderBrowserDialog ( ) ;
380367
381368 if ( folderBrowserDialog . ShowDialog ( ) != DialogResult . OK )
382369 return ;
383370
384371 var newAccessLink = new AccessLink
385372 {
373+ Name = folderBrowserDialog . SelectedPath . GetPathName ( ) ,
386374 Path = folderBrowserDialog . SelectedPath
387375 } ;
388376
389377 container . Add ( newAccessLink ) ;
378+ Save ( ) ;
379+ }
380+
381+ [ RelayCommand ]
382+ private void EditQuickAccessLink ( )
383+ {
384+ var selectedLink = SelectedQuickAccessLink ;
385+ var collection = Settings . QuickAccessLinks ;
386+
387+ if ( selectedLink is null )
388+ {
389+ ShowUnselectedMessage ( ) ;
390+ return ;
391+ }
392+
393+ var quickAccessLinkSettings = new QuickAccessLinkSettings ( collection , SelectedQuickAccessLink ) ;
394+ if ( quickAccessLinkSettings . ShowDialog ( ) == true )
395+ {
396+ Save ( ) ;
397+ }
398+ }
399+
400+ [ RelayCommand ]
401+ private void AddQuickAccessLink ( )
402+ {
403+ var quickAccessLinkSettings = new QuickAccessLinkSettings ( Settings . QuickAccessLinks ) ;
404+ if ( quickAccessLinkSettings . ShowDialog ( ) == true )
405+ {
406+ Save ( ) ;
407+ }
390408 }
391409
392410 [ RelayCommand ]
393- private void RemoveLink ( object obj )
411+ private void RemoveLink ( object commandParameter )
394412 {
395- if ( obj is not string container ) return ;
413+ if ( commandParameter is not string container ) return ;
396414
397415 switch ( container )
398416 {
@@ -407,10 +425,16 @@ private void RemoveLink(object obj)
407425 }
408426 Save ( ) ;
409427 }
428+
429+ private void ShowUnselectedMessage ( )
430+ {
431+ var warning = Context . API . GetTranslation ( "plugin_explorer_make_selection_warning" ) ;
432+ Context . API . ShowMsgBox ( warning ) ;
433+ }
410434
411435 #endregion
412436
413- private string ? PromptUserSelectPath ( ResultType type , string ? initialDirectory = null )
437+ private static string ? PromptUserSelectPath ( ResultType type , string ? initialDirectory = null )
414438 {
415439 string ? path = null ;
416440
0 commit comments