add:有更新时系统级弹窗
This commit is contained in:
@@ -59,8 +59,19 @@ namespace Ink_Canvas
|
|||||||
private static SplashScreen _splashScreen;
|
private static SplashScreen _splashScreen;
|
||||||
private static bool _isSplashScreenShown = false;
|
private static bool _isSplashScreenShown = false;
|
||||||
|
|
||||||
|
[DllImport("shell32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
|
||||||
|
private static extern int SetCurrentProcessExplicitAppUserModelID(string appId);
|
||||||
|
|
||||||
public App()
|
public App()
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
SetCurrentProcessExplicitAppUserModelID("InkCanvasForClass.CE");
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
// 配置TLS协议以支持Windows 7
|
// 配置TLS协议以支持Windows 7
|
||||||
ConfigureTlsForWindows7();
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -153,6 +153,7 @@
|
|||||||
<PackageReference Include="MdXaml" Version="1.27.0" />
|
<PackageReference Include="MdXaml" Version="1.27.0" />
|
||||||
<PackageReference Include="Microsoft.Office.Interop.PowerPoint" Version="15.0.4420.1018" />
|
<PackageReference Include="Microsoft.Office.Interop.PowerPoint" Version="15.0.4420.1018" />
|
||||||
<PackageReference Include="MicrosoftOfficeCore" Version="15.0.0" />
|
<PackageReference Include="MicrosoftOfficeCore" Version="15.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
|
|||||||
@@ -1011,6 +1011,9 @@ namespace Ink_Canvas
|
|||||||
// 检测到新版本
|
// 检测到新版本
|
||||||
LogHelper.WriteLogToFile($"AutoUpdate | New version available: {AvailableLatestVersion}");
|
LogHelper.WriteLogToFile($"AutoUpdate | New version available: {AvailableLatestVersion}");
|
||||||
|
|
||||||
|
// 通过 Windows 系统通知提示有新版本
|
||||||
|
WindowsNotificationHelper.ShowNewVersionToast(AvailableLatestVersion);
|
||||||
|
|
||||||
// 检查是否是用户选择跳过的版本
|
// 检查是否是用户选择跳过的版本
|
||||||
if (!string.IsNullOrEmpty(Settings.Startup.SkippedVersion) &&
|
if (!string.IsNullOrEmpty(Settings.Startup.SkippedVersion) &&
|
||||||
Settings.Startup.SkippedVersion == AvailableLatestVersion)
|
Settings.Startup.SkippedVersion == AvailableLatestVersion)
|
||||||
|
|||||||
Reference in New Issue
Block a user