|
@@ -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);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|