|
@@ -1,11 +1,12 @@
|
|
|
using ComPDFKit.PDFDocument;
|
|
|
using Compdfkit_Tools.PDFControlUI;
|
|
|
-using ComPDFKitViewer.PdfViewer;
|
|
|
+using ComPDFKitViewer;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Windows;
|
|
|
using System.Windows.Controls;
|
|
|
+using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel;
|
|
|
|
|
|
namespace Compdfkit_Tools.PDFControl
|
|
|
{
|
|
@@ -14,7 +15,7 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
/// <summary>
|
|
|
/// PDFViewer
|
|
|
/// </summary>
|
|
|
- private CPDFViewer pdfView;
|
|
|
+ private PDFViewControl ViewControl;
|
|
|
|
|
|
public CPDFBookmarkControl()
|
|
|
{
|
|
@@ -40,12 +41,16 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
|
|
|
private void BookmarkAddUI_BookmarkInputExpandEvent(object sender, EventArgs e)
|
|
|
{
|
|
|
- if(pdfView!=null)
|
|
|
+ if(ViewControl!=null && ViewControl.PDFViewTool!=null)
|
|
|
{
|
|
|
- BookmarkAddUI.SetBookmarkChangeData(new BookmarkChangeData()
|
|
|
+ CPDFViewer pdfViewer=ViewControl.PDFViewTool.GetCPDFViewer();
|
|
|
+ if(pdfViewer!=null && pdfViewer.CurrentRenderFrame!=null)
|
|
|
{
|
|
|
- PageIndex=pdfView.CurrentIndex
|
|
|
- });
|
|
|
+ BookmarkAddUI.SetBookmarkChangeData(new BookmarkChangeData()
|
|
|
+ {
|
|
|
+ PageIndex = pdfViewer.CurrentRenderFrame.PageIndex,
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -56,12 +61,15 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
|
|
|
private void BookmarkResultUI_BookmarkDelete(object sender, BookmarkChangeData e)
|
|
|
{
|
|
|
- if (pdfView == null || pdfView.Document == null)
|
|
|
+ if(ViewControl!=null && ViewControl.PDFViewTool!=null)
|
|
|
{
|
|
|
- return;
|
|
|
+ CPDFViewer pdfViewer = ViewControl.PDFViewTool.GetCPDFViewer();
|
|
|
+ CPDFDocument pdfDoc = pdfViewer?.GetDocument();
|
|
|
+ if(pdfDoc!=null)
|
|
|
+ {
|
|
|
+ pdfDoc.RemoveBookmark(e.PageIndex);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- pdfView.Document.RemoveBookmark(e.PageIndex);
|
|
|
}
|
|
|
|
|
|
private void BookmarkResultUI_SelectionChanged(object sender, int e)
|
|
@@ -78,16 +86,22 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
|
|
|
private void BookmarkAddUI_BookmarkAddEvent(object sender, BookmarkChangeData newData)
|
|
|
{
|
|
|
- if (pdfView == null || pdfView.Document == null || newData==null)
|
|
|
+ CPDFDocument pdfDoc = null;
|
|
|
+ if (ViewControl != null && ViewControl.PDFViewTool != null)
|
|
|
+ {
|
|
|
+ CPDFViewer pdfViewer = ViewControl.PDFViewTool.GetCPDFViewer();
|
|
|
+ pdfDoc = pdfViewer?.GetDocument();
|
|
|
+
|
|
|
+ }
|
|
|
+ if (pdfDoc == null || newData == null)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
- if (newData.PageIndex >= 0 && newData.PageIndex < pdfView.Document.PageCount)
|
|
|
+ if (newData.PageIndex >= 0 && newData.PageIndex < pdfDoc.PageCount)
|
|
|
{
|
|
|
if (string.IsNullOrEmpty(newData.NewTitle) == false && string.IsNullOrEmpty(newData.BookmarkTitle))
|
|
|
{
|
|
|
- bool addState = pdfView.Document.AddBookmark(new CPDFBookmark()
|
|
|
+ bool addState = pdfDoc.AddBookmark(new CPDFBookmark()
|
|
|
{
|
|
|
PageIndex = newData.PageIndex,
|
|
|
Title = newData.NewTitle
|
|
@@ -95,7 +109,6 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
if (addState)
|
|
|
{
|
|
|
LoadBookmark();
|
|
|
- pdfView.UndoManager.CanSave = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -106,12 +119,11 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
|
|
|
if (!string.IsNullOrEmpty(newData.NewTitle) && !string.IsNullOrEmpty(newData.BookmarkTitle))
|
|
|
{
|
|
|
- pdfView.Document.EditBookmark(newData.PageIndex, newData.NewTitle);
|
|
|
+ pdfDoc.EditBookmark(newData.PageIndex, newData.NewTitle);
|
|
|
BookmarkBindData bindUiData = newData.BindData as BookmarkBindData;
|
|
|
if (bindUiData != null)
|
|
|
{
|
|
|
bindUiData.BindProperty.BookmarkTitle = newData.NewTitle;
|
|
|
- pdfView.UndoManager.CanSave = true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -119,30 +131,36 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
|
|
|
private void GotoBookmarkPage(int pageIndex)
|
|
|
{
|
|
|
- if (pdfView == null || pdfView.Document == null)
|
|
|
+ if (ViewControl != null && ViewControl.PDFViewTool != null)
|
|
|
{
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (pageIndex >= 0)
|
|
|
- {
|
|
|
- pdfView.GoToPage(pageIndex);
|
|
|
+ CPDFViewer pdfViewer = ViewControl.PDFViewTool.GetCPDFViewer();
|
|
|
+ if (pageIndex >= 0)
|
|
|
+ {
|
|
|
+ pdfViewer.GoToPage(pageIndex,new Point(0,0));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void InitWithPDFViewer(CPDFViewer newPDFView)
|
|
|
+ public void InitWithPDFViewer(PDFViewControl viewControl)
|
|
|
{
|
|
|
- pdfView = newPDFView;
|
|
|
+ ViewControl = viewControl;
|
|
|
}
|
|
|
|
|
|
public void LoadBookmark()
|
|
|
{
|
|
|
- if (pdfView == null || pdfView.Document == null)
|
|
|
+ CPDFDocument pdfDoc = null;
|
|
|
+ if (ViewControl != null && ViewControl.PDFViewTool != null)
|
|
|
+ {
|
|
|
+ CPDFViewer pdfViewer = ViewControl.PDFViewTool.GetCPDFViewer();
|
|
|
+ pdfDoc = pdfViewer?.GetDocument();
|
|
|
+
|
|
|
+ }
|
|
|
+ if (pdfDoc == null)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- List<CPDFBookmark> bookmarkList = pdfView.Document.GetBookmarkList();
|
|
|
+ List<CPDFBookmark> bookmarkList = pdfDoc.GetBookmarkList();
|
|
|
List<BindBookmarkResult> bindBookmarkList = new List<BindBookmarkResult>();
|
|
|
if (bookmarkList != null && bookmarkList.Count>0)
|
|
|
{
|