Saku-Overclock
48 строк · 2.0 Кб
1using Microsoft.UI.Dispatching;2using Microsoft.UI.Xaml;3using Microsoft.Windows.AppLifecycle;4using Saku_Overclock.Contracts.Services;5
6namespace Saku_Overclock.Activation;7
8public class AppNotificationActivationHandler : ActivationHandler<LaunchActivatedEventArgs>9{
10private readonly INavigationService _navigationService;11private readonly IAppNotificationService _notificationService;12
13public AppNotificationActivationHandler(INavigationService navigationService, IAppNotificationService notificationService)14{15_navigationService = navigationService;16_notificationService = notificationService;17}18
19protected override bool CanHandleInternal(LaunchActivatedEventArgs args)20{21return AppInstance.GetCurrent().GetActivatedEventArgs()?.Kind == ExtendedActivationKind.AppNotification;22}23
24protected async override Task HandleInternalAsync(LaunchActivatedEventArgs args)25{26// TODO: Handle notification activations.27
28//// // Access the AppNotificationActivatedEventArgs.29//// var activatedEventArgs = (AppNotificationActivatedEventArgs)AppInstance.GetCurrent().GetActivatedEventArgs().Data;30
31//// // Navigate to a specific page based on the notification arguments.32//// if (_notificationService.ParseArguments(activatedEventArgs.Argument)["action"] == "Settings")33//// {34//// // Queue navigation with low priority to allow the UI to initialize.35//// App.MainWindow.DispatcherQueue.TryEnqueue(DispatcherQueuePriority.Low, () =>36//// {37//// _navigationService.NavigateTo(typeof(SettingsViewModel).FullName!);38//// });39//// }40
41App.MainWindow.DispatcherQueue.TryEnqueue(DispatcherQueuePriority.Low, () =>42{43App.MainWindow.ShowMessageDialogAsync("TODO: Handle notification activations.", "Notification Activation");44});45
46await Task.CompletedTask;47}48}
49