liyijie 2 年之前
父节点
当前提交
0b51c7d8e8
共有 23 个文件被更改,包括 587 次插入374 次删除
  1. 二进制
      PDF Office/ComPDFKit.Desk.dll
  2. 二进制
      PDF Office/ComPDFKit.Viewer.dll
  3. 1 1
      PDF Office/Helper/HomePageEditHelper.cs
  4. 1 1
      PDF Office/Model/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageCompressDialogModel.cs
  5. 1 1
      PDF Office/Model/Dialog/ToolsDialogs/CompressDialogModel/CompressDialogModel.cs
  6. 7 6
      PDF Office/SDKLisence.xml
  7. 34 7
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundDialogViewModel.cs
  8. 34 10
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBates/HomePageBatesDialogViewModel.cs
  9. 34 5
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageCompressDialogViewModel.cs
  10. 30 2
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageConverter/HomePageConverterDialogViewModel.cs
  11. 33 8
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageHeaderFooter/HomePageHeaderFooterDialogViewModel.cs
  12. 9 6
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageRemoveDialogViewModel.cs
  13. 2 1
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageSetPasswordDialogViewModel.cs
  14. 33 7
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkDialogViewModel.cs
  15. 7 4
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageExtractDialogViewModel.cs
  16. 3 1
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageInsertDialogViewModel.cs
  17. 12 3
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePictureToPDFDialogViewModel.cs
  18. 14 9
      PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageSplitDialogViewModel.cs
  19. 202 202
      PDF Office/ViewModels/Dialog/ToolsDialogs/CompressDialogs/CompressDialogViewModel.cs
  20. 100 98
      PDF Office/ViewModels/Dialog/ToolsDialogs/CompressDialogs/CompressProgressBarDialogViewModel.cs
  21. 29 1
      PDF Office/ViewModels/HomePanel/PDFTools/QuickToolsContentViewModel.cs
  22. 1 1
      PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageCompressDialog.xaml
  23. 二进制
      PDF Office/x64/ComPDFKit.dll

二进制
PDF Office/ComPDFKit.Desk.dll


二进制
PDF Office/ComPDFKit.Viewer.dll


+ 1 - 1
PDF Office/Helper/HomePageEditHelper.cs

@@ -54,7 +54,7 @@ namespace PDF_Office.Helper
         /// </summary>
         /// <param name="pagecontent">文档总页数</param>
         /// <param name="averagedoc">平均几页分为一个文档</param>
