WIn_RustTools/RustTools/Activation/DefaultActivationHandler.cs
2024-07-14 19:24:10 +08:00

30 lines
849 B
C#

using Microsoft.UI.Xaml;
using RustTools.Contracts.Services;
using RustTools.ViewModels;
namespace RustTools.Activation;
public class DefaultActivationHandler : ActivationHandler<LaunchActivatedEventArgs>
{
private readonly INavigationService _navigationService;
public DefaultActivationHandler(INavigationService navigationService)
{
_navigationService = navigationService;
}
protected override bool CanHandleInternal(LaunchActivatedEventArgs args)
{
// None of the ActivationHandlers has handled the activation.
return _navigationService.Frame?.Content == null;
}
protected async override Task HandleInternalAsync(LaunchActivatedEventArgs args)
{
_navigationService.NavigateTo(typeof(MainViewModel).FullName!, args.Arguments);
await Task.CompletedTask;
}
}