add:有更新时系统级弹窗

This commit is contained in:
2025-12-20 19:16:39 +08:00
parent ddfa9c2676
commit b6368fb0e4
4 changed files with 77 additions and 0 deletions
+11
View File
@@ -59,8 +59,19 @@ namespace Ink_Canvas
private static SplashScreen _splashScreen;
private static bool _isSplashScreenShown = false;
[DllImport("shell32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
private static extern int SetCurrentProcessExplicitAppUserModelID(string appId);
public App()
{
try
{
SetCurrentProcessExplicitAppUserModelID("InkCanvasForClass.CE");
}
catch
{
}
// 配置TLS协议以支持Windows 7
ConfigureTlsForWindows7();
@@ -0,0 +1,62 @@
using Hardcodet.Wpf.TaskbarNotification;
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.ShowBalloonTip(
"InkCanvasForClass CE",
$"有新版本:{version}",
BalloonIcon.Info);
}
catch
{
}
});
}
private static void ShowToastForModernWindows(string version)
{
new ToastContentBuilder()
.AddText("InkCanvasForClass CE")
.AddText($"有新版本:{version}")
.Show();
}
}
}
+1
View File
@@ -153,6 +153,7 @@
<PackageReference Include="MdXaml" Version="1.27.0" />
<PackageReference Include="Microsoft.Office.Interop.PowerPoint" Version="15.0.4420.1018" />
<PackageReference Include="MicrosoftOfficeCore" Version="15.0.0" />
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.3" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
+3
View File
@@ -1011,6 +1011,9 @@ namespace Ink_Canvas
// 检测到新版本
LogHelper.WriteLogToFile($"AutoUpdate | New version available: {AvailableLatestVersion}");
// 通过 Windows 系统通知提示有新版本
WindowsNotificationHelper.ShowNewVersionToast(AvailableLatestVersion);
// 检查是否是用户选择跳过的版本
if (!string.IsNullOrEmpty(Settings.Startup.SkippedVersion) &&
Settings.Startup.SkippedVersion == AvailableLatestVersion)