-        /// <param name="remainder">引用,截至第几位文档比后面文档多一 例如11页文档 分为3份 4,4,3 remainder为1 第一个文档和第二文档比后续文档多一</param>
+        /// <param name="remainder">引用,截至第几位文档比后面文档多一 例如11页文档 分为3份 4,4,3 remainder为2 第一个文档和第二文档比后续文档多一</param>
         /// <returns></returns>
         public static int AverageSplitDocs(int pagecontent, int averagedoc, ref int remainder)
         {

+ 1 - 1
PDF Office/Model/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageCompressDialogModel.cs

@@ -12,7 +12,7 @@ namespace PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing
         {
             StatusLarge = 100,
             StatusStandard = 80,
-            StatusDefault = 45,
+            StatusDefault = 40,
             StatusLittle = 40,
             StatusMicro = 10
         }

+ 1 - 1
PDF Office/Model/Dialog/ToolsDialogs/CompressDialogModel/CompressDialogModel.cs

@@ -11,7 +11,7 @@ namespace PDF_Office.Model.Dialog.ToolsDialogs
        public enum EnumQualityLevel {  
         StatusLarge=100,
         StatusStandard=80,
-        StatusDefault=45,
+        StatusDefault=40,
         StatusLittle =40,
         StatusMicro=10
         }

+ 7 - 6
PDF Office/SDKLisence.xml

@@ -1,10 +1,11 @@
 <Lisences
-	devKey = "ehrnKqkWc1XSEAWyPUt6+95GzCoLEyoKrCbsUuJkCqGmxmP5ozX4bS0R6crHItQVNTFvC5mBZ1M7QjJ6Ekdu4Daj7PM+EDLTBKbFJinK4Ri9E5E2X+a9vF5zSj0TkIscQPVnwj9ikxAFOWGIyybMwQQzwc8a4j1cGOqGXQRDMMY="
-  devSecret = "mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4gQurxTxGuBlGAhs0P1mD3X3bHT+AHfcLiymaqE4DY7kTFHoPs9I3tl5ErS+BHdzHRhrp9sGpqfp0B228KI+IMTu4aGVjtYuk+Uxs/kosIBw1367/WkJ00tM7U7tttD6ccHhEu996bvBgqf8Sw8OekQKQq13VBewK5AckaDux4W7SGRhCUNWC4MItkr36JnXMD2tiFQYzMG8C66HYmRGSLh"
-  userKey = "iBPRM/Tz8b6Z1G2GQt52X7hiNCGfVYXztnPjalgrgARvqfKV6lFNH8QeScTzBRYI8GGFpwelfgh790Kd9JmL7V4adI1jCiFHUT2DLT7QucxY5Nkgys2aJItQS482Ck2G2Xf8gNgojxYxRt65o/MEzkj93foj8qIdfHagXsSorSs="
+	devKey = "sTHSivIW4YnZQavIYDLVw4vaFcN5DQTUtRGrVyv5p9aeaHX3GirG/MBxl6Wy9TJbNOwR4CU6LPjHmGe3Po3OtBCPqIRheam9+LomScw3AvoUTHFlG1134e2J4enF43WJQ6PyOnjwZqsG1kUdlBPNztkoPzDAE2pQKgZWf6V2i34="
+    devSecret = "mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4gQurxTxGuBlGAhs0P1mD3X3bHT+AHfcLiymaqE4DY7kTFHoPs9I3tl5ErS+BHdzHRhrp9sGpqfp0B228KI+IMTu4aGVjtYuk+Uxs/kosIBw1367/WkJ00tM7U7tttD6cfaiHpW8pgW2aur3AxuQIBBLuJD5gcmNxTYW3KA32JLG8alfyXjKFVS3gka9bngvwfZ7GuNXybjKlmz1tnN6iVHpnbSj+xOHhWEperY4HHrSg=="
+	userKey = "iBPRM/Tz8b6Z1G2GQt52X7hiNCGfVYXztnPjalgrgARvqfKV6lFNH8QeScTzBRYI8GGFpwelfgh790Kd9JmL7V4adI1jCiFHUT2DLT7QucxY5Nkgys2aJItQS482Ck2G2Xf8gNgojxYxRt65o/MEzkj93foj8qIdfHagXsSorSs="
 	userSecret="mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4ivEHOmPIqbfhpDnKKj+7Ymj2rXQvfZRmke06HMV+3tt064G64WjPW8+EbGCNZaAh1hrp9sGpqfp0B228KI+IMTu4aGVjtYuk+Uxs/kosIBw1FKJi6HYB+DuugQyaqI2prfej861QnJrU4s2T/npZK/"
-	ConverterDevKey="Eahwo7OZAYHJaCF7TJQYKSVqC62MzfBdllVXnC5BRR5BQFDKnQ1FJtCRVdug+VNg/ti+/DeA5Sq4IH2CBpQjAZst5705uk5Sz0ZwRu8Qdn9HFGwh2pG6dJEIrl7lOccoZS6+1IxgOTcTeHqYpym3NsmtbhBWE848Pvme3scpW28="
-	ConverterDevSecret="mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4iccr16WMBclnQACarlyblNUvAm/S8uFbhXMvxwgBSgULSsrbuyF/SIZ3I+dl0qU8EiR4IKrcJxus3VRNu+jx8P7CGq2BlSjPVXRHBI1lV8ukpCIUGmcK+P+Z0QbYdkAHAm6NPgs2c4tp1jOFPPbnUkTtX7riDb9xRCx1YNm3/+xd96PzrVCcmtTizZP+elkr8="
+	ConverterDevKey="ErjZKxcU3SPvUohGZo0CBgy0XdkAsZqUYqCTbfn1AYsCQ6mxCucx61UPqLT7MDQ0n+5/oKnWY9SSk8Xv5pJtYYHD87HRdYNG+QNCaoPGHulyfVxGllmzU71U7WjflfZBFvhg/UQOFiz3OsAVKz4k2YkXPzQgNaS3glym42PVpj4="
+	ConverterDevSecret="mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4iYfqdItiFUaR9LVjsPTUXicGXjRTJz0NHg67bO82qMNdkuY0NReKpg+S1SkS2QdEScM/fgvvcctF5rcqYAH1dpMv7C2jvq4o0q6sQtN3jR47j9bjclgv4TJTahQMmvDDLtOGD99YkYWB6rt/zU8htEYkwcNWVMyYvggPV2rTFvfawopGIC034QzjthmhwwX90="
 	ConverterUserkey=" WLUHzXhndQKyrTJVzvZ+dvPXDQDZeJpcSvklX3GJwRX4+urd8eQskYgbeCf0NXLZ/qJkS/k10x+qGad34i4v5rI/ASFIx901c/Nw5C0YJMH7X87dib141tdAmSmQhnKLO5TBi4FiAidboyvnLFLrYGMmS2kLQOXFPwPj5zQUv5A="
-	ConverterUserSecret="mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4iK16EcneqBPRe2eKQLuJXpA79IONX9GVI/Ap3uWzMcNWaitc2UB6gDeexJXFPVaXOFAoV6NtcUJC8skonXVk7k/oKTJGcYKLPGdXenrzHolQ==" >
+	ConverterUserSecret="mG0c3O3Mzeu5dkZJW3gpqq9uA7o7EGQveSC38Q8TK4iK16EcneqBPRe2eKQLuJXpA79IONX9GVI/Ap3uWzMcNWaitc2UB6gDeexJXFPVaXOFAoV6NtcUJC8skonXVk7k/oKTJGcYKLPGdXenrzHolQ=="
+	>
 </Lisences>

+ 34 - 7
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBackground/HomePageBackgroundDialogViewModel.cs

@@ -21,6 +21,7 @@ using PDFSettings;
 using PDF_Office.Model.EditTools.Bates;
 using PDF_Office.Model.EditTools.Background;
 using static System.Windows.Forms.VisualStyles.VisualStyleElement.TrayNotify;
+using Prism.Services.Dialogs;
 
 namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBackground
 {
@@ -39,6 +40,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         public IRegionManager backgroundRegion;
         public IEventAggregator eventAggregator;
+        public IDialogService dialogs;
 
         private CPDFViewer PDFViewer;
 
@@ -228,10 +230,11 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         public string Unicode = null;
 
-        public HomePageBackgroundDialogViewModel(IRegionManager backgroundRegion, IEventAggregator eventAggregator)
+        public HomePageBackgroundDialogViewModel(IRegionManager backgroundRegion, IEventAggregator eventAggregator, IDialogService dialogs)
         {
             this.eventAggregator = eventAggregator;
             this.backgroundRegion = backgroundRegion;
+            this.dialogs = dialogs;
             PDFCurrentDataTable.Columns.Add("FilePageRangeText");
             PDFCurrentDataTable.Columns.Add("FilePageRangeSelectIndex");
             PDFCurrentDataTable.Columns.Add("IsEvenPageIsEnabled");
@@ -253,6 +256,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             eventAggregator.GetEvent<SetCurrentCreateModEvent>().Subscribe(SetCurrentCreateMod, e => e.Unicode == Unicode);
             eventAggregator.GetEvent<SetCurrentTemplateListModEvent>().Subscribe(SetCurrentTemplateListMod, e => e.Unicode == Unicode);
             eventAggregator.GetEvent<EditBackgroundTemplateItemEvent>().Subscribe(EditBackgroundTemplateItem, e => e.Unicode == Unicode);
+            
         }
         #region 逻辑函数
         public void EnterTemplateListOrCreate(EnumTemplateListOrCreateUnicode enumTemplateListOrCreateunicode)
@@ -340,13 +344,39 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
                 char[] rangeSeparator = new char[] { '-' };
                 List<int> PageIndexLists = new List<int>();
                 CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
-                if (document == null || document.IsEncrypted)
+                if (document == null)
                 {
                     PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                    PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                    fileNamesIndex++;
                     continue;
                 }
+                if (document.IsLocked)
+                {
+                    DialogParameters value = new DialogParameters();
+                    value.Add(ParameterNames.PDFDocument, document);
+                    dialogs.ShowDialog(DialogNames.VerifyPassWordDialog, value, e =>
+                    {
+                        if (e.Result == ButtonResult.OK)
+                        {
+                            if (e.Parameters.ContainsKey(ParameterNames.PassWord) && e.Parameters.GetValue<string>(ParameterNames.PassWord) != null)
+                            {
+                                document.UnlockWithPassword(e.Parameters.GetValue<string>(ParameterNames.PassWord).ToString());
+                            }
+                        }
+                    });
+
+                    if (document.IsLocked)
+                    {
+                        //未成功解密文档时,释放Document对象,返回
+                        PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                        PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                        fileNamesIndex++;
+                        continue;
+                    }
+                }
                 CreateBackground(document);
-                document.WriteToFilePath(filename + "_Background.pdf");
+                document.WriteToFilePath(CommonHelper.CreateFilePath(filename + "_Background.pdf"));
                 //    if (!CommonHelper.GetPagesInRange(ref PageIndexLists, "1-" + document.PageCount.ToString(), document.PageCount, enumerationSeparator, rangeSeparator))
                 //    { //TODO
                 //        Trace.WriteLine("输入不对");
@@ -354,11 +384,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
                 //        return;
                 //    }
 
-                //    document.Release();
-                //PDFDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
+                document.Release();
                 PDFDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
-                //PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeText"] = "2";
-                //PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
                 PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
                 fileNamesIndex++;
             }

+ 34 - 10
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageBates/HomePageBatesDialogViewModel.cs

@@ -23,6 +23,7 @@ using PDF_Office.Model.EditTools.Watermark;
 using PDF_Office.Model.EditTools.Bates;
 using PDF_Office.Model.EditTools.Background;
 using MessageBox = System.Windows.MessageBox;
+using Prism.Services.Dialogs;
 
 namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBates
 {
@@ -42,6 +43,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         public IEventAggregator eventAggregator;
         public IRegionManager batesRegion;
+        public IDialogService dialogs;
 
         private CPDFViewer PDFViewer;
 
@@ -203,10 +205,11 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         public string Unicode = null;
 
-        public HomePageBatesDialogViewModel(IRegionManager batesRegion, IEventAggregator eventAggregator)
+        public HomePageBatesDialogViewModel(IRegionManager batesRegion, IEventAggregator eventAggregator,IDialogService dialogs)
         {
             this.eventAggregator = eventAggregator;
             this.batesRegion = batesRegion;
+            this.dialogs = dialogs;
             BatesSettingsRegionName = Guid.NewGuid().ToString();
             Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
             PDFCurrentDataTable.Columns.Add("FilePageRangeText");
@@ -278,27 +281,48 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
                 char[] rangeSeparator = new char[] { '-' };
                 List<int> PageIndexLists = new List<int>();
                 CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
-                if (document == null||document.IsEncrypted)
+                if (document == null)
                 {
                     PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                    PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
                     fileNamesIndex++;
-                    continue; 
+                    continue;
                 }
-               // MessageBox.Show(filename);
+                if (document.IsLocked)
+                {
+                    DialogParameters value = new DialogParameters();
+                    value.Add(ParameterNames.PDFDocument, document);
+                    dialogs.ShowDialog(DialogNames.VerifyPassWordDialog, value, e =>
+                    {
+                        if (e.Result == ButtonResult.OK)
+                        {
+                            if (e.Parameters.ContainsKey(ParameterNames.PassWord) && e.Parameters.GetValue<string>(ParameterNames.PassWord) != null)
+                            {
+                                document.UnlockWithPassword(e.Parameters.GetValue<string>(ParameterNames.PassWord).ToString());
+                            }
+                        }
+                    });
+
+                    if (document.IsLocked)
+                    {
+                        //未成功解密文档时,释放Document对象,返回
+                        PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                        PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                        fileNamesIndex++;
+                        continue;
+                    }
+                }
+                // MessageBox.Show(filename);
                 CreateBates(document);
-                document.WriteToFilePath(filename + "_Bates.pdf");
+                document.WriteToFilePath(CommonHelper.CreateFilePath(filename + "_Bates.pdf"));
                 //if (!CommonHelper.GetPagesInRange(ref PageIndexLists, "1-" + document.PageCount.ToString(), document.PageCount, enumerationSeparator, rangeSeparator))
                 //{ //TODO
                 //    Trace.WriteLine("输入不对");
                 //    MessageBoxEx.Show("输入不对");
                 //    return;
                 //}
-
-                //document.Release();
-                //PDFDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
+                document.Release();
                 PDFDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
-                //PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeText"] = "2";
-                //PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
                 PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
                 fileNamesIndex++;
             }

+ 34 - 5
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageCompressDialogViewModel.cs

@@ -1,5 +1,7 @@
 using ComPDFKit.PDFDocument;
+using ComPDFKitViewer.PdfViewer;
 using PDF_Office.CustomControl;
+using PDF_Office.Helper;
 using PDF_Office.Model;
 using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
 using Prism.Commands;
@@ -24,6 +26,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         #region 参数和属性
         private List<string> fileNames;
 
+        public IDialogService dialogs;
+
         private CPDFDocument tempDocument;
 
         public List<int> fileNamesView = new List<int>();
@@ -129,7 +133,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         public DelegateCommand<string> RadioButtonCommand{ get; set; }
         #endregion
 
-        public HomePageCompressDialogViewModel()
+        public HomePageCompressDialogViewModel(IDialogService dialogs)
         {
             PDFCurrentDataTable.Columns.Add("FileState");
             PDFDataTable.Columns.Add("FileName");
@@ -140,6 +144,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             RemovePDFFileCommand = new DelegateCommand(removepdffile);
             CompressCommand = new DelegateCommand(compress);
             RadioButtonCommand = new DelegateCommand<string>(RadioButton);
+            this.dialogs = dialogs;
         }
         #region 逻辑函数
         private void RadioButton(string sender) {
@@ -179,25 +184,49 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             foreach (var filename in fileNames)
             {
                 CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
-                if (document == null) {
+                if (document == null)
+                {
                     PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
                     PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                    fileNamesIndex++;
                     continue;
                 }
+                if (document.IsLocked)
+                {
+                    DialogParameters value = new DialogParameters();
+                    value.Add(ParameterNames.PDFDocument, document);
+                    dialogs.ShowDialog(DialogNames.VerifyPassWordDialog, value, e =>
+                    {
+                        if (e.Result == ButtonResult.OK)
+                        {
+                            if (e.Parameters.ContainsKey(ParameterNames.PassWord) && e.Parameters.GetValue<string>(ParameterNames.PassWord) != null)
+                            {
+                                document.UnlockWithPassword (e.Parameters.GetValue<string>(ParameterNames.PassWord).ToString());
+                            }
+                        }
+                    });
+
+                    if (document.IsLocked)
+                    {
+                        //未成功解密文档时,释放Document对象,返回
+                        PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                        PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                        fileNamesIndex++;
+                        continue;
+                    }
+                }
                 FileInfo fileinfo = new FileInfo(filename);
                 string file_size = (((float)fileinfo.Length) / 1024).ToString() + " K";
                 indexDelegate += GetIndex;
                 compressingIntpr = document.CompressFile_Init(((float)homePageCompressDialogModel.CompressQuality), indexDelegate);
                 tempDocument = document;
-                await Task.Run<bool>(() => { return document.CompressFile_Start(compressingIntpr, filename+"compress.pdf"); });
+                await Task.Run<bool>(() => { return document.CompressFile_Start(compressingIntpr, CommonHelper.CreateFilePath(filename +"compress.pdf")); });
                 PDFDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
                 PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
                 fileNamesIndex++;
                 document.Release();
             }
             CompressGridIsEnabled = "True";
-            MessageBoxEx.Show("已完成");
-            
         }
         #endregion
 

+ 30 - 2
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageConverter/HomePageConverterDialogViewModel.cs

@@ -1,5 +1,6 @@
 using ComPDFKit.PDFDocument;
 using ComPDFKit_Conversion.Converter;
+using Microsoft.Office.Interop.Excel;
 using Microsoft.Office.Interop.Word;
 using PDF_Office.CustomControl;
 using PDF_Office.Helper;
@@ -43,6 +44,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         public string PageNumber = "";
 
         public IRegionManager ConverterRegion;
+        public IDialogService dialogs;
 
         public List<int> fileNamesView = new List<int>();
 
@@ -183,7 +185,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
         public DelegateCommand ADDPDFFilesCommand { get; set; }
         #endregion
 
-        public HomePageConverterDialogViewModel(IRegionManager converterRegion)
+        public HomePageConverterDialogViewModel(IRegionManager converterRegion, IDialogService dialogs)
         {
 
             SetImageTypeOrigin();
@@ -203,6 +205,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             RemovePDFFileCommand = new DelegateCommand(removepdffile);
             ConvertCommand = new DelegateCommand(convert);
             ConverterRegion = converterRegion;
+            this.dialogs = dialogs;
             ConverterRegionName=Guid.NewGuid().ToString();
         }
         #region 逻辑函数
@@ -228,12 +231,37 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
                 char[] rangeSeparator = new char[] { '-' };
                 List<int> PageIndexLists=new List<int>();
                 CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
-                if (document == null)
+                if (document == null )
                 {
                     PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
                     PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                    fileNamesIndex++;
                     continue;
                 }
+                if (document.IsLocked)
+                {
+                    DialogParameters value = new DialogParameters();
+                    value.Add(ParameterNames.PDFDocument, document);
+                    dialogs.ShowDialog(DialogNames.VerifyPassWordDialog, value, e =>
+                    {
+                        if (e.Result == ButtonResult.OK)
+                        {
+                            if (e.Parameters.ContainsKey(ParameterNames.PassWord) && e.Parameters.GetValue<string>(ParameterNames.PassWord) != null)
+                            {
+                                document.UnlockWithPassword(e.Parameters.GetValue<string>(ParameterNames.PassWord).ToString());
+                            }
+                        }
+                    });
+
+                    if (document.IsLocked)
+                    {
+                        //未成功解密文档时,释放Document对象,返回
+                        PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                        PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                        fileNamesIndex++;
+                        continue;
+                    }
+                }
                 if (!CommonHelper.GetPagesInRange(ref PageIndexLists, "1-" + document.PageCount.ToString(),document.PageCount, enumerationSeparator, rangeSeparator))
                 { //TODO
                     Trace.WriteLine("输入不对");

+ 33 - 8
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageHeaderFooter/HomePageHeaderFooterDialogViewModel.cs

@@ -19,6 +19,7 @@ using ComPDFKitViewer.PdfViewer;
 using PDF_Office.EventAggregators;
 using PDFSettings;
 using PDF_Office.Model.EditTools.HeaderFooter;
+using Prism.Services.Dialogs;
 
 namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageHeaderFooter
 {
@@ -36,6 +37,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         public IRegionManager headerFooterRegion;
         public IEventAggregator eventAggregator;
+        public IDialogService dialogs;
 
         private CPDFViewer PDFViewer;
 
@@ -210,11 +212,11 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         public string Unicode = null;
 
-        public HomePageHeaderFooterDialogViewModel(IRegionManager regionManager, IEventAggregator eventAggregator)
+        public HomePageHeaderFooterDialogViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, IDialogService dialogs)
         {
             this.eventAggregator = eventAggregator;
             this.headerFooterRegion = regionManager;
-
+            this.dialogs = dialogs;
             HeaderFooterSettingsRegionName = Guid.NewGuid().ToString();
             Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
             PDFCurrentDataTable.Columns.Add("FilePageRangeText");
@@ -287,13 +289,39 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
                 char[] rangeSeparator = new char[] { '-' };
                 List<int> PageIndexLists = new List<int>();
                 CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
-                if (document == null || document.IsEncrypted)
+                if (document == null)
                 {
                     PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                    PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                    fileNamesIndex++;
                     continue;
                 }
+                if (document.IsLocked)
+                {
+                    DialogParameters value = new DialogParameters();
+                    value.Add(ParameterNames.PDFDocument, document);
+                    dialogs.ShowDialog(DialogNames.VerifyPassWordDialog, value, e =>
+                    {
+                        if (e.Result == ButtonResult.OK)
+                        {
+                            if (e.Parameters.ContainsKey(ParameterNames.PassWord) && e.Parameters.GetValue<string>(ParameterNames.PassWord) != null)
+                            {
+                                document.UnlockWithPassword(e.Parameters.GetValue<string>(ParameterNames.PassWord).ToString());
+                            }
+                        }
+                    });
+
+                    if (document.IsLocked)
+                    {
+                        //未成功解密文档时,释放Document对象,返回
+                        PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                        PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                        fileNamesIndex++;
+                        continue;
+                    }
+                }
                 CreateHeaderFooter(document);
-                document.WriteToFilePath(filename + "_HeaderFooter.pdf");
+                document.WriteToFilePath(CommonHelper.CreateFilePath(filename + "_HeaderFooter.pdf"));
                 //if (!CommonHelper.GetPagesInRange(ref PageIndexLists, "1-" + document.PageCount.ToString(), document.PageCount, enumerationSeparator, rangeSeparator))
                 //{ //TODO
                 //    Trace.WriteLine("输入不对");
@@ -301,11 +329,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
                 //    return;
                 //}
 
-                //document.Release();
-                PDFDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
+                document.Release();
                 PDFDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
-                PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeText"] = "2";
-                PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
                 PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
                 fileNamesIndex++;
             }

+ 9 - 6
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageRemoveDialogViewModel.cs

@@ -1,6 +1,7 @@
 using ComPDFKit.PDFDocument;
 using ComPDFKitViewer.PdfViewer;
 using PDF_Office.CustomControl;
+using PDF_Office.Helper;
 using PDF_Office.Model;
 using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
 using PDF_Office.Model.Dialog.ToolsDialogs.SaftyDialogs;
@@ -244,14 +245,14 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             {
                 PDFDataTable.Rows[fileNamesIndex]["FileState"] = "待完成";
                 CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
-                
+
                 if (document == null)
                 {
                     PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
                     PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                    fileNamesIndex++;
                     continue;
                 }
-                FileInfo fileinfo = new FileInfo(filename);
                 if (document.IsLocked)
                 {
                     DialogParameters value = new DialogParameters();
@@ -262,7 +263,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
                         {
                             if (e.Parameters.ContainsKey(ParameterNames.PassWord) && e.Parameters.GetValue<string>(ParameterNames.PassWord) != null)
                             {
-                              
+                                document.UnlockWithPassword(e.Parameters.GetValue<string>(ParameterNames.PassWord).ToString());
                             }
                         }
                     });
@@ -270,12 +271,14 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
                     if (document.IsLocked)
                     {
                         //未成功解密文档时,释放Document对象,返回
-                        document.Release();
                         PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
                         PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                        fileNamesIndex++;
                         continue;
                     }
                 }
+                FileInfo fileinfo = new FileInfo(filename);
+                
                 if (WatermarkIsRemove)
                 {
                     document.DeleteWatermarks();
@@ -294,12 +297,12 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
                 }
                 if (SecurityIsRemove)
                 {
-                    document.Descrypt(filename + "_Remove.pdf");
+                    document.Descrypt(CommonHelper.CreateFilePath(filename + "_Remove.pdf"));
 
                 }
                 else
                 {
-                    document.WriteToFilePath(filename + "_Remove.pdf");
+                    document.WriteToFilePath(CommonHelper.CreateFilePath(filename + "_Remove.pdf"));
                 }
                 PDFDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
                 PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "完成";

+ 2 - 1
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageSetPasswordDialogViewModel.cs

@@ -298,10 +298,11 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
             {
                 PDFDataTable.Rows[fileNamesIndex]["FileState"] = "待完成";
                 CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
-                if (document == null)
+                if (document == null || document.IsEncrypted)
                 {
                     PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
                     PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                    fileNamesIndex++;
                     continue;
                 }
                 FileInfo fileinfo = new FileInfo(filename);

+ 33 - 7
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageWatermark/HomePageWatermarkDialogViewModel.cs

@@ -20,6 +20,7 @@ using PDF_Office.EventAggregators;
 using PDFSettings;
 using PDF_Office.Model.EditTools.Watermark;
 using ComPDFKit.PDFWatermark;
+using Prism.Services.Dialogs;
 
 namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageWatermark
 {
@@ -34,6 +35,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         public IEventAggregator eventAggregator;
         public IRegionManager watermarkRegion;
+        public IDialogService dialogs;
 
         private CPDFViewer PDFViewer;
 
@@ -223,10 +225,11 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
 
         public string Unicode = null;
 
-        public HomePageWatermarkDialogViewModel(IRegionManager watermarkRegion, IEventAggregator eventAggregator)
+        public HomePageWatermarkDialogViewModel(IRegionManager watermarkRegion, IEventAggregator eventAggregator, IDialogService dialogs)
         {
             this.eventAggregator = eventAggregator;
             this.watermarkRegion = watermarkRegion;
+            this.dialogs = dialogs;
             Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
             WatermarkSettingsVisible = Visibility.Visible;
             PDFCurrentDataTable.Columns.Add("FilePageRangeText");
@@ -343,13 +346,39 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
                 char[] rangeSeparator = new char[] { '-' };
                 List<int> PageIndexLists = new List<int>();
                 CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
-                if (document == null || document.IsEncrypted)
+                if (document == null )
                 {
                     PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                    PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                    fileNamesIndex++;
                     continue;
                 }
+                if (document.IsLocked)
+                {
+                    DialogParameters value = new DialogParameters();
+                    value.Add(ParameterNames.PDFDocument, document);
+                    dialogs.ShowDialog(DialogNames.VerifyPassWordDialog, value, e =>
+                    {
+                        if (e.Result == ButtonResult.OK)
+                        {
+                            if (e.Parameters.ContainsKey(ParameterNames.PassWord) && e.Parameters.GetValue<string>(ParameterNames.PassWord) != null)
+                            {
+                                document.UnlockWithPassword(e.Parameters.GetValue<string>(ParameterNames.PassWord).ToString());
+                            }
+                        }
+                    });
+
+                    if (document.IsLocked)
+                    {
+                        //未成功解密文档时,释放Document对象,返回
+                        PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                        PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                        fileNamesIndex++;
+                        continue;
+                    }
+                }
                 CreateWatermark(document);
-                document.WriteToFilePath(filename + "_Watermark.pdf");
+                document.WriteToFilePath(CommonHelper.CreateFilePath(filename + "_Watermark.pdf"));
                 //if (!CommonHelper.GetPagesInRange(ref PageIndexLists, "1-" + document.PageCount.ToString(), document.PageCount, enumerationSeparator, rangeSeparator))
                 //{ //TODO
                 //    Trace.WriteLine("输入不对");
@@ -357,11 +386,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
                 //    return;
                 //}
 
-                //document.Release();
-                //PDFDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
+                document.Release();
                 PDFDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
-                //PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeText"] = "2";
-                //PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
                 PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
                 fileNamesIndex++;
             }

+ 7 - 4
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageExtractDialogViewModel.cs

@@ -13,6 +13,7 @@ using PDF_Office.Helper;
 using System.Diagnostics;
 using PDF_Office.CustomControl;
 using PDF_Office.Model.Dialog.HomePageToolsDialogs;
+using ImTools;
 
 namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
 {
@@ -35,7 +36,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
 
         public string PageRangeText { get; set; } = "";
 
-        public string PageRangeSelectIndex { get; set; } = "";
+        public string PageRangeSelectIndex { get; set; } = "0";
         #endregion
 
         #region 委托声明
@@ -86,7 +87,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
                     CPDFDocument extractdoc = CPDFDocument.CreateDocument();
                     extractdoc.ImportPages(currentViewer.Document, (extractModel.PageParm.ToArray()[i] + 1).ToString());
                     Trace.WriteLine(extractModel.PageParm.ToArray()[i].ToString());
-                    extractdoc.WriteToFilePath(savefilepath + currentViewer.Document.FileName + ".extract" + i.ToString() + ".pdf");
+                    string createfilepath= CommonHelper.CreateFilePath(savefilepath + currentViewer.Document.FileName + ".extract" + i.ToString() + ".pdf");
+                    extractdoc.WriteToFilePath(createfilepath);
                     extractdoc.Release();
                 }
                 if (extractModel.DeleteAfterExtract)
@@ -100,7 +102,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
             {
                 CPDFDocument extractdoc = CPDFDocument.CreateDocument();
                 extractdoc.ImportPages(currentViewer.Document, extractModel.PageRange);
-                extractdoc.WriteToFilePath(savefilepath + currentViewer.Document.FileName + ".extract.pdf");
+                string createfilepath = CommonHelper.CreateFilePath(savefilepath + currentViewer.Document.FileName + ".extract.pdf");
+                extractdoc.WriteToFilePath(createfilepath);
                 if (extractModel.DeleteAfterExtract)
                 {
                     currentViewer.Document.RemovePages(extractModel.PageParm.ToArray());
@@ -108,7 +111,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
                 }
                 extractdoc.Release();
             }
-            System.Diagnostics.Process.Start("Explorer", "/select," + currentViewer.Document.FilePath);
+            CommonHelper.ShowFileBrowser(currentViewer.Document.FilePath);
             RequestClose.Invoke(new DialogResult(ButtonResult.OK));
         }
 

+ 3 - 1
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageInsertDialogViewModel.cs

@@ -9,6 +9,7 @@ using PDF_Office.Model.HomePageToolsDialogs;
 using System.Diagnostics;
 using DialogResult = Prism.Services.Dialogs.DialogResult;
 using PDF_Office.CustomControl;
+using PDF_Office.Helper;
 
 namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
 {
@@ -142,7 +143,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
             currentViewer.Document.ImportPagesAtIndex(insertdocument, insertModel.InserPageRange(insertdocument), insertModel.InsertIndex);
             currentViewer.Document.WriteToLoadedPath();
             insertdocument.Release();
-            System.Diagnostics.Process.Start("Explorer", "/select," + currentViewer.Document.FilePath);
+            CommonHelper.ShowFileBrowser(currentViewer.Document.FilePath);
+            //System.Diagnostics.Process.Start("Explorer", "/select," + currentViewer.Document.FilePath);
             RequestClose.Invoke(new DialogResult(ButtonResult.OK));
         }
 

+ 12 - 3
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePagePictureToPDFDialogViewModel.cs

@@ -146,10 +146,12 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
                 foreach (var filename in fileNames)
                 {
                     ImagesDataTable.Rows[fileNamesIndex]["FileState"] = "准备转换";
+                    ImagesCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "准备转换";
                     Image img = Image.FromFile(filename);
                     if (img == null)
                     {
                         ImagesDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                        ImagesCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
                         continue;
                     }
                     CPDFDocument topdfdoc = CPDFDocument.CreateDocument();
@@ -160,6 +162,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
                     topdfdoc.Release();
                     string file_size = (((float)fileinfo.Length) / 1024).ToString() + " K";
                     ImagesDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
+                    ImagesCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
                     fileNamesIndex++;
                 }
                 System.Diagnostics.Process.Start("Explorer", "/select," + savefilename(fileNames[0]));
@@ -170,10 +173,12 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
                 int pageindex = 0;
                 foreach (var filename in fileNames) {
                     ImagesDataTable.Rows[fileNamesIndex]["FileState"] = "准备转换";
+                    ImagesCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "准备转换";
                     Image img = Image.FromFile(filename);
                     if (img == null)
                     {
                         ImagesDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                        ImagesCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
                         continue;
                     }
                     FileInfo fileinfo = new FileInfo(filename);
@@ -181,6 +186,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
                     pageindex++;
                     string file_size = (((float)fileinfo.Length) / 1024).ToString() + " K";
                     ImagesDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
+                    ImagesCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
                     fileNamesIndex++;
                 }
                 System.Diagnostics.Process.Start("Explorer", "/select," + savefilename(fileNames[0]));
@@ -208,10 +214,12 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
                 foreach (var filename in fileNames)
                 {
                     ImagesDataTable.Rows[fileNamesIndex]["FileState"] = "准备转换";
+                    ImagesCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "准备转换";
                     Image img = Image.FromFile(filename);
                     if (img == null)
                     {
                         ImagesDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
+                        ImagesCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
                         continue;
                     }
                     FileInfo fileinfo = new FileInfo(filename);
@@ -219,6 +227,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
                     pageindex++;
                     string file_size = (((float)fileinfo.Length) / 1024).ToString() + " K";
                     ImagesDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
+                    ImagesCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
                     fileNamesIndex++;
                 }
                 topdfdoc.WriteToLoadedPath();
@@ -235,7 +244,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
         public string savefilename(string filename)
         {
             FileInfo file = new FileInfo(filename);
-            return filename.Replace(file.Name, "") +pictureToPDFModel.FrontFileNameLabel+file.Name+pictureToPDFModel.RearFileNameLabel+".pdf";
+            return CommonHelper.CreateFilePath(filename.Replace(file.Name, "") + pictureToPDFModel.FrontFileNameLabel + file.Name + pictureToPDFModel.RearFileNameLabel + ".pdf");
         }
         #endregion
 
@@ -382,7 +391,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
         /// 更新listview显示
         /// state 状态显示字符串
         /// </summary>
-        public void updateListview( string state) {
+        public void updateListview(string state) {
             updateCurrentListview();
             DataTable imagesdatatable = new DataTable();
             imagesdatatable.Columns.Add("FileName");
@@ -410,7 +419,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
             {
                 for (int i = 0; fileNames.Count - FileNameNumber > i; i++)
                 {
-                    ImagesCurrentDataTable.Rows.Add( state);
+                    ImagesCurrentDataTable.Rows.Add(state);
                 }
             }
             else

+ 14 - 9
PDF Office/ViewModels/Dialog/HomePageToolsDialogs/HomePageSplitDialogViewModel.cs

@@ -246,8 +246,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
                 {
                     CPDFDocument extractdoc = CPDFDocument.CreateDocument();
                     extractdoc.ImportPages(currentViewer.Document, (1 + splitModel.GetModeCount * (averagepagesdoc - 1)).ToString() + "-" + (splitModel.GetModeCount * averagepagesdoc).ToString());
-
-                    extractdoc.WriteToFilePath(splitModel.FileName + averagepagesdoc.ToString() + ".pdf");
+                    string createfilepath = CommonHelper.CreateFilePath(splitModel.FileName + ".split" + averagepagesdoc.ToString() + ".pdf");
+                    extractdoc.WriteToFilePath(createfilepath);
 
                     extractdoc.Release();
                 }
@@ -255,7 +255,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
                 {
                     CPDFDocument extractdoc = CPDFDocument.CreateDocument();
                     extractdoc.ImportPages(currentViewer.Document, (1 + splitModel.GetModeCount * (averagepagesdoc - 1)).ToString() + "-" + currentViewer.Document.PageCount.ToString());
-                    extractdoc.WriteToFilePath(splitModel.FileName + averagepagesdoc.ToString() + ".pdf");
+                    string createfilepath = CommonHelper.CreateFilePath(splitModel.FileName + ".split" + averagepagesdoc.ToString() + ".pdf");
+                    extractdoc.WriteToFilePath(createfilepath);
                 }
             }
             if (splitModel.Mode == HomePageSplitDialogModel.SplitMode.AverageFiles)
@@ -269,7 +270,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
                 int averagefilesdoc;
                 if (splitModel.GetModeCount > currentViewer.Document.PageCount)
                 {
-                    splitModel.GetModeCount = 10;
+                    splitModel.GetModeCount = currentViewer.Document.PageCount;
                 }
                 for (averagefilesdoc = 1; averagefilesdoc <= splitModel.GetModeCount; averagefilesdoc++)
                 {
@@ -277,13 +278,15 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
                     if (averagefilesremainder > 0)
                     {
                         extractdoc.ImportPages(currentViewer.Document, (1 + (averagefilespages + 1) * (averagefilesdoc - 1)).ToString() + "-" + ((averagefilespages + 1) * averagefilesdoc).ToString());
-                        extractdoc.WriteToFilePath(splitModel.FileName + averagefilesdoc.ToString() + ".pdf");
+                        string createfilepath = CommonHelper.CreateFilePath(splitModel.FileName + ".split" + averagefilesdoc.ToString() + ".pdf");
+                        extractdoc.WriteToFilePath(createfilepath);
                         averagefilesremainder--;
                     }
                     else
                     {
                         extractdoc.ImportPages(currentViewer.Document, (averagefilespages * averagefilesremainder + averagefilesremainder + 1 + averagefilespages * (averagefilesdoc - 1)).ToString() + "-" + (averagefilespages * averagefilesremainder + averagefilesremainder + (averagefilespages * averagefilesdoc)).ToString());
-                        extractdoc.WriteToFilePath(splitModel.FileName + averagefilesdoc.ToString() + ".pdf");
+                        string createfilepath = CommonHelper.CreateFilePath(splitModel.FileName + ".split" + averagefilesdoc.ToString() + ".pdf");
+                        extractdoc.WriteToFilePath(createfilepath);
                     }
                     extractdoc.Release();
                 }
@@ -292,14 +295,16 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs
             {
                 CPDFDocument extractdoc = CPDFDocument.CreateDocument();
                 extractdoc.ImportPages(currentViewer.Document, splitModel.PageRange);
-                extractdoc.WriteToFilePath(splitModel.FileName + "1" + ".pdf");
+                string createfilepath = CommonHelper.CreateFilePath(splitModel.FileName + ".split" + "1" + ".pdf");
+                extractdoc.WriteToFilePath(createfilepath);
                 if (splitModel.PageRange != "1-" + currentViewer.Document.PageCount.ToString())
                 {
                     currentViewer.Document.RemovePages(splitModel.PageParm.ToArray());
-                    currentViewer.Document.WriteToFilePath(splitModel.FileName + "2" + ".pdf");
+                    createfilepath = CommonHelper.CreateFilePath(splitModel.FileName + ".split" + "2" + ".pdf");
+                    currentViewer.Document.WriteToFilePath(createfilepath);
                 }
             }
-            System.Diagnostics.Process.Start("Explorer", "/select," + currentViewer.Document.FilePath);
+            CommonHelper.ShowFileBrowser(currentViewer.Document.FilePath);
             RequestClose.Invoke(new DialogResult(ButtonResult.OK));
         }
 

+ 202 - 202
PDF Office/ViewModels/Dialog/ToolsDialogs/CompressDialogs/CompressDialogViewModel.cs

@@ -1,205 +1,205 @@
-using ComPDFKit.PDFDocument;
-using PDF_Office.Model.Dialog.ToolsDialogs;
-using PDF_Office.Model;
-using Prism.Commands;
-using Prism.Mvvm;
-using Prism.Services.Dialogs;
-using System;
-using System.Diagnostics;
-using System.Windows.Forms;
-using System.Windows;
-using DialogResult = Prism.Services.Dialogs.DialogResult;
-using MessageBox = System.Windows.Forms.MessageBox;
+using ComPDFKit.PDFDocument;
+using PDF_Office.Model.Dialog.ToolsDialogs;
+using PDF_Office.Model;
+using Prism.Commands;
+using Prism.Mvvm;
+using Prism.Services.Dialogs;
+using System;
+using System.Diagnostics;
+using System.Windows.Forms;
+using System.Windows;
+using DialogResult = Prism.Services.Dialogs.DialogResult;
+using MessageBox = System.Windows.Forms.MessageBox;
 using PDF_Office.Helper;
 using ComPDFKitViewer.PdfViewer;
 
-namespace PDF_Office.ViewModels.Dialog.ToolsDialogs.CompressDialogs
-{
-    public class CompressDialogViewModel : BindableBase, IDialogAware
-    {
-        #region 参数和属性
-        private CompressDialogModel compressDialogModel;
-        private IntPtr compressingIntpr = IntPtr.Zero;
-        private CPDFDocument document;
-        private CPDFViewer pdfviewer;
-        private Visibility _compressLargeStyle = Visibility.Hidden;
-        public IDialogService dialogs;
-
-        public Visibility CompressLargeStyle
-        {
-            get { return _compressLargeStyle; }
-            set
-            {
-                SetProperty(ref _compressLargeStyle, value);
-            }
-        }
-
-        private Visibility _compressStandardStyle = Visibility.Hidden;
-        public Visibility CompressStandardStyle
-        {
-            get { return _compressStandardStyle; }
-            set
-            {
-                SetProperty(ref _compressStandardStyle, value);
-            }
-        }
-        private Visibility _compressLittleStyle = Visibility.Hidden;
-        public Visibility CompressLittleStyle
-        {
-            get { return _compressLittleStyle; }
-            set
-            {
-                SetProperty(ref _compressLittleStyle, value);
-            }
-        }
-        private Visibility _compressMicroStyle = Visibility.Hidden;
-        public Visibility CompressMicroStyle
-        {
-            get { return _compressMicroStyle; }
-            set
-            {
-                SetProperty(ref _compressMicroStyle, value);
-            }
-        }
-        #endregion
-
-        #region 委托声明
-        public DelegateCommand LargeQualityCommand { get; set; }
-
-        public DelegateCommand StandardQualityCommand { get; set; }
-
-        public DelegateCommand LittleQualityCommand { get; set; }
-
-        public DelegateCommand MicroQualityCommand { get; set; }
-
-        public DelegateCommand CompressCommand { get; set; }
-
-        public DelegateCommand ConfirmCompressCommand { get; set; }
-        #endregion
-
-        public CompressDialogViewModel(IDialogService dialogService)
-        {
-            LargeQualityCommand = new DelegateCommand(LargeQuality);
-            StandardQualityCommand = new DelegateCommand(StandardQuality);
-            LittleQualityCommand = new DelegateCommand(LittleQuality);
-            MicroQualityCommand = new DelegateCommand(MicroQuality);
-            CompressCommand = new DelegateCommand(Compress);
-            ConfirmCompressCommand = new DelegateCommand(ConfirmCompress);
-            dialogs = dialogService;
-        }
-
-        #region 逻辑函数
-        private void LargeQuality()
-        {
-            compressDialogModel.CompressQuality = CompressDialogModel.EnumQualityLevel.StatusLarge;
-            CompressLargeStyle = Visibility.Visible;
-            CompressStandardStyle = Visibility.Hidden;
-            CompressLittleStyle = Visibility.Hidden;
-            CompressMicroStyle = Visibility.Hidden;
-        }
-        private void StandardQuality()
-        {
-            compressDialogModel.CompressQuality = CompressDialogModel.EnumQualityLevel.StatusStandard;
-            CompressLargeStyle = Visibility.Hidden;
-            CompressStandardStyle = Visibility.Visible;
-            CompressLittleStyle = Visibility.Hidden;
-            CompressMicroStyle = Visibility.Hidden;
-        }
-        private void LittleQuality()
-        {
-            compressDialogModel.CompressQuality = CompressDialogModel.EnumQualityLevel.StatusLittle;
-            CompressLargeStyle = Visibility.Hidden;
-            CompressStandardStyle = Visibility.Hidden;
-            CompressLittleStyle = Visibility.Visible;
-            CompressMicroStyle = Visibility.Hidden;
-        }
-        private void MicroQuality()
-        {
-            compressDialogModel.CompressQuality = CompressDialogModel.EnumQualityLevel.StatusMicro;
-            CompressLargeStyle = Visibility.Hidden;
-            CompressStandardStyle = Visibility.Hidden;
-            CompressLittleStyle = Visibility.Hidden;
-            CompressMicroStyle = Visibility.Visible;
-        }
-
-        private void ConfirmCompress()
-        {
-            RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
-        }
-
-        private int GetIndex(int pageindex)
-        {
-            Trace.WriteLine(pageindex);
-            return 0;
-        }
-        private void Compress()
-        {
-
-            FolderBrowserDialog folderDialog = new FolderBrowserDialog();
-            System.Windows.Forms.SaveFileDialog sfd = new System.Windows.Forms.SaveFileDialog();
-            /*
-             *设置这个对话框的起始保存路径
-             */
-            sfd.InitialDirectory = document.FilePath;
-            /*
-             *设置保存的文件的类型,注意过滤器的语法 例子:“文件类型|*.后缀名;*.后缀名;”
-             */
-            sfd.Filter = "PDF|*.pdf;";
-            /*
-             *调用ShowDialog()方法显示该对话框,该方法的返回值代表用户是否点击了确定按钮
-             **/
-            sfd.FileName = document.FileName + "_CompressFile.pdf";
-
-            if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
-            {
-                /*
-                 * 做一些工作
-                 */
-
-                Trace.WriteLine("compressDialogModel.CompressQuality:  " + compressDialogModel.CompressQuality);
-                DialogParameters value = new DialogParameters();
-                value.Add(ParameterNames.PDFDocument, document);
-                value.Add(ParameterNames.PassWord, pdfviewer.Tag);
-                value.Add(ParameterNames.FilePath, sfd.FileName);
-                value.Add("compressDialogModel.CompressQuality", (int)compressDialogModel.CompressQuality);
-                RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
-                dialogs.ShowDialog(DialogNames.CompressProgressBarDialog, value, e =>
-                {
-
-                });
-            }
-            else
-            {
-                MessageBox.Show("Cancel.");
-            }
-        }
-        #endregion
-
-        #region 框架行为
-        public string Title => "";
-
-        public event Action<IDialogResult> RequestClose;
-
-        public bool CanCloseDialog()
-        {
-            return true;
-        }
-
-        public void OnDialogClosed()
-        {
-        }
-
-        public void OnDialogOpened(IDialogParameters parameters)
-        {
-            parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out pdfviewer);
-            if (pdfviewer != null)
-            {
-                CompressDialogModel compressdialogmodel = new CompressDialogModel();
-                document = pdfviewer.Document;
-                compressDialogModel = compressdialogmodel;
-                compressDialogModel.CompressQuality = CompressDialogModel.EnumQualityLevel.StatusDefault;
-            }
-        }
-        #endregion
-    }
-}
+namespace PDF_Office.ViewModels.Dialog.ToolsDialogs.CompressDialogs
+{
+    public class CompressDialogViewModel : BindableBase, IDialogAware
+    {
+        #region 参数和属性
+        private CompressDialogModel compressDialogModel;
+        private IntPtr compressingIntpr = IntPtr.Zero;
+        private CPDFDocument document;
+        private CPDFViewer pdfviewer;
+        private Visibility _compressLargeStyle = Visibility.Hidden;
+        public IDialogService dialogs;
+
+        public Visibility CompressLargeStyle
+        {
+            get { return _compressLargeStyle; }
+            set
+            {
+                SetProperty(ref _compressLargeStyle, value);
+            }
+        }
+
+        private Visibility _compressStandardStyle = Visibility.Hidden;
+        public Visibility CompressStandardStyle
+        {
+            get { return _compressStandardStyle; }
+            set
+            {
+                SetProperty(ref _compressStandardStyle, value);
+            }
+        }
+        private Visibility _compressLittleStyle = Visibility.Visible;
+        public Visibility CompressLittleStyle
+        {
+            get { return _compressLittleStyle; }
+            set
+            {
+                SetProperty(ref _compressLittleStyle, value);
+            }
+        }
+        private Visibility _compressMicroStyle = Visibility.Hidden;
+        public Visibility CompressMicroStyle
+        {
+            get { return _compressMicroStyle; }
+            set
+            {
+                SetProperty(ref _compressMicroStyle, value);
+            }
+        }
+        #endregion
+
+        #region 委托声明
+        public DelegateCommand LargeQualityCommand { get; set; }
+
+        public DelegateCommand StandardQualityCommand { get; set; }
+
+        public DelegateCommand LittleQualityCommand { get; set; }
+
+        public DelegateCommand MicroQualityCommand { get; set; }
+
+        public DelegateCommand CompressCommand { get; set; }
+
+        public DelegateCommand ConfirmCompressCommand { get; set; }
+        #endregion
+
+        public CompressDialogViewModel(IDialogService dialogService)
+        {
+            LargeQualityCommand = new DelegateCommand(LargeQuality);
+            StandardQualityCommand = new DelegateCommand(StandardQuality);
+            LittleQualityCommand = new DelegateCommand(LittleQuality);
+            MicroQualityCommand = new DelegateCommand(MicroQuality);
+            CompressCommand = new DelegateCommand(Compress);
+            ConfirmCompressCommand = new DelegateCommand(ConfirmCompress);
+            dialogs = dialogService;
+        }
+
+        #region 逻辑函数
+        private void LargeQuality()
+        {
+            compressDialogModel.CompressQuality = CompressDialogModel.EnumQualityLevel.StatusLarge;
+            CompressLargeStyle = Visibility.Visible;
+            CompressStandardStyle = Visibility.Hidden;
+            CompressLittleStyle = Visibility.Hidden;
+            CompressMicroStyle = Visibility.Hidden;
+        }
+        private void StandardQuality()
+        {
+            compressDialogModel.CompressQuality = CompressDialogModel.EnumQualityLevel.StatusStandard;
+            CompressLargeStyle = Visibility.Hidden;
+            CompressStandardStyle = Visibility.Visible;
+            CompressLittleStyle = Visibility.Hidden;
+            CompressMicroStyle = Visibility.Hidden;
+        }
+        private void LittleQuality()
+        {
+            compressDialogModel.CompressQuality = CompressDialogModel.EnumQualityLevel.StatusLittle;
+            CompressLargeStyle = Visibility.Hidden;
+            CompressStandardStyle = Visibility.Hidden;
+            CompressLittleStyle = Visibility.Visible;
+            CompressMicroStyle = Visibility.Hidden;
+        }
+        private void MicroQuality()
+        {
+            compressDialogModel.CompressQuality = CompressDialogModel.EnumQualityLevel.StatusMicro;
+            CompressLargeStyle = Visibility.Hidden;
+            CompressStandardStyle = Visibility.Hidden;
+            CompressLittleStyle = Visibility.Hidden;
+            CompressMicroStyle = Visibility.Visible;
+        }
+
+        private void ConfirmCompress()
+        {
+            RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
+        }
+
+        private int GetIndex(int pageindex)
+        {
+            Trace.WriteLine(pageindex);
+            return 0;
+        }
+        private void Compress()
+        {
+
+            FolderBrowserDialog folderDialog = new FolderBrowserDialog();
+            System.Windows.Forms.SaveFileDialog sfd = new System.Windows.Forms.SaveFileDialog();
+            /*
+             *设置这个对话框的起始保存路径
+             */
+            sfd.InitialDirectory = document.FilePath;
+            /*
+             *设置保存的文件的类型,注意过滤器的语法 例子:“文件类型|*.后缀名;*.后缀名;”
+             */
+            sfd.Filter = "PDF|*.pdf;";
+            /*
+             *调用ShowDialog()方法显示该对话框,该方法的返回值代表用户是否点击了确定按钮
+             **/
+            sfd.FileName = document.FileName + "_CompressFile.pdf";
+
+            if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+            {
+                /*
+                 * 做一些工作
+                 */
+
+                Trace.WriteLine("compressDialogModel.CompressQuality:  " + compressDialogModel.CompressQuality);
+                DialogParameters value = new DialogParameters();
+                value.Add(ParameterNames.PDFDocument, document);
+                value.Add(ParameterNames.PassWord, pdfviewer.Tag);
+                value.Add(ParameterNames.FilePath, sfd.FileName);
+                value.Add("compressDialogModel.CompressQuality", (int)compressDialogModel.CompressQuality);
+                RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
+                dialogs.ShowDialog(DialogNames.CompressProgressBarDialog, value, e =>
+                {
+
+                });
+            }
+            else
+            {
+                MessageBox.Show("Cancel.");
+            }
+        }
+        #endregion
+
+        #region 框架行为
+        public string Title => "";
+
+        public event Action<IDialogResult> RequestClose;
+
+        public bool CanCloseDialog()
+        {
+            return true;
+        }
+
+        public void OnDialogClosed()
+        {
+        }
+
+        public void OnDialogOpened(IDialogParameters parameters)
+        {
+            parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out pdfviewer);
+            if (pdfviewer != null)
+            {
+                CompressDialogModel compressdialogmodel = new CompressDialogModel();
+                document = pdfviewer.Document;
+                compressDialogModel = compressdialogmodel;
+                compressDialogModel.CompressQuality = CompressDialogModel.EnumQualityLevel.StatusDefault;
+            }
+        }
+        #endregion
+    }
+}

+ 100 - 98
PDF Office/ViewModels/Dialog/ToolsDialogs/CompressDialogs/CompressProgressBarDialogViewModel.cs

@@ -1,99 +1,101 @@
-using PDF_Office.Model.Dialog.ToolsDialogs;
-using ComPDFKit.PDFDocument;
-using PDF_Office.Model;
-using Prism.Mvvm;
-using Prism.Services.Dialogs;
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace PDF_Office.ViewModels.Dialog.ToolsDialogs.CompressDialogs
-{
-    public class CompresProgressBarDialogViewModel : BindableBase, IDialogAware
-    {
-        #region 参数和属性
-        private IntPtr compressingIntpr = IntPtr.Zero;
-        private CPDFDocument.GetPageIndexDelegate indexDelegate = null;
-        private CPDFDocument tempDocument;
-        private string _pageIndex = "0";
-
-        /// <value>
-        /// 当前页
-        /// </value>
-        public string PageIndex
-        {
-            get { return _pageIndex; }
-            set
-            {
-                SetProperty(ref _pageIndex, value);
-            }
-        }
-
-        private string _pageNumber = "";
-        /// <value>
-        /// 总页数
-        /// </value>
-        public string PageNumber
-        {
-            get { return _pageNumber; }
-            set
-            {
-                SetProperty(ref _pageNumber, value);
-            }
-        }
-        #endregion
-
-        #region 逻辑函数
-        private int GetIndex(int pageindex)
-        {
-            PageIndex = pageindex.ToString();
-            return 0;
-        }
-        #endregion
-
-        #region 框架行为
-        public string Title => "";
-
-        public event Action<IDialogResult> RequestClose;
-
-        public bool CanCloseDialog()
-        {
-            return true;
-        }
-
-        public void OnDialogClosed()
-        {
-            tempDocument.CompressFile_Cancel(compressingIntpr);
-        }
-
-        public async void OnDialogOpened(IDialogParameters parameters)
-        {
-            CPDFDocument doc = null;
-            string filepath = "";
-            string password = "";
-            int compressquality = 45;
-            parameters.TryGetValue<CPDFDocument>(ParameterNames.PDFDocument, out doc);
-            parameters.TryGetValue<string>(ParameterNames.FilePath, out filepath);
-            parameters.TryGetValue<string>(ParameterNames.PassWord, out password);
-            parameters.TryGetValue<int>("compressDialogModel.CompressQuality", out compressquality);
-            if (doc != null)
-            {
-                PageNumber = doc.PageCount.ToString();
+using PDF_Office.Model.Dialog.ToolsDialogs;
+using ComPDFKit.PDFDocument;
+using PDF_Office.Model;
+using Prism.Mvvm;
+using Prism.Services.Dialogs;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using PDF_Office.Helper;
+
+namespace PDF_Office.ViewModels.Dialog.ToolsDialogs.CompressDialogs
+{
+    public class CompresProgressBarDialogViewModel : BindableBase, IDialogAware
+    {
+        #region 参数和属性
+        private IntPtr compressingIntpr = IntPtr.Zero;
+        private CPDFDocument.GetPageIndexDelegate indexDelegate = null;
+        private CPDFDocument tempDocument;
+        private string _pageIndex = "0";
+
+        /// <value>
+        /// 当前页
+        /// </value>
+        public string PageIndex
+        {
+            get { return _pageIndex; }
+            set
+            {
+                SetProperty(ref _pageIndex, value);
+            }
+        }
+
+        private string _pageNumber = "";
+        /// <value>
+        /// 总页数
+        /// </value>
+        public string PageNumber
+        {
+            get { return _pageNumber; }
+            set
+            {
+                SetProperty(ref _pageNumber, value);
+            }
+        }
+        #endregion
+
+        #region 逻辑函数
+        private int GetIndex(int pageindex)
+        {
+            PageIndex = pageindex.ToString();
+            return 0;
+        }
+        #endregion
+
+        #region 框架行为
+        public string Title => "";
+
+        public event Action<IDialogResult> RequestClose;
+
+        public bool CanCloseDialog()
+        {
+            return true;
+        }
+
+        public void OnDialogClosed()
+        {
+            tempDocument.CompressFile_Cancel(compressingIntpr);
+        }
+
+        public async void OnDialogOpened(IDialogParameters parameters)
+        {
+            CPDFDocument doc = null;
+            string filepath = "";
+            string password = "";
+            int compressquality = 45;
+            parameters.TryGetValue<CPDFDocument>(ParameterNames.PDFDocument, out doc);
+            parameters.TryGetValue<string>(ParameterNames.FilePath, out filepath);
+            parameters.TryGetValue<string>(ParameterNames.PassWord, out password);
+            parameters.TryGetValue<int>("compressDialogModel.CompressQuality", out compressquality);
+            if (doc != null)
+            {
+                PageNumber = doc.PageCount.ToString();
                 CPDFDocument document = CPDFDocument.InitWithFilePath(doc.FilePath);
-                document.UnlockWithPassword(password);
-                indexDelegate += GetIndex;
-                compressingIntpr = document.CompressFile_Init(compressquality, indexDelegate);
-                //GC.KeepAlive(indexDelegate);
-                tempDocument = document;
-                Trace.WriteLine("compressDialogModel.CompressQuality" + compressquality);
-                await Task.Run<bool>(() => { return document.CompressFile_Start(compressingIntpr, filepath); });
-                RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
-                document.Release();
-            }
-        }
-        #endregion
-    }
-}
+                document.UnlockWithPassword(password);
+                indexDelegate += GetIndex;
+                compressingIntpr = document.CompressFile_Init(compressquality, indexDelegate);
+                //GC.KeepAlive(indexDelegate);
+                tempDocument = document;
+                Trace.WriteLine("compressDialogModel.CompressQuality" + compressquality);
+                await Task.Run<bool>(() => { return document.CompressFile_Start(compressingIntpr, filepath); });
+                CommonHelper.ShowFileBrowser(filepath);
+                RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
+                document.Release();
+            }
+        }
+        #endregion
+    }
+}

+ 29 - 1
PDF Office/ViewModels/HomePanel/PDFTools/QuickToolsContentViewModel.cs

@@ -115,6 +115,7 @@ namespace PDF_Office.ViewModels.HomePanel.PDFTools
                     case PDFFnType.Split:
 
                         viewer.InitDocument(dlg.FileName);
+                        CheckPassword(viewer);
                         DialogParameters splitvalue = new DialogParameters();
                         splitvalue.Add(ParameterNames.PDFViewer, viewer);
                         splitvalue.Add(ParameterNames.FilePath, dlg.FileName);
@@ -123,6 +124,7 @@ namespace PDF_Office.ViewModels.HomePanel.PDFTools
 
                     case PDFFnType.Extract:
                         viewer.InitDocument(dlg.FileName);
+                        CheckPassword(viewer);
                         DialogParameters extractvalue = new DialogParameters();
                         extractvalue.Add(ParameterNames.PDFViewer, viewer);
                         extractvalue.Add(ParameterNames.FilePath, dlg.FileName);
@@ -131,6 +133,7 @@ namespace PDF_Office.ViewModels.HomePanel.PDFTools
 
                     case PDFFnType.Insert:
                         viewer.InitDocument(dlg.FileName);
+                        CheckPassword(viewer);
                         DialogParameters insertvalue = new DialogParameters();
                         insertvalue.Add(ParameterNames.PDFViewer, viewer);
                         insertvalue.Add(ParameterNames.FilePath, dlg.FileName);
@@ -154,6 +157,7 @@ namespace PDF_Office.ViewModels.HomePanel.PDFTools
 
                     case PDFFnType.Print:
                         viewer.InitDocument(dlg.FileName);
+                        CheckPassword(viewer);
                         DialogParameters printvalue = new DialogParameters();
                         printvalue.Add(ParameterNames.PDFViewer, viewer);
                         printvalue.Add(ParameterNames.FilePath, dlg.FileName);
@@ -266,8 +270,32 @@ namespace PDF_Office.ViewModels.HomePanel.PDFTools
 
             }
         }
