implement native notifications
This commit is contained in:
parent
b8ec8ab7b3
commit
88e7610a46
6 changed files with 33 additions and 14 deletions
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using Microsoft.Toolkit.Uwp.Notifications;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
|
@ -6,6 +7,7 @@ using System.Diagnostics;
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using Windows.Foundation.Collections;
|
||||
|
||||
namespace EnvyUpdate
|
||||
{
|
||||
|
@ -14,5 +16,23 @@ namespace EnvyUpdate
|
|||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
protected override void OnStartup(StartupEventArgs e)
|
||||
{
|
||||
// Listen to notification activation
|
||||
ToastNotificationManagerCompat.OnActivated += toastArgs =>
|
||||
{
|
||||
// Obtain the arguments from the notification
|
||||
ToastArguments args = ToastArguments.Parse(toastArgs.Argument);
|
||||
|
||||
// Obtain any user input (text boxes, menu selections) from the notification
|
||||
ValueSet userInput = toastArgs.UserInput;
|
||||
|
||||
// Need to dispatch to UI thread if performing UI operations
|
||||
Application.Current.Dispatcher.Invoke(delegate
|
||||
{
|
||||
Util.ShowMain();
|
||||
});
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using Microsoft.Toolkit.Uwp.Notifications;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
@ -295,7 +296,10 @@ namespace EnvyUpdate
|
|||
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
if (MessageBox.Show(Properties.Resources.exit_confirm, "", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
|
||||
{
|
||||
ToastNotificationManagerCompat.Uninstall();
|
||||
Application.Current.Shutdown();
|
||||
}
|
||||
else
|
||||
e.Cancel = true;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using Notifications.Wpf;
|
||||
using Microsoft.Toolkit.Uwp.Notifications;
|
||||
|
||||
namespace EnvyUpdate
|
||||
{
|
||||
|
@ -6,14 +6,9 @@ namespace EnvyUpdate
|
|||
{
|
||||
public static void ShowDrivUpdatePopup()
|
||||
{
|
||||
var notificationManager = new NotificationManager();
|
||||
|
||||
notificationManager.Show(new NotificationContent
|
||||
{
|
||||
Title = "EnvyUpdate",
|
||||
Message = Properties.Resources.update_popup_message,
|
||||
Type = NotificationType.Information
|
||||
}, onClick: Util.ShowMain);
|
||||
var toast = new ToastContentBuilder();
|
||||
toast.AddText(Properties.Resources.update_popup_message);
|
||||
toast.Show();
|
||||
}
|
||||
}
|
||||
}
|
2
EnvyUpdate/Properties/Resources.Designer.cs
generated
2
EnvyUpdate/Properties/Resources.Designer.cs
generated
|
@ -250,7 +250,7 @@ namespace EnvyUpdate.Properties {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to A new driver update is available for your graphics card. Click for more info..
|
||||
/// Looks up a localized string similar to A new driver update is available for your graphics card..
|
||||
/// </summary>
|
||||
public static string update_popup_message {
|
||||
get {
|
||||
|
|
|
@ -181,6 +181,6 @@
|
|||
<value>Aufgrund eines Programmfehlers musste EnvyUpdate deinstalliert werden. Bitte laden Sie die neuste Version erneut manuell herunter.</value>
|
||||
</data>
|
||||
<data name="update_popup_message" xml:space="preserve">
|
||||
<value>Eine neue Treiberversion ist verfügbar. Hier klicken für mehr Info.</value>
|
||||
<value>Eine neue Treiberversion ist verfügbar.</value>
|
||||
</data>
|
||||
</root>
|
|
@ -181,6 +181,6 @@
|
|||
<value>EnvyUpdate must be uninstalled because of an application bug. Please download the most recent version again.</value>
|
||||
</data>
|
||||
<data name="update_popup_message" xml:space="preserve">
|
||||
<value>A new driver update is available for your graphics card. Click for more info.</value>
|
||||
<value>A new driver update is available for your graphics card.</value>
|
||||
</data>
|
||||
</root>
|
Reference in a new issue