From 7ece0005f8d6aaca04c52dc3b16648ebdcfc8232 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=AB=E9=9B=A8?= <35213527+moomiji@users.noreply.github.com> Date: Wed, 30 Aug 2023 21:51:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=B0=9D=E8=AF=95=E6=98=BE=E7=A4=BA=20T?= =?UTF-8?q?oast?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MaaWpfGui/Helper/ToastNotification.cs | 17 +++++++++++++++++ src/MaaWpfGui/Views/UI/NotifyIcon.xaml.cs | 1 + 2 files changed, 18 insertions(+) diff --git a/src/MaaWpfGui/Helper/ToastNotification.cs b/src/MaaWpfGui/Helper/ToastNotification.cs index 09855a8136..3d3f82febb 100644 --- a/src/MaaWpfGui/Helper/ToastNotification.cs +++ b/src/MaaWpfGui/Helper/ToastNotification.cs @@ -23,7 +23,9 @@ using System.Windows; using System.Windows.Interop; using System.Windows.Media; using System.Windows.Media.Imaging; +using HandyControl.Data; using MaaWpfGui.Configuration; +using MaaWpfGui.Constants; using Microsoft.Toolkit.Uwp.Notifications; using Microsoft.Win32; using Notification.Wpf; @@ -60,6 +62,8 @@ namespace MaaWpfGui.Helper private static readonly ILogger _logger = Log.ForContext(); + public static Action ShowBalloonTip { get; set; } + /// /// Checks toast system. /// @@ -390,6 +394,15 @@ namespace MaaWpfGui.Helper #region 显示通知方法 + /// + /// 显示通知 + /// + public void Show() + { + _contentCollection.AppendLine(); // content 不能为空,否则通知发不出去 + ShowBalloonTip(_notificationTitle, _contentCollection.ToString(), NotifyIconInfoType.None); + } + /// /// 显示通知 /// @@ -402,6 +415,10 @@ namespace MaaWpfGui.Helper NotificationSounds sound = NotificationSounds.Notification, NotificationContent notificationContent = null) { + Show(); + return; + + // TODO: 整理过时代码 if (!ConfigFactory.CurrentConfig.GUI.UseNotify) { return; diff --git a/src/MaaWpfGui/Views/UI/NotifyIcon.xaml.cs b/src/MaaWpfGui/Views/UI/NotifyIcon.xaml.cs index 34e97a687c..879a7f8b1d 100644 --- a/src/MaaWpfGui/Views/UI/NotifyIcon.xaml.cs +++ b/src/MaaWpfGui/Views/UI/NotifyIcon.xaml.cs @@ -30,6 +30,7 @@ namespace MaaWpfGui.Views.UI { InitializeComponent(); InitIcon(); + ToastNotification.ShowBalloonTip = notifyIcon.ShowBalloonTip; } private void InitIcon()