Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 28 additions & 14 deletions src/Files.App/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,23 +160,37 @@ public async Task InitializeApplicationAsync(object activatedEventArgs)
break;

case IFileActivatedEventArgs fileArgs:
var index = 0;
if (rootFrame.Content is null || rootFrame.Content is SplashScreenPage || !MainPageViewModel.AppInstances.Any())
try
{
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation parameter
rootFrame.Navigate(typeof(MainPage), fileArgs.Files.First().Path, new SuppressNavigationTransitionInfo());
index = 1;
}
else
{
// Bring to foreground (#14730)
Win32Helper.BringToForegroundEx(new(WindowHandle));
}
if (fileArgs.Files is null || fileArgs.Files.Count == 0)
{
break;
}

var index = 0;
if (rootFrame.Content is null || rootFrame.Content is SplashScreenPage || !MainPageViewModel.AppInstances.Any())
{
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation parameter
rootFrame.Navigate(typeof(MainPage), fileArgs.Files.First().Path, new SuppressNavigationTransitionInfo());
index = 1;
}
else
{
// Bring to foreground (#14730)
Win32Helper.BringToForegroundEx(new(WindowHandle));
}

for (; index < fileArgs.Files.Count; index++)
for (; index < fileArgs.Files.Count; index++)
{
await NavigationHelpers.AddNewTabByPathAsync(typeof(ShellPanesPage), fileArgs.Files[index].Path, true);
}
}
catch (Exception ex)
{
await NavigationHelpers.AddNewTabByPathAsync(typeof(ShellPanesPage), fileArgs.Files[index].Path, true);
App.Logger.LogWarning(ex, "Failed to open files.");
if (rootFrame.Content is null || rootFrame.Content is SplashScreenPage || !MainPageViewModel.AppInstances.Any())
rootFrame.Navigate(typeof(MainPage), null, new SuppressNavigationTransitionInfo());
}
break;

Expand Down
Loading