|
@@ -69,6 +69,8 @@ using System.Runtime.InteropServices;
|
|
|
using System.Security.Cryptography;
|
|
|
using System.Text;
|
|
|
using Prism.Services.Dialogs;
|
|
|
+using NetSparkleUpdater;
|
|
|
+using NetSparkleUpdater.SignatureVerifiers;
|
|
|
|
|
|
namespace PDF_Master
|
|
|
{
|
|
@@ -114,6 +116,8 @@ namespace PDF_Master
|
|
|
/// </summary>
|
|
|
public static string modelFolderPath = null;
|
|
|
|
|
|
+ public static SparkleUpdater SparkleUpdateDetector;
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 是否是软件的第一个主窗体
|
|
|
/// </summary>
|
|
@@ -282,8 +286,15 @@ namespace PDF_Master
|
|
|
}
|
|
|
|
|
|
|
|
|
+ //增加全局异常捕获
|
|
|
+ //UI线程异常
|
|
|
+ this.DispatcherUnhandledException += App_DispatcherUnhandledException;
|
|
|
+ //非UI线程异常
|
|
|
+ AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
|
|
+ //Task线程内
|
|
|
+ TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
|
|
|
|
|
|
- if(!LicenseVerify())
|
|
|
+ if (!LicenseVerify())
|
|
|
{
|
|
|
#if !DEBUG
|
|
|
//部分人员没有转档库密钥,为避免弹窗影响正常的功能开发、调试。本弹窗仅在Release模式下弹出,用于正式包
|
|
@@ -340,13 +351,7 @@ namespace PDF_Master
|
|
|
{
|
|
|
}
|
|
|
|
|
|
- //增加全局异常捕获
|
|
|
- //UI线程异常
|
|
|
- this.DispatcherUnhandledException += App_DispatcherUnhandledException;
|
|
|
- //非UI线程异常
|
|
|
- AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
|
|
- //Task线程内
|
|
|
- TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
|
|
|
+ CheckUpdate();
|
|
|
|
|
|
base.OnStartup(e);
|
|
|
}
|
|
@@ -700,6 +705,66 @@ namespace PDF_Master
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ private static void CheckUpdate()
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ string lang = "en_Us";
|
|
|
+ lang = Settings.Default.AppProperties.culture;
|
|
|
+ switch (lang)
|
|
|
+ {
|
|
|
+ case "zh-CN":
|
|
|
+ lang = "zh_Hans";
|
|
|
+ break;
|
|
|
+ case "zh-TW":
|
|
|
+ lang = "zh_Hant";
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ lang = "en_Us";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+#if DEBUG
|
|
|
+ var appcastUrl = string.Format("http://test-pdf-pro.kdan.cn:3021/downloads/pdfmaster_win_{0}.xml", lang);
|
|
|
+#else
|
|
|
+ //var appcastUrl = string.Format("http://test-pdf-pro.kdan.cn:3021/downloads/pdfmaster_win_{0}.xml", lang);
|
|
|
+ var appcastUrl = string.Format("https://www.pdfreaderpro.com/downloads/pdfmaster_win_{0}.xml",lang);
|
|
|
+#endif
|
|
|
+ // set icon in project properties!
|
|
|
+ string manifestModuleName = System.Reflection.Assembly.GetEntryAssembly().ManifestModule.FullyQualifiedName;
|
|
|
+ var icon = System.Drawing.Icon.ExtractAssociatedIcon(manifestModuleName);
|
|
|
+ //设为false 则显示立即购买按钮,设为true则不显示立即购买按钮
|
|
|
+ bool ispurchased = true;
|
|
|
+ SparkleUpdateDetector = new SparkleUpdater(appcastUrl, new DSAChecker(NetSparkleUpdater.Enums.SecurityMode.Unsafe), ispurchased)
|
|
|
+ {
|
|
|
+ UIFactory = new NetSparkleUpdater.UI.WinForms.UIFactory(icon, "PDF Master"),
|
|
|
+ //RelaunchAfterUpdate = true,
|
|
|
+ //ShowsUIOnMainThread = true,
|
|
|
+ //UseNotificationToast = true
|
|
|
+ };
|
|
|
+
|
|
|
+ SparkleUpdateDetector.SecurityProtocolType = System.Net.SecurityProtocolType.Tls12;
|
|
|
+ SparkleUpdateDetector.CloseApplication += SparkleUpdateDetector_CloseApplication;
|
|
|
+ SparkleUpdateDetector.StartLoop(true);
|
|
|
+ }
|
|
|
+ catch { }
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void SparkleUpdateDetector_CloseApplication()
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ SparkleUpdateDetector.Dispose();
|
|
|
+ Current.Dispatcher.Invoke(() =>
|
|
|
+ {
|
|
|
+ Current.Shutdown();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
protected override void OnExit(ExitEventArgs e)
|
|
|
{
|
|
|
Environment.Exit(1);
|