fix: 尝试显示 Toast

This commit is contained in:
枫雨
2023-08-30 21:51:23 +08:00
committed by uye
parent 881125d3d4
commit 7ece0005f8
2 changed files with 18 additions and 0 deletions

View File

@@ -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<ToastNotification>();
public static Action<string, string, NotifyIconInfoType> ShowBalloonTip { get; set; }
/// <summary>
/// Checks toast system.
/// </summary>
@@ -390,6 +394,15 @@ namespace MaaWpfGui.Helper
#region
/// <summary>
/// 显示通知
/// </summary>
public void Show()
{
_contentCollection.AppendLine(); // content 不能为空,否则通知发不出去
ShowBalloonTip(_notificationTitle, _contentCollection.ToString(), NotifyIconInfoType.None);
}
/// <summary>
/// 显示通知
/// </summary>
@@ -402,6 +415,10 @@ namespace MaaWpfGui.Helper
NotificationSounds sound = NotificationSounds.Notification,
NotificationContent notificationContent = null)
{
Show();
return;
// TODO: 整理过时代码
if (!ConfigFactory.CurrentConfig.GUI.UseNotify)
{
return;

View File

@@ -30,6 +30,7 @@ namespace MaaWpfGui.Views.UI
{
InitializeComponent();
InitIcon();
ToastNotification.ShowBalloonTip = notifyIcon.ShowBalloonTip;
}
private void InitIcon()