@@ -596,10 +596,10 @@ public void PathBoxItem_PointerPressed(object sender, PointerRoutedEventArgs e)
596596 _pointerRoutedEventArgs = ptrPt . Properties . IsMiddleButtonPressed ? e : null ;
597597 }
598598
599- public async Task HandleFolderNavigationAsync ( string path , bool ? isMiddleButtonPressed = null )
599+ public async Task HandleFolderNavigationAsync ( string path , bool openNewTab = false )
600600 {
601- isMiddleButtonPressed ?? = _pointerRoutedEventArgs is not null ;
602- if ( isMiddleButtonPressed is true )
601+ openNewTab | = _pointerRoutedEventArgs is not null ;
602+ if ( openNewTab )
603603 {
604604 await MainWindow . Instance . DispatcherQueue . EnqueueOrInvokeAsync (
605605 async ( ) =>
@@ -616,6 +616,106 @@ await MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(
616616 ToolbarPathItemInvoked ? . Invoke ( this , new ( ) { ItemPath = path } ) ;
617617 }
618618
619+ public async Task HandleItemNavigationAsync ( string path )
620+ {
621+ if ( ContentPageContext . ShellPage is null || PathComponents . LastOrDefault ( ) ? . Path is not { } currentPath )
622+ return ;
623+
624+ var isFtp = FtpHelpers . IsFtpPath ( path ) ;
625+ var normalizedInput = NormalizePathInput ( path , isFtp ) ;
626+ if ( currentPath . Equals ( normalizedInput , StringComparison . OrdinalIgnoreCase ) ||
627+ string . IsNullOrWhiteSpace ( normalizedInput ) )
628+ return ;
629+
630+ if ( normalizedInput . Equals ( ContentPageContext . ShellPage . ShellViewModel . WorkingDirectory ) &&
631+ ContentPageContext . ShellPage . CurrentPageType != typeof ( HomePage ) )
632+ return ;
633+
634+ if ( normalizedInput . Equals ( "Home" , StringComparison . OrdinalIgnoreCase ) ||
635+ normalizedInput . Equals ( Strings . Home . GetLocalizedResource ( ) , StringComparison . OrdinalIgnoreCase ) )
636+ {
637+ SavePathToHistory ( "Home" ) ;
638+ ContentPageContext . ShellPage . NavigateHome ( ) ;
639+ }
640+ else if ( normalizedInput . Equals ( "ReleaseNotes" , StringComparison . OrdinalIgnoreCase ) ||
641+ normalizedInput . Equals ( Strings . ReleaseNotes . GetLocalizedResource ( ) , StringComparison . OrdinalIgnoreCase ) )
642+ {
643+ SavePathToHistory ( "ReleaseNotes" ) ;
644+ ContentPageContext . ShellPage . NavigateToReleaseNotes ( ) ;
645+ }
646+ else if ( normalizedInput . Equals ( "Settings" , StringComparison . OrdinalIgnoreCase ) ||
647+ normalizedInput . Equals ( Strings . Settings . GetLocalizedResource ( ) , StringComparison . OrdinalIgnoreCase ) )
648+ {
649+ //SavePathToHistory("Settings");
650+ //ContentPageContext.ShellPage.NavigateToSettings();
651+ }
652+ else
653+ {
654+ normalizedInput = StorageFileExtensions . GetResolvedPath ( normalizedInput , isFtp ) ;
655+ if ( currentPath . Equals ( normalizedInput , StringComparison . OrdinalIgnoreCase ) )
656+ return ;
657+
658+ var item = await FilesystemTasks . Wrap ( ( ) => DriveHelpers . GetRootFromPathAsync ( normalizedInput ) ) ;
659+
660+ var resFolder = await FilesystemTasks . Wrap ( ( ) => StorageFileExtensions . DangerousGetFolderWithPathFromPathAsync ( normalizedInput , item ) ) ;
661+ if ( resFolder || FolderHelpers . CheckFolderAccessWithWin32 ( normalizedInput ) )
662+ {
663+ var matchingDrive = drivesViewModel . Drives . Cast < DriveItem > ( ) . FirstOrDefault ( x => PathNormalization . NormalizePath ( normalizedInput ) . StartsWith ( PathNormalization . NormalizePath ( x . Path ) , StringComparison . Ordinal ) ) ;
664+ if ( matchingDrive is not null && matchingDrive . Type == Data . Items . DriveType . CDRom && matchingDrive . MaxSpace == ByteSizeLib . ByteSize . FromBytes ( 0 ) )
665+ {
666+ bool ejectButton = await DialogDisplayHelper . ShowDialogAsync ( Strings . InsertDiscDialog_Title . GetLocalizedResource ( ) , string . Format ( Strings . InsertDiscDialog_Text . GetLocalizedResource ( ) , matchingDrive . Path ) , Strings . InsertDiscDialog_OpenDriveButton . GetLocalizedResource ( ) , Strings . Close . GetLocalizedResource ( ) ) ;
667+ if ( ejectButton )
668+ DriveHelpers . EjectDeviceAsync ( matchingDrive . Path ) ;
669+ return ;
670+ }
671+
672+ var pathToNavigate = resFolder . Result ? . Path ?? normalizedInput ;
673+ SavePathToHistory ( pathToNavigate ) ;
674+ ContentPageContext . ShellPage . NavigateToPath ( pathToNavigate ) ;
675+ }
676+ else if ( isFtp )
677+ {
678+ SavePathToHistory ( normalizedInput ) ;
679+ ContentPageContext . ShellPage . NavigateToPath ( normalizedInput ) ;
680+ }
681+ else // Not a folder or inaccessible
682+ {
683+ var resFile = await FilesystemTasks . Wrap ( ( ) => StorageFileExtensions . DangerousGetFileWithPathFromPathAsync ( normalizedInput , item ) ) ;
684+ if ( resFile )
685+ {
686+ var pathToInvoke = resFile . Result . Path ;
687+ await Win32Helper . InvokeWin32ComponentAsync ( pathToInvoke , ContentPageContext . ShellPage ) ;
688+ }
689+ else // Not a file or not accessible
690+ {
691+ var workingDir =
692+ string . IsNullOrEmpty ( ContentPageContext . ShellPage . ShellViewModel . WorkingDirectory ) ||
693+ ContentPageContext . ShellPage . CurrentPageType == typeof ( HomePage )
694+ ? Constants . UserEnvironmentPaths . HomePath
695+ : ContentPageContext . ShellPage . ShellViewModel . WorkingDirectory ;
696+
697+ if ( await LaunchApplicationFromPath ( OmnibarPathModeText , workingDir ) )
698+ return ;
699+
700+ try
701+ {
702+ if ( ! await Windows . System . Launcher . LaunchUriAsync ( new Uri ( OmnibarPathModeText ) ) )
703+ await DialogDisplayHelper . ShowDialogAsync ( Strings . InvalidItemDialogTitle . GetLocalizedResource ( ) ,
704+ string . Format ( Strings . InvalidItemDialogContent . GetLocalizedResource ( ) , Environment . NewLine , resFolder . ErrorCode . ToString ( ) ) ) ;
705+ }
706+ catch ( Exception ex ) when ( ex is UriFormatException || ex is ArgumentException )
707+ {
708+ await DialogDisplayHelper . ShowDialogAsync ( Strings . InvalidItemDialogTitle . GetLocalizedResource ( ) ,
709+ string . Format ( Strings . InvalidItemDialogContent . GetLocalizedResource ( ) , Environment . NewLine , resFolder . ErrorCode . ToString ( ) ) ) ;
710+ }
711+ }
712+ }
713+ }
714+
715+ PathControlDisplayText = ContentPageContext . ShellPage . ShellViewModel . WorkingDirectory ;
716+ IsOmnibarFocused = false ;
717+ }
718+
619719 public void PathBoxItem_PreviewKeyDown ( object sender , KeyRoutedEventArgs e )
620720 {
621721 switch ( e . Key )
@@ -799,6 +899,7 @@ private static string NormalizePathInput(string currentInput, bool isFtp)
799899 return currentInput ;
800900 }
801901
902+ [ Obsolete ( "Remove once Omnibar goes out of experimental." ) ]
802903 public async Task CheckPathInputAsync ( string currentInput , string currentSelectedPath , IShellPage shellPage )
803904 {
804905 if ( currentInput . StartsWith ( '>' ) )
0 commit comments