+        //
+        //
+        private void CheckPassword(CPDFViewer viewer) {
+            if (viewer.Document.IsLocked)
+            {
+                DialogParameters value = new DialogParameters();
+                value.Add(ParameterNames.PDFDocument, viewer.Document);
+                dialogs.ShowDialog(DialogNames.VerifyPassWordDialog, value, e =>
+                {
+                    if (e.Result == ButtonResult.OK)
+                    {
+                        if (e.Parameters.ContainsKey(ParameterNames.PassWord) && e.Parameters.GetValue<string>(ParameterNames.PassWord) != null)
+                        {
+                            viewer.Tag = e.Parameters.GetValue<string>(ParameterNames.PassWord).ToString();
+                        }
+                    }
+                });
 
-
+                if (viewer.Document.IsLocked)
+                {
+                    //未成功解密文档时,释放Document对象,返回
+                    viewer.Document.Release();
+                    return;
+                }
+            }
+        }
 
         private void Expend()
         {

+ 1 - 1
PDF Office/Views/Dialog/HomePageToolsDialogs/HomePageBatchProcessing/HomePageCompressDialog.xaml

@@ -140,7 +140,7 @@
                 <RadioButton Name="StandardQualityRadioBtn" Command="{Binding RadioButtonCommand}" CommandParameter="{Binding ElementName=StandardQualityRadioBtn,Path=Name}" Margin="0,8,0,0">
                     <TextBlock Text="标准文件" FontSize="14" Height="22" Width="87" TextBlock.Foreground="#252629"/>
                 </RadioButton>
-                <RadioButton Name="LittleQualityRadioBtn" Command="{Binding RadioButtonCommand}" CommandParameter="{Binding ElementName=LittleQualityRadioBtn,Path=Name}" Margin="0,8,0,0">
+                <RadioButton Name="LittleQualityRadioBtn" Command="{Binding RadioButtonCommand}" CommandParameter="{Binding ElementName=LittleQualityRadioBtn,Path=Name}" Margin="0,8,0,0" IsChecked="True">
                     <TextBlock Text="小型文件" FontSize="14" Height="22" Width="87" TextBlock.Foreground="#252629"/>
                 </RadioButton>
                 <RadioButton Name="MicroQualityRadioBtn" Command="{Binding RadioButtonCommand}" CommandParameter="{Binding ElementName=MicroQualityRadioBtn,Path=Name}" Margin="0,8,0,0">

二进制
PDF Office/x64/ComPDFKit.dll