[go: nahoru, domu]

Skip to content

Commit

Permalink
Only enable prelaunch when AlwaysOpenNewWindow is set to false
Browse files Browse the repository at this point in the history
  • Loading branch information
0x7c13 committed Dec 18, 2023
1 parent 99c94ed commit b778721
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
13 changes: 13 additions & 0 deletions src/Notepads/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,19 @@ private async Task ActivateAsync(IActivatedEventArgs e)
throw;
}

try
{
if (Windows.Foundation.Metadata.ApiInformation.IsMethodPresent("Windows.ApplicationModel.Core.CoreApplication", "EnablePrelaunch"))
{
// Only enable prelaunch when AlwaysOpenNewWindow is set to false
CoreApplication.EnablePrelaunch(!AppSettingsService.AlwaysOpenNewWindow);
}
}
catch (Exception)
{
// Best efforts
}

if (rootFrameCreated)
{
ExtendViewIntoTitleBar();
Expand Down
6 changes: 0 additions & 6 deletions src/Notepads/Services/ActivationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ private static void LaunchActivated(Frame rootFrame, LaunchActivatedEventArgs la
{
LoggingService.LogInfo($"[{nameof(ActivationService)}] [LaunchActivated] Kind: {launchActivatedEventArgs.Kind}");

if (launchActivatedEventArgs.PrelaunchActivated == false)
{
// On Windows 10 version 1607 or later, this code signals that this app wants to participate in prelaunch
Windows.ApplicationModel.Core.CoreApplication.EnablePrelaunch(true);
}

if (rootFrame.Content == null)
{
rootFrame.Navigate(typeof(NotepadsMainPage), launchActivatedEventArgs.Arguments);
Expand Down

0 comments on commit b778721

Please sign in to comment.