24c6ca60a3
更新所有相关文件和引用,从 Hardcodet.Wpf.TaskbarNotification 迁移到 H.NotifyIcon 调整通知显示方式并添加 ForceCreate 调用确保图标正确显示 Signed-off-by: doudou0720 <98651603+doudou0720@users.noreply.github.com>
62 lines
1.6 KiB
C#
62 lines
1.6 KiB
C#
using H.NotifyIcon;
|
|
using Microsoft.Toolkit.Uwp.Notifications;
|
|
using System;
|
|
using System.Windows;
|
|
|
|
namespace Ink_Canvas.Helpers
|
|
{
|
|
internal static class WindowsNotificationHelper
|
|
{
|
|
private const string APP_ID = "InkCanvasForClass.CE";
|
|
|
|
public static void ShowNewVersionToast(string version)
|
|
{
|
|
try
|
|
{
|
|
var os = Environment.OSVersion.Version;
|
|
|
|
if (os.Major == 6 && os.Minor == 1)
|
|
{
|
|
ShowBalloonForWin7(version);
|
|
}
|
|
else
|
|
{
|
|
ShowToastForModernWindows(version);
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
}
|
|
|
|
private static void ShowBalloonForWin7(string version)
|
|
{
|
|
Application.Current?.Dispatcher.Invoke(() =>
|
|
{
|
|
try
|
|
{
|
|
var taskbar = Application.Current.Resources["TaskbarTrayIcon"] as TaskbarIcon;
|
|
if (taskbar == null) return;
|
|
|
|
taskbar.Visibility = Visibility.Visible;
|
|
|
|
taskbar.ShowNotification(
|
|
"InkCanvasForClass CE",
|
|
$"发现新版本!:{version}");
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
});
|
|
}
|
|
|
|
private static void ShowToastForModernWindows(string version)
|
|
{
|
|
new ToastContentBuilder()
|
|
.AddText("InkCanvasForClass CE")
|
|
.AddText($"发现新版本!:{version}")
|
|
.Show();
|
|
}
|
|
}
|
|
}
|