浏览代码

Merge branch 'dev' of http://git.kdan.cc:8865/Windows/PDFOffice_Windows_exe into dev

ZhouJieSheng 1 年之前
父节点
当前提交
d8121703b0

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

@@ -1,9 +1,11 @@
 using ComPDFKit.PDFDocument;
 using Microsoft.Office.Interop.Word;
+using PDF_Master.CustomControl;
 using PDF_Master.Helper;
 using System;
 using System.Collections.Generic;
 using System.Diagnostics;
+using System.IO;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
@@ -54,6 +56,13 @@ namespace PDF_Master.Model.Dialog.ToolsDialogs
                 int compressquality = 45;
                 doc = e.Parameters.GetValue<CPDFDocument>(ParameterNames.PDFDocument);
                 filepath = e.Parameters.GetValue<string>(ParameterNames.FilePath);
+                try { if (File.Exists(filepath)) File.Delete(filepath); }
+                catch
+                {
+                    AlertsMessage alertsMessage = new AlertsMessage();
+                    alertsMessage.ShowDialog("", App.MainPageLoader.GetString("FileNotExistWarning"), App.ServiceLoader.GetString("Text_ok"));
+                    return;
+                }
                 password = e.Parameters.GetValue<string>(ParameterNames.PassWord);
                 compressquality = e.Parameters.GetValue<int>("compressDialogModel.CompressQuality");
                 if (doc != null)
@@ -71,12 +80,16 @@ namespace PDF_Master.Model.Dialog.ToolsDialogs
                     tempDocument = document;
                     Trace.WriteLine("compressDialogModel.CompressQuality" + compressquality);
                     App.mainWindowViewModel.ProcessCloseAction = CompressClear;
-                    if (await Task.Run<bool>(() => { return document.CompressFile_Start(compressingIntpr, filepath); })) { CommonHelper.ShowFileBrowser(filepath);  }
+                    if (await Task.Run<bool>(() => { return document.CompressFile_Start(compressingIntpr, filepath); })) {
+                        CommonHelper.ShowFileBrowser(filepath); 
+                    }
 
                     document.Release();
                 }
             }
             catch {
+                AlertsMessage alertsMessage = new AlertsMessage();
+                alertsMessage.ShowDialog("", "Compress file error", App.ServiceLoader.GetString("Text_ok"));
                 tempDocument.CompressFile_Cancel(compressingIntpr);
                 App.mainWindowViewModel.IsProcessVisible = System.Windows.Visibility.Collapsed;
             }

+ 14 - 7
PDF Office/ViewModels/Tools/AnnotToolContentViewModel.Command.cs

@@ -2,6 +2,7 @@
 using ComPDFKit.PDFAnnotation;
 using ComPDFKit.PDFDocument;
 using ComPDFKit.PDFDocument.Action;
+using ComPDFKit.PDFPage;
 using ComPDFKitViewer;
 using ComPDFKitViewer.AnnotEvent;
 using ComPDFKitViewer.PdfViewer;
@@ -230,9 +231,17 @@ namespace PDF_Master.ViewModels.Tools
                         CPDFGoToAction gotoAction = action as CPDFGoToAction;
                         CPDFDestination dest = gotoAction.GetDestination(PDFViewer.Document);
                         if (dest != null)
-                        {
-                            PDFViewer.GoToPage(dest.PageIndex, new System.Windows.Point(0, 0));
-                        }
+                        {
+                            CPDFPage docPage = PDFViewer.Document.PageAtIndex(dest.PageIndex, false);
+                            if (docPage != null)
+                            {
+                                PDFViewer.GoToPage(dest.PageIndex, new System.Windows.Point(dest.Position_X, docPage.PageSize.Height - dest.Position_Y));
+                            }
+                            else
+                            {
+                                PDFViewer.GoToPage(dest.PageIndex, new System.Windows.Point(dest.Position_X, dest.Position_Y));
+                            }
+                        }
                     }
                     break;
 
@@ -757,8 +766,6 @@ namespace PDF_Master.ViewModels.Tools
             PropertyPanel.annotlists = null;
         }
 
-
-
         /// <summary>
         /// 注释列表同步选中
         /// </summary>
@@ -1810,10 +1817,10 @@ namespace PDF_Master.ViewModels.Tools
                             //创建注释后,修改注释属性,可用于下次创建的注释
                             if (PropertyPanel != null && PropertyPanel.annot != null && PDFViewer.MouseMode == MouseModes.AnnotCreate)
                             {
-                                if (StrAnnotToolChecked == "Rect" )
+                                if (StrAnnotToolChecked == "Rect")
                                 {
                                     if (PropertyPanel.SharpsAnnot == key.Key || (PropertyPanel.SharpsAnnot != key.Key && key.Key == "Arrow"))
-                                    PDFViewer.SetToolParam(PropertyPanel.annot);
+                                        PDFViewer.SetToolParam(PropertyPanel.annot);
                                     PropertyPanel.SaveLastAnnot();
                                 }
                             }