mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-17 18:01:26 +08:00
fix: 尝试显示 Toast
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -30,6 +30,7 @@ namespace MaaWpfGui.Views.UI
|
||||
{
|
||||
InitializeComponent();
|
||||
InitIcon();
|
||||
ToastNotification.ShowBalloonTip = notifyIcon.ShowBalloonTip;
|
||||
}
|
||||
|
||||
private void InitIcon()
|
||||
|
||||
Reference in New Issue
Block a user