Selaa lähdekoodia

测试链接定位返回问题

OYXH\oyxh 2 vuotta sitten
vanhempi
commit
edbeee00de

+ 78 - 51
PDF Office/ViewModels/PropertyPanel/AnnotPanel/LinkAnnotPropertyViewModel.cs

@@ -37,6 +37,8 @@ using ImTools;
 using PDF_Master.ViewModels.Tools.AnnotManager;
 using PDF_Master.EventAggregators;
 using DryIoc;
+using static Dropbox.Api.TeamLog.PaperDownloadFormat;
+using ComPDFKit.Import;
 
 namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
 {
@@ -819,10 +821,12 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
 
                         pdfViewer.GoToPage(historyPageIndex);
 
-                        if (string.IsNullOrEmpty(PageNumTextContent))
-                        {
-                            pdfViewer.SelectAnnotation(historyPageIndex, LinkAnnotArgs.AnnotIndex);
-                        }
+                        BackToPage(historyPageIndex, areaInfo.PageIndex);
+
+                        //if (string.IsNullOrEmpty(PageNumTextContent))
+                        //{
+                        pdfViewer.SelectAnnotation(historyPageIndex, LinkAnnotArgs.AnnotIndex);
+                        //}
 
                         BtnLocationIsChecked = false;
 
@@ -944,14 +948,14 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
         {
             int pageIndex = Convert.ToInt32(PageNumTextContent) - 1;
 
-            //注释位置
-            Rect rect = LinkAnnotArgs.GetLinkPaintArea();
-            //定位
-            paintrect = LinkAnnotArgs.GetLinkCreateArea();
-            double height = 0;
-            CPDFDocument doc = pdfViewer.Document;
-            CPDFPage docPage;
-            double zoom = pdfViewer.ZoomFactor;
+            ////注释位置
+            //Rect rect = LinkAnnotArgs.GetLinkPaintArea();
+            ////定位
+            //Rect paintrect = LinkAnnotArgs.GetLinkCreateArea();
+            //double height = 0;
+            //CPDFDocument doc = pdfViewer.Document;
+            //CPDFPage docPage;
+            //double zoom = pdfViewer.ZoomFactor;
 
             if (btnGOorBack.Tag.ToString() == "GO")
             {
@@ -962,27 +966,7 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
                 //AnnotAttribEvent?.UpdateAnnot();
 
                 //historyPageIndex = LinkAnnotArgs != null ? LinkAnnotArgs.PageIndex : backPageIndex;
-
-                docPage = doc.PageAtIndex(pageIndex, false);
-                if (!paintrect.IsEmpty)
-                {
-                    double vertical = pdfViewer.GetVerticalOffset();
-                    if (docPage.PageSize.Height / 2 < paintrect.Top)
-                    {
-                        if (historyPageIndex < pageIndex)
-                        {
-                            height = vertical + (paintrect.Bottom * zoom);
-                            pdfViewer.ScrollToVerticalOffset(height);
-                        }
-                        else
-                        {
-                            height = vertical + (paintrect.Top * zoom);
-                            pdfViewer.ScrollToVerticalOffset(height);
-                        }
-                    }
-                    //height = vertical + (paintrect.Bottom * zoom);
-                    pdfViewer.ScrollToVerticalOffset(height);
-                }
+                GoToPage(pageIndex);
 
                 ChangeBtnGOorBack("BACK", btnGOorBack);
             }
@@ -993,30 +977,73 @@ namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
                     SelectAnnotation();
                     pdfViewer.GoToPage(historyPageIndex);
 
-                    docPage = doc.PageAtIndex(historyPageIndex, false);
-                    if (!rect.IsEmpty)
-                    {
-                        double vertical = pdfViewer.GetVerticalOffset();
-                        if (docPage.PageSize.Height / 2 < rect.Top)
-                        {
-                            if (historyPageIndex < pageIndex)
-                            {
-                                height = vertical + (rect.Bottom * zoom);
-                                pdfViewer.ScrollToVerticalOffset(height);
-                            }
-                            else
-                            {
-                                height = vertical + (rect.Top * zoom);
-                                pdfViewer.ScrollToVerticalOffset(height);
-                            }
-                        }
-                    }
+                    BackToPage(historyPageIndex, pageIndex);
+
                     ChangeBtnGOorBack("GO", btnGOorBack);
                     pdfViewer.SelectAnnotation(historyPageIndex, LinkAnnotArgs.AnnotIndex);
                 }
             }
         }
 
+        private void BackToPage(int historyPageIndex, int pageIndex)
+        {
+            //注释位置
+            Rect rect = LinkAnnotArgs.GetLinkPaintArea();
+            //定位
+            Rect paintrect = LinkAnnotArgs.GetLinkCreateArea();
+            double height = 0;
+            CPDFDocument doc = pdfViewer.Document;
+            CPDFPage docPage;
+            double zoom = pdfViewer.ZoomFactor;
+            docPage = doc.PageAtIndex(historyPageIndex, false);
+            if (!rect.IsEmpty)
+            {
+                double vertical = pdfViewer.GetVerticalOffset();
+                if (docPage.PageSize.Height / 2 < rect.Top)
+                {
+                    if (historyPageIndex < pageIndex)
+                    {
+                        height = vertical + (rect.Bottom * zoom);
+                        pdfViewer.ScrollToVerticalOffset(height);
+                    }
+                    else
+                    {
+                        height = vertical + (rect.Top * zoom);
+                        pdfViewer.ScrollToVerticalOffset(height);
+                    }
+                }
+            }
+        }
+
+        private void GoToPage(int pageIndex)
+        {
+            //定位
+            paintrect = LinkAnnotArgs.GetLinkCreateArea();
+            double height = 0;
+            CPDFDocument doc = pdfViewer.Document;
+            CPDFPage docPage;
+            double zoom = pdfViewer.ZoomFactor;
+            docPage = doc.PageAtIndex(pageIndex, false);
+            if (!paintrect.IsEmpty)
+            {
+                double vertical = pdfViewer.GetVerticalOffset();
+                if (docPage.PageSize.Height / 2 < paintrect.Top)
+                {
+                    if (historyPageIndex < pageIndex)
+                    {
+                        height = vertical + (paintrect.Top * zoom);
+                        pdfViewer.ScrollToVerticalOffset(height);
+                    }
+                    else
+                    {
+                        height = vertical + (paintrect.Top * zoom);
+                        pdfViewer.ScrollToVerticalOffset(height);
+                    }
+                }
+                //height = vertical + (paintrect.Bottom * zoom);
+            }
+        }
+
         /// <summary>
         /// 选择注释
         /// </summary>