Browse Source

转档安全检查,时钟释放安全检查

liyijie 1 year ago
parent
commit
1b709f11bc

+ 18 - 11
PDF Office/Model/Dialog/ConverterDialogs/ConverterDialogsModel.cs

@@ -8,6 +8,7 @@ using ComDocumentAIKit;
 using ComPDFKit_Conversion.Options;
 using Microsoft.Office.Interop.Word;
 using PDF_Master.Helper;
+using PDF_Master.CustomControl;
 
 namespace PDF_Master.Model.Dialog.ConverterDialogs
 {
@@ -15,7 +16,7 @@ namespace PDF_Master.Model.Dialog.ConverterDialogs
     {
         public COCRLanguage OCRLanguage = COCRLanguage.English;
         public bool IsAllowOCR = false;
-        public bool IsContainOCRBgImage =false;
+        public bool IsContainOCRBgImage = false;
         public bool IsContainAnnotations = true;
         public bool IsContainImages = true;
         public ContentOptions ContentOpts = ContentOptions.AllContent;
@@ -33,22 +34,22 @@ namespace PDF_Master.Model.Dialog.ConverterDialogs
         /// <summary>
         /// 文档地址;
         /// </summary>
-        public string InputPath="";
+        public string InputPath = "";
 
         /// <summary>
         /// 输出地址;
         /// </summary>
-        public string OutputPath="";
+        public string OutputPath = "";
 
         /// <summary>
         /// 进度;
         /// </summary>
-        public OnProgress GetProgress=null;
+        public OnProgress GetProgress = null;
 
         /// <summary>
         /// 页码 页码范围;
         /// </summary>
-        public List<int> PageIndexLists= new List<int> { };
+        public List<int> PageIndexLists = new List<int> { };
 
         /// <summary>
         /// 页面信息
@@ -58,18 +59,18 @@ namespace PDF_Master.Model.Dialog.ConverterDialogs
         /// <summary>
         /// 文档密码;
         /// </summary>
-        public string Pawssword="";
+        public string Pawssword = "";
 
         /// <summary>
         /// 文档密码;
         /// </summary>
-        public bool IsCustomFileName=true;
-               
+        public bool IsCustomFileName = true;
+
 
         /// <summary>
         /// OCR,与部分功能;
         /// </summary>
-        public ConvertOptions Options=new ConvertOptions();
+        public ConvertOptions Options = new ConvertOptions();
 
         private void ConverterClear()
         {
@@ -79,13 +80,13 @@ namespace PDF_Master.Model.Dialog.ConverterDialogs
         private void SetProgress(int pageIndex)
         {
             App.mainWindowViewModel.Value = pageIndex;
-            
+
             if (App.mainWindowViewModel.Value == App.mainWindowViewModel.MaxValue) { App.mainWindowViewModel.IsProcessVisible = System.Windows.Visibility.Collapsed; }
         }
 
         public async void OnOpened(Prism.Services.Dialogs.DialogResult e)
         {
-            if (e.Result == Prism.Services.Dialogs.ButtonResult.Cancel|| e.Result== Prism.Services.Dialogs.ButtonResult.None) { return; }
+            if (e.Result == Prism.Services.Dialogs.ButtonResult.Cancel || e.Result == Prism.Services.Dialogs.ButtonResult.None) { return; }
             bool result = false;
             string convertType = "";
             OnProgress GetProgress = null;
@@ -207,6 +208,12 @@ namespace PDF_Master.Model.Dialog.ConverterDialogs
                 default:
                     break;
             }
+            if (!result)
+            {
+                AlertsMessage alertsMessage = new AlertsMessage();
+                alertsMessage.ShowDialog("", App.MainPageLoader.GetString("Convert_FailedWarning"), App.ServiceLoader.GetString("Text_ok"));
+            }
+            App.mainWindowViewModel.IsProcessVisible = System.Windows.Visibility.Collapsed;
         }
 
     }

+ 5 - 0
PDF Office/MultilingualResources/PDF Office.en.xlf

@@ -2365,6 +2365,11 @@ Some functions may not work, please restart or re-download PDF Reader Pro from o
           <target state="new">Do you want to delete all signatures?</target>
           <note from="MultilingualBuild" annotates="source" priority="2">删除所有签名时,提示文案</note>
         </trans-unit>
+        <trans-unit id="Convert_FailedWarning" translate="yes" xml:space="preserve">
+          <source>Failed to convert files</source>
+          <target state="new">Failed to convert files</target>
+          <note from="MultilingualBuild" annotates="source" priority="2">转档失败</note>
+        </trans-unit>
       </group>
     </body>
   </file>

+ 5 - 0
PDF Office/MultilingualResources/PDF Office.zh-Hans.xlf

@@ -2365,6 +2365,11 @@ Some functions may not work, please restart or re-download PDF Reader Pro from o
           <target state="new">Do you want to delete all signatures?</target>
           <note from="MultilingualBuild" annotates="source" priority="2">删除所有签名时,提示文案</note>
         </trans-unit>
+        <trans-unit id="Convert_FailedWarning" translate="yes" xml:space="preserve">
+          <source>Failed to convert files</source>
+          <target state="new">Failed to convert files</target>
+          <note from="MultilingualBuild" annotates="source" priority="2">转档失败</note>
+        </trans-unit>
       </group>
     </body>
   </file>

+ 5 - 0
PDF Office/MultilingualResources/PDF Office.zh-Hant.xlf

@@ -2365,6 +2365,11 @@ Some functions may not work, please restart or re-download PDF Reader Pro from o
           <target state="new">Do you want to delete all signatures?</target>
           <note from="MultilingualBuild" annotates="source" priority="2">删除所有签名时,提示文案</note>
         </trans-unit>
+        <trans-unit id="Convert_FailedWarning" translate="yes" xml:space="preserve">
+          <source>Failed to convert files</source>
+          <target state="new">Failed to convert files</target>
+          <note from="MultilingualBuild" annotates="source" priority="2">转档失败</note>
+        </trans-unit>
       </group>
     </body>
   </file>

+ 10 - 1
PDF Office/Strings/MainPage/MainPage.Designer.cs

@@ -19,7 +19,7 @@ namespace PDF_Master.Strings.MainPage {
     // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
     // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
     // (以 /str 作为命令选项),或重新生成 VS 项目。
-    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
     public class MainPage {
@@ -411,6 +411,15 @@ namespace PDF_Master.Strings.MainPage {
             }
         }
         
+        /// <summary>
+        ///   查找类似 Failed to convert files 的本地化字符串。
+        /// </summary>
+        public static string Convert_FailedWarning {
+            get {
+                return ResourceManager.GetString("Convert_FailedWarning", resourceCulture);
+            }
+        }
+        
         /// <summary>
         ///   查找类似 Cancel 的本地化字符串。
         /// </summary>

+ 4 - 0
PDF Office/Strings/MainPage/MainPage.resx

@@ -240,6 +240,10 @@
   <data name="ContentSelection_ZoomArea" xml:space="preserve">
     <value>Zoom to Selected Area</value>
   </data>
+  <data name="Convert_FailedWarning" xml:space="preserve">
+    <value>Failed to convert files</value>
+    <comment>转档失败</comment>
+  </data>
   <data name="Convert_No" xml:space="preserve">
     <value>Cancel</value>
   </data>

+ 6 - 3
PDF Office/ViewModels/ViewContentViewModel.cs

@@ -913,9 +913,12 @@ namespace PDF_Master.ViewModels
         /// </summary>
         public void CloseAutoSave()
         {
-            autoSaveTimer.Stop();
-            autoSaveTimer.Tick -= AutoSaveTimer_Tick;
-            autoSaveTimer = null;
+            if (autoSaveTimer != null)
+            {
+                autoSaveTimer.Stop();
+                autoSaveTimer.Tick -= AutoSaveTimer_Tick;
+                autoSaveTimer = null;
+            }
         }
 
         private void AutoSaveTimer_Tick(object sender, EventArgs e)