diff --git a/src/MaaWpfGui/Helper/ToastNotification.cs b/src/MaaWpfGui/Helper/ToastNotification.cs index c615c87f3a..09855a8136 100644 --- a/src/MaaWpfGui/Helper/ToastNotification.cs +++ b/src/MaaWpfGui/Helper/ToastNotification.cs @@ -33,6 +33,8 @@ using Notification.Wpf.Controls; using Semver; using Serilog; using Stylet; +using Windows.Data.Xml.Dom; +using Windows.UI.Notifications; using Application = System.Windows.Forms.Application; using FontFamily = System.Windows.Media.FontFamily; @@ -414,20 +416,28 @@ namespace MaaWpfGui.Helper if (_buttonSystemEnabled) { Uri burl = new Uri(ButtonSystemUrl); - new ToastContentBuilder() + var toastContent = new ToastContentBuilder() .AddText(_notificationTitle) .AddText(_contentCollection.ToString()) .AddButton(new ToastButton() .SetContent(_buttonSystemText) .SetProtocolActivation(burl)) - .Show(); + .GetToastContent(); + var toastXmlDoc = new XmlDocument(); + toastXmlDoc.LoadXml(toastContent.GetContent()); + var toastNotification = new Windows.UI.Notifications.ToastNotification(toastXmlDoc); + ToastNotificationManager.CreateToastNotifier().Show(toastNotification); } else { - new ToastContentBuilder() + var toastContent = new ToastContentBuilder() .AddText(_notificationTitle) .AddText(_contentCollection.ToString()) - .Show(); + .GetToastContent(); + var toastXmlDoc = new XmlDocument(); + toastXmlDoc.LoadXml(toastContent.GetContent()); + var toastNotification = new Windows.UI.Notifications.ToastNotification(toastXmlDoc); + ToastNotificationManager.CreateToastNotifier().Show(toastNotification); } }); diff --git a/src/MaaWpfGui/MaaWpfGui.csproj b/src/MaaWpfGui/MaaWpfGui.csproj index a588e3d72b..a1162321bf 100644 --- a/src/MaaWpfGui/MaaWpfGui.csproj +++ b/src/MaaWpfGui/MaaWpfGui.csproj @@ -7,7 +7,7 @@ WinExe MaaWpfGui MAA - net48 + net8.0-windows net481 x64;ARM64 Release;RelWithDebInfo;Debug @@ -100,7 +100,7 @@ 1.1.0 - 3.1.1 + 3.2.1 3.4.5 @@ -109,13 +109,13 @@ - 7.1.2 + 7.1.3 13.0.1 - 6.1.0.5 + 7.0.0.2 1.1.3 @@ -125,10 +125,10 @@ All - 2.2.0 + 2.3.0 - 2.12.0 + 3.0.1 3.1.0 @@ -147,16 +147,14 @@ 1.3.6 - + + + + + + - - 7.0.2 - - - - - - + diff --git a/src/MaaWpfGui/Main/Bootstrapper.cs b/src/MaaWpfGui/Main/Bootstrapper.cs index be62a6f314..ff03c6211e 100644 --- a/src/MaaWpfGui/Main/Bootstrapper.cs +++ b/src/MaaWpfGui/Main/Bootstrapper.cs @@ -28,11 +28,11 @@ using MaaWpfGui.Services.RemoteControl; using MaaWpfGui.Services.Web; using MaaWpfGui.ViewModels.UI; using MaaWpfGui.Views.UI; -using Microsoft.Toolkit.Uwp.Notifications; using Serilog; using Serilog.Core; using Stylet; using StyletIoC; +using Windows.UI.Notifications; namespace MaaWpfGui.Main { @@ -227,7 +227,7 @@ namespace MaaWpfGui.Main var os = RuntimeInformation.OSDescription; if (string.Compare(os, "Microsoft Windows 10.0.10240", StringComparison.Ordinal) >= 0) { - ToastNotificationManagerCompat.History.Clear(); + new ToastNotificationHistory().Clear(); } // 注销任务栏图标 diff --git a/src/MaaWpfGui/Services/TrayIcon.cs b/src/MaaWpfGui/Services/TrayIcon.cs index 893b6c9abf..e82b295bda 100644 --- a/src/MaaWpfGui/Services/TrayIcon.cs +++ b/src/MaaWpfGui/Services/TrayIcon.cs @@ -44,12 +44,12 @@ namespace MaaWpfGui.Services _notifyIcon.MouseClick += NotifyIcon_MouseClick; _notifyIcon.MouseDoubleClick += OnNotifyIconDoubleClick; - MenuItem startMenu = new MenuItem(LocalizationHelper.GetString("Farming")); + ToolStripMenuItem startMenu = new ToolStripMenuItem (LocalizationHelper.GetString("Farming")); startMenu.Click += StartTask; - MenuItem stopMenu = new MenuItem(LocalizationHelper.GetString("Stop")); + ToolStripMenuItem stopMenu = new ToolStripMenuItem(LocalizationHelper.GetString("Stop")); stopMenu.Click += StopTask; - MenuItem switchLangMenu = new MenuItem(LocalizationHelper.GetString("SwitchLanguage")); + ToolStripMenuItem switchLangMenu = new ToolStripMenuItem(LocalizationHelper.GetString("SwitchLanguage")); foreach (var lang in LocalizationHelper.SupportedLanguages) { @@ -58,21 +58,28 @@ namespace MaaWpfGui.Services continue; } - var langMenu = new MenuItem(lang.Value); + var langMenu = new ToolStripMenuItem(lang.Value); langMenu.Click += (sender, e) => { Instances.SettingsViewModel.Language = lang.Key; }; - switchLangMenu.MenuItems.Add(langMenu); + switchLangMenu.DropDownItems.Add(langMenu); } - MenuItem forceShowMenu = new MenuItem(LocalizationHelper.GetString("ForceShow")); + ToolStripMenuItem forceShowMenu = new ToolStripMenuItem(LocalizationHelper.GetString("ForceShow")); forceShowMenu.Click += ForceShow; - MenuItem exitMenu = new MenuItem(LocalizationHelper.GetString("Exit")); + ToolStripMenuItem exitMenu = new ToolStripMenuItem(LocalizationHelper.GetString("Exit")); exitMenu.Click += AppExit; - MenuItem[] menuItems = { startMenu, stopMenu, switchLangMenu, forceShowMenu, exitMenu }; - this._notifyIcon.ContextMenu = new ContextMenu(menuItems); + + ToolStripMenuItem[] menuItems = new ToolStripMenuItem[] { startMenu, stopMenu, switchLangMenu, forceShowMenu, exitMenu }; + var contextMenuStrip = new ContextMenuStrip(); + foreach (var item in menuItems) + { + contextMenuStrip.Items.Add(item); + } + + this._notifyIcon.ContextMenuStrip = contextMenuStrip; } private static void NotifyIcon_MouseClick(object sender, MouseEventArgs e)