Bläddra i källkod

综合-补充软件更新模块、限制tabcontrol响应

ZhouJieSheng 1 år sedan
förälder
incheckning
b34d52752a

+ 73 - 8
PDF Office/App.xaml.cs

@@ -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);

+ 14 - 0
PDF Office/PDF Master.csproj

@@ -193,6 +193,14 @@
     <Reference Include="Microsoft.Xaml.Behaviors, Version=1.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
       <HintPath>packages\Microsoft.Xaml.Behaviors.Wpf.1.1.31\lib\net45\Microsoft.Xaml.Behaviors.dll</HintPath>
     </Reference>
+    <Reference Include="NetSparkle, Version=2.0.8.0, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>Updater\NetSparkle.dll</HintPath>
+    </Reference>
+    <Reference Include="NetSparkleUpdater.UI.WinForms, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>Updater\NetSparkleUpdater.UI.WinForms.dll</HintPath>
+    </Reference>
     <Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
       <HintPath>packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
     </Reference>
@@ -2529,6 +2537,12 @@
     <Content Include="SystemService\ThumbnailProviderx86.dll">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </Content>
+    <Content Include="Updater\en-US\NetSparkleUpdater.UI.WinForms.resources.dll" />
+    <Content Include="Updater\NetSparkle.dll" />
+    <Resource Include="Updater\NetSparkle.xml" />
+    <Content Include="Updater\NetSparkleUpdater.UI.WinForms.dll" />
+    <Content Include="Updater\zh-CN\NetSparkleUpdater.UI.WinForms.resources.dll" />
+    <Content Include="Updater\zh-TW\NetSparkleUpdater.UI.WinForms.resources.dll" />
     <Content Include="x64\ComPDFKit.dll">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </Content>

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 2911 - 0
PDF Office/Updater/NetSparkle.xml


+ 3 - 0
PDF Office/Views/ViewContent.xaml

@@ -299,6 +299,7 @@
                                 InputGestureText="Ctrl+P" />
                             <Separator Margin="8,0" Style="{StaticResource HorizontalSeparatorStyle}" />
                             <MenuItem Command="{Binding SettingsCommand}" Header="Settings" />
+                            <MenuItem Header="Check Update" Click="MenuItem_Click"/>
                             <MenuItem Header="Help">
                                 <MenuItem
                                     Command="{Binding HelpCommand}"
@@ -457,6 +458,8 @@
                     HorizontalAlignment="Center"
                     VerticalAlignment="Top"
                     BorderThickness="0"
+                    FocusVisualStyle="{x:Null}"
+                    Keyboard.PreviewKeyDown="ToolTabControl_PreviewKeyDown"
                     PreviewMouseLeftButtonDown="ToolTabControl_PreviewMouseLeftButtonDown"
                     SelectedIndex="{Binding TabSelectedIndex, Mode=TwoWay}"
                     Style="{StaticResource TabControlWithUnderLineStyle}"

+ 16 - 0
PDF Office/Views/ViewContent.xaml.cs

@@ -547,5 +547,21 @@ namespace PDF_Master.Views
             this.Focusable = true;
             this.Focus();
         }
+
+        private void ToolTabControl_PreviewKeyDown(object sender, KeyEventArgs e)
+        {
+            //禁用控件的左右按键,避免和左右翻页快捷键冲突
+            if(e.Key== Key.Left||e.Key==Key.Right||e.Key==Key.Tab)
+            {
+                e.Handled = true;
+            }
+        }
+
+        private void MenuItem_Click(object sender, RoutedEventArgs e)
+        {
+            //检查更新
+            if (App.SparkleUpdateDetector != null)
+                App.SparkleUpdateDetector?.CheckForUpdatesAtUserRequest();
+        }
     }
 }

+ 26 - 0
UpdateXML/pdfmaster_win_en_Us.xml

