Przeglądaj źródła

其他 - 替换PDF文档信息控件和大纲控件

liyuxuan 1 rok temu
rodzic
commit
e6a691eb78

+ 13 - 5
Demo/Examples/Compdfkit_Tools/PDFView/PDFInfo/CPDFAbstractInfoControl.xaml.cs

@@ -1,17 +1,25 @@
 using ComPDFKit.PDFDocument;
 using Compdfkit_Tools.Helper;
-using ComPDFKitViewer.PdfViewer;
+using ComPDFKitViewer;
 using System.Windows.Controls;
 
 namespace Compdfkit_Tools.PDFControl
 {
     public partial class CPDFAbstractInfoControl : UserControl
     {
-        public CPDFViewer pdfViewer;
-        public void InitWithPDFViewer(CPDFViewer pdfViewer)
+        public PDFViewControl ViewControl;
+        public void InitWithPDFViewer(PDFViewControl viewControl)
         {
-            this.pdfViewer = pdfViewer;
-            InitializeAbstractInfo(pdfViewer.Document);
+            this.ViewControl = viewControl;
+            if(viewControl!=null && viewControl.PDFViewTool != null)
+            {
+                CPDFViewer pdfViewer=viewControl.PDFViewTool.GetCPDFViewer();
+                CPDFDocument pdfDoc=pdfViewer?.GetDocument();
+                if(pdfDoc!=null)
+                {
+                    InitializeAbstractInfo(pdfDoc);
+                }
+            }
         }
 
         public CPDFAbstractInfoControl()

+ 13 - 6
Demo/Examples/Compdfkit_Tools/PDFView/PDFInfo/CPDFCreateInfoControl.xaml.cs

@@ -1,6 +1,5 @@
 using ComPDFKit.PDFDocument;
-using Compdfkit_Tools.Helper;
-using ComPDFKitViewer.PdfViewer;
+using ComPDFKitViewer;
 using System;
 using System.Text.RegularExpressions;
 using System.Windows.Controls;
@@ -9,11 +8,19 @@ namespace Compdfkit_Tools.PDFControl
 {
     public partial class CPDFCreateInfoControl : UserControl
     {
-        public CPDFViewer pdfViewer;
-        public void InitWithPDFViewer(CPDFViewer pdfViewer)
+        public PDFViewControl ViewControl;
+        public void InitWithPDFViewer(PDFViewControl viewControl)
         {
-            this.pdfViewer = pdfViewer;
-            InitializeCreateInfo(pdfViewer.Document);
+            this.ViewControl = viewControl;
+            if(viewControl!=null && viewControl.PDFViewTool != null)
+            {
+                CPDFViewer pdfViewer=viewControl.PDFViewTool.GetCPDFViewer();
+                CPDFDocument pdfDoc=pdfViewer.GetDocument();
+                if(pdfDoc!=null)
+                {
+                    InitializeCreateInfo(pdfDoc);
+                }    
+            }
         }
 
 

+ 7 - 8
Demo/Examples/Compdfkit_Tools/PDFView/PDFInfo/CPDFInfoControl.xaml.cs

@@ -1,12 +1,11 @@
-using ComPDFKitViewer.PdfViewer;
-using System;
+using System;
 using System.Windows.Controls;
 
 namespace Compdfkit_Tools.PDFControl
 {
     public partial class CPDFInfoControl : UserControl
     {
-        public CPDFViewer pdfViewer;
+        public PDFViewControl ViewControl;
 
         public event EventHandler CloseInfoEvent;
 
@@ -16,12 +15,12 @@ namespace Compdfkit_Tools.PDFControl
 
         }
 
-        public void InitWithPDFViewer(CPDFViewer pdfViewer)
+        public void InitWithPDFViewer(PDFViewControl viewControl)
         {
-            this.pdfViewer = pdfViewer;
-            CPDFAbstractInfoControl.InitWithPDFViewer(pdfViewer);
-            CPDFCreateInfoControl.InitWithPDFViewer(pdfViewer);
-            CPDFSecurityInfoControl.InitWithPDFViewer(pdfViewer);
+            this.ViewControl = viewControl;
+            CPDFAbstractInfoControl.InitWithPDFViewer(viewControl);
+            CPDFCreateInfoControl.InitWithPDFViewer(viewControl);
+            CPDFSecurityInfoControl.InitWithPDFViewer(viewControl);
         }
         private void CloseInfoButton_Click(object sender, System.Windows.RoutedEventArgs e)
         {

+ 13 - 5
Demo/Examples/Compdfkit_Tools/PDFView/PDFInfo/CPDFSecurityInfoControl.xaml.cs

@@ -1,5 +1,5 @@
 using ComPDFKit.PDFDocument;
-using ComPDFKitViewer.PdfViewer;
+using ComPDFKitViewer;
 using System.Windows.Controls;
 
 namespace Compdfkit_Tools.PDFControl
@@ -9,11 +9,19 @@ namespace Compdfkit_Tools.PDFControl
         private string T_Allowed = "Allowed";
         private string T_NotAllowed = "Not Allowed";
 
-        public CPDFViewer pdfViewer;
-        public void InitWithPDFViewer(CPDFViewer pdfViewer)
+        public PDFViewControl ViewControl;
+        public void InitWithPDFViewer(PDFViewControl viewControl)
         {
-            this.pdfViewer = pdfViewer;
-            InitializeSecurityInfo(pdfViewer.Document);
+            this.ViewControl = viewControl;
+            if(viewControl!=null && viewControl.PDFViewTool != null )
+            {
+                CPDFViewer pdfViewer=viewControl.PDFViewTool.GetCPDFViewer();
+                CPDFDocument pdfDoc=pdfViewer?.GetDocument();
+                if(pdfDoc!=null)
+                {
+                    InitializeSecurityInfo(pdfDoc);
+                }
+            }
         }
 
 

+ 37 - 14
Demo/Examples/Compdfkit_Tools/PDFView/PDFOutline/PDFOutlineControl/CPDFOutlineControl.xaml.cs

@@ -1,18 +1,21 @@
 using ComPDFKit.PDFDocument;
 using ComPDFKit.PDFDocument.Action;
+using ComPDFKit.Tool;
 using Compdfkit_Tools.PDFControlUI;
-using ComPDFKitViewer.PdfViewer;
+using ComPDFKitViewer;
 using System;
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
+using System.Diagnostics;
 using System.Windows;
 using System.Windows.Controls;
+using System.Xml.Linq;
 
 namespace Compdfkit_Tools.PDFControl
 {
     public partial class CPDFOutlineControl : UserControl
     {
-        CPDFViewer pdfViewer;
+        PDFViewControl ViewControl;
         public ObservableCollection<CPDFOutlineNode> OutlineList
         {
             set; get;
@@ -39,14 +42,16 @@ namespace Compdfkit_Tools.PDFControl
                 CPDFAction action = outline.GetAction();
                 if (action != null && action.ActionType != C_ACTION_TYPE.ACTION_TYPE_UNKNOWN)
                 {
-                    pdfViewer.ProcessAction(action);
+                    ViewControl.PDFViewTool.ActionProcess(action);
                 }
                 else
                 {
-                    CPDFDestination dest = outline.GetDestination(pdfViewer.Document);
+                    CPDFViewer pdfViewer = ViewControl.PDFViewTool.GetCPDFViewer();
+                    CPDFDocument pdfDoc = pdfViewer.GetDocument();
+                    CPDFDestination dest = outline.GetDestination(pdfDoc);
                     if (dest != null)
                     {
-                        pdfViewer.GoToPage(dest.PageIndex);
+                        pdfViewer.GoToPage(dest.PageIndex, new Point(dest.Position_X, dest.Position_Y));
                     }
                 }
             }
@@ -124,24 +129,42 @@ namespace Compdfkit_Tools.PDFControl
         public ObservableCollection<CPDFOutlineNode> GetOutlineViewDataSource()
         {
             ObservableCollection<CPDFOutlineNode> data = new ObservableCollection<CPDFOutlineNode>();
-            List<CPDFOutline> datasource = pdfViewer.Document.GetOutlineList();
-            foreach (CPDFOutline item in datasource)
+            if (ViewControl == null && ViewControl.PDFViewTool == null)
             {
+                return data;
+            }
 
-                CPDFOutlineNode dto = ConvertCPDFToOutlineNode(item, null);
-                if (dto != null)
+            CPDFViewer pdfViewer = ViewControl.PDFViewTool.GetCPDFViewer();
+            CPDFDocument pdfDoc = pdfViewer?.GetDocument();
+            if(pdfDoc!=null)
+            {
+                List<CPDFOutline> datasource = pdfDoc.GetOutlineList();
+                foreach (CPDFOutline item in datasource)
                 {
-                    data.Add(dto);
+                    CPDFOutlineNode dto = ConvertCPDFToOutlineNode(item, null);
+                    if (dto != null)
+                    {
+                        data.Add(dto);
+                    }
                 }
             }
+           
             return data;
         }
 
-        public void InitWithPDFViewer(CPDFViewer pdfViewer)
+        public void InitWithPDFViewer(PDFViewControl viewControl)
         {
-            this.pdfViewer = pdfViewer;
-            List<CPDFOutline> outlineList = pdfViewer.Document.GetOutlineList();
-            CPDFOutlineUI.SetOutlineTree(outlineList);
+            this.ViewControl = viewControl;
+            if(ViewControl != null && viewControl.PDFViewTool!=null)
+            {
+                CPDFViewer pdfViewer = viewControl.PDFViewTool.GetCPDFViewer();
+                CPDFDocument pdfDoc=pdfViewer?.GetDocument();
+                if(pdfDoc!=null)
+                {
+                    List<CPDFOutline> outlineList = pdfDoc.GetOutlineList();
+                    CPDFOutlineUI.SetOutlineTree(outlineList);
+                }
+            }
         }
     }
 }