File tree Expand file tree Collapse file tree 5 files changed +34
-4
lines changed Expand file tree Collapse file tree 5 files changed +34
-4
lines changed Original file line number Diff line number Diff line change 1+ // Copyright (c) 2024 Files Community
2+ // Licensed under the MIT License. See the LICENSE.
3+
4+ namespace Files . App . Actions
5+ {
6+ internal sealed class OpenStorageSenseFromSidebarAction : OpenStorageSenseAction
7+ {
8+ private ISidebarContext SidebarContext { get ; } = Ioc . Default . GetRequiredService < ISidebarContext > ( ) ;
9+ private readonly DrivesViewModel drivesViewModel = Ioc . Default . GetRequiredService < DrivesViewModel > ( ) ;
10+
11+ public override bool IsExecutable =>
12+ SidebarContext . IsItemRightClicked &&
13+ SidebarContext . RightClickedItem is not null &&
14+ SidebarContext . RightClickedItem . Path is not null &&
15+ drivesViewModel . Drives
16+ . Cast < DriveItem > ( )
17+ . FirstOrDefault ( x => string . Equals ( x . Path , SidebarContext . RightClickedItem . Path ) ) is DriveItem driveItem &&
18+ driveItem . Type != DriveType . Network ;
19+
20+ public override bool IsAccessibleGlobally
21+ => false ;
22+
23+ public override Task ExecuteAsync ( object ? parameter = null )
24+ {
25+ return StorageSenseHelper . OpenStorageSenseAsync ( SidebarContext ? . RightClickedItem ? . Path ?? string . Empty ) ;
26+ }
27+ }
28+ }
Original file line number Diff line number Diff line change @@ -116,6 +116,7 @@ public enum CommandCodes
116116 OpenSettings ,
117117 OpenStorageSense ,
118118 OpenStorageSenseFromHome ,
119+ OpenStorageSenseFromSidebar ,
119120 OpenTerminal ,
120121 OpenTerminalAsAdmin ,
121122 OpenTerminalFromSidebar ,
Original file line number Diff line number Diff line change @@ -118,6 +118,7 @@ public IRichCommand this[HotKey hotKey]
118118 public IRichCommand OpenClassicProperties => commands [ CommandCodes . OpenClassicProperties ] ;
119119 public IRichCommand OpenStorageSense => commands [ CommandCodes . OpenStorageSense ] ;
120120 public IRichCommand OpenStorageSenseFromHome => commands [ CommandCodes . OpenStorageSenseFromHome ] ;
121+ public IRichCommand OpenStorageSenseFromSidebar => commands [ CommandCodes . OpenStorageSenseFromSidebar ] ;
121122 public IRichCommand OpenSettings => commands [ CommandCodes . OpenSettings ] ;
122123 public IRichCommand OpenTerminal => commands [ CommandCodes . OpenTerminal ] ;
123124 public IRichCommand OpenTerminalAsAdmin => commands [ CommandCodes . OpenTerminalAsAdmin ] ;
@@ -317,6 +318,7 @@ public IEnumerator<IRichCommand> GetEnumerator() =>
317318 [ CommandCodes . OpenClassicProperties ] = new OpenClassicPropertiesAction ( ) ,
318319 [ CommandCodes . OpenStorageSense ] = new OpenStorageSenseAction ( ) ,
319320 [ CommandCodes . OpenStorageSenseFromHome ] = new OpenStorageSenseFromHomeAction ( ) ,
321+ [ CommandCodes . OpenStorageSenseFromSidebar ] = new OpenStorageSenseFromSidebarAction ( ) ,
320322 [ CommandCodes . OpenSettings ] = new OpenSettingsAction ( ) ,
321323 [ CommandCodes . OpenTerminal ] = new OpenTerminalAction ( ) ,
322324 [ CommandCodes . OpenTerminalAsAdmin ] = new OpenTerminalAsAdminAction ( ) ,
Original file line number Diff line number Diff line change @@ -104,6 +104,7 @@ public interface ICommandManager : IEnumerable<IRichCommand>
104104 IRichCommand OpenClassicProperties { get ; }
105105 IRichCommand OpenStorageSense { get ; }
106106 IRichCommand OpenStorageSenseFromHome { get ; }
107+ IRichCommand OpenStorageSenseFromSidebar { get ; }
107108 IRichCommand OpenSettings { get ; }
108109 IRichCommand OpenTerminal { get ; }
109110 IRichCommand OpenTerminalAsAdmin { get ; }
Original file line number Diff line number Diff line change 33
44using Files . App . Helpers . ContextFlyouts ;
55using Files . App . UserControls . Sidebar ;
6- using Files . App . ViewModels . Dialogs ;
76using Microsoft . UI . Input ;
87using Microsoft . UI . Xaml ;
98using Microsoft . UI . Xaml . Controls ;
1211using System . Collections . Specialized ;
1312using System . IO ;
1413using System . Windows . Input ;
15- using Windows . ApplicationModel . DataTransfer . DragDrop ;
1614using Windows . ApplicationModel . DataTransfer ;
15+ using Windows . ApplicationModel . DataTransfer . DragDrop ;
1716using Windows . Storage ;
1817using Windows . System ;
1918using Windows . UI . Core ;
20- using Files . Core . Storage ;
21- using Files . Core . Storage . Extensions ;
2219
2320namespace Files . App . ViewModels . UserControls
2421{
@@ -1063,6 +1060,7 @@ private List<ContextMenuFlyoutItemViewModel> GetLocationItemMenuItems(INavigatio
10631060 CommandParameter = menu ,
10641061 ShowItem = options . ShowProperties
10651062 } ,
1063+ new ContextMenuFlyoutItemViewModelBuilder ( Commands . OpenStorageSenseFromSidebar ) . Build ( ) ,
10661064 new ContextMenuFlyoutItemViewModel ( )
10671065 {
10681066 ItemType = ContextMenuFlyoutItemType . Separator ,
You can’t perform that action at this time.
0 commit comments