@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle"  xmlns:dc="http://purl.org/dc/elements/1.1/">
+  <channel>
+    <title>PDF Reader Pro's Changelog</title>
+    <link> https://www.pdfreaderpro.com/downloads/pdfreaderprocast_win.xml</link>
+    <description>Most recent changes with links to updates.</description>
+    <language>en</language>
+      <item>
+        <title>Version 1.1.0</title>
+        <description>
+            <![CDATA[
+          <ul>
+            <head>PDF Reader Pro gets a new update! Discover a fast and easy way to convert PDF to Office!</head>
+            <br></br>
+              <li>Upgrade PDF Converter: Convert PDFs to Microsoft Word (.docx), PowerPoint (.pptx), Excel (.xlsx), Text, Image and more Offline;</li>
+                <li>Tiny bug fixed and performance optimization for user experience.</li>
+            <br></br>
+            <head>Have any questions or feedback? Please feel free to contact us at support@pdfreaderpro.com.</head>
+            </ul>
+            ]]>
+        </description>
+       <pubDate>Thur, 20 Dec 2022 00:00:00 +0000</pubDate>
+        <enclosure url="http://test-pdf-pro.kdan.cn:3021/downloads/PDFMaster.exe" sparkle:version="1.1.0.0" />
+      </item>
+  </channel>
+</rss>

+ 26 - 0
UpdateXML/pdfmaster_win_zh_Hans.xml

@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle"  xmlns:dc="http://purl.org/dc/elements/1.1/">
+  <channel>
+    <title>PDF Reader Pro's Changelog</title>
+    <link> https://www.pdfreaderpro.com/downloads/pdfreaderprocast_win.xml</link>
+    <description>Most recent changes with links to updates.</description>
+    <language>en</language>
+           <item>
+        <title>Version 1.1.0.0</title>
+        <description>
+            <![CDATA[
+           <ul>
+            <head>PDF Reader Pro 新版本发布!利用升级的转档工具快速将PDF转换成Office文档!</head>
+            <br></br>
+              <li>优化PDF转档器:快速将您的PDF文件转换为Microsoft Word (.docx)、Excel (.xlsx)、PowerPoint (.pptx)、图片和文本等;</li>
+                <li>已知问题修复,性能优化,提高用户体验。</li>
+            <br></br>
+            <head>有任何反馈,意见或是建议,请随时与我们联系:support@pdfreaderpro.com</head>
+            </ul>
+            ]]>
+        </description>
+       <pubDate>Thur, 20 Dec 2022 00:00:00 +0000</pubDate>
+     <enclosure url="http://test-pdf-pro.kdan.cn:3021/downloads/PDFMaster.exe" sparkle:version="1.1.0.0" />
+      </item>
+  </channel>
+</rss>

+ 26 - 0
UpdateXML/pdfmaster_win_zh_Hant.xml

@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle"  xmlns:dc="http://purl.org/dc/elements/1.1/">
+  <channel>
+    <title>PDF Reader Pro's Changelog</title>
+    <link> https://www.pdfreaderpro.com/downloads/pdfreaderprocast_win.xml</link>
+    <description>Most recent changes with links to updates.</description>
+    <language>en</language>
+          <item>
+        <title>Version 1.1.0.0</title>
+        <description>
+            <![CDATA[
+           <ul>
+            <head>PDF Reader Pro新版發佈!利用升級的轉檔工具快速將PDF轉換成Office文檔!</head>
+            <br></br>
+                <li>優化PDF轉檔器:快速將您的PDF文檔轉換為Microsoft Word (.docx)、Excel (.xlsx)、PowerPoint (.pptx)、圖片和文本等;</li>
+                <li>已知問題修復,優化性能,提高用戶體驗感。</li>
+            <br></br>
+            <head>有任何反饋,意見或是建議,請隨時與我們聯繫:support@pdfreaderpro.com</head>
+            </ul>
+            ]]>
+        </description>
+       <pubDate>Thur, 20 Dec 2022 00:00:00 +0000</pubDate>
+     <enclosure url="http://test-pdf-pro.kdan.cn:3021/downloads/PDFMaster.exe" sparkle:version="1.1.0.0" />
+      </item>
+  </channel>
+</rss>