|
@@ -3,8 +3,6 @@ using Compdfkit_Tools.Data;
|
|
using Compdfkit_Tools.Helper;
|
|
using Compdfkit_Tools.Helper;
|
|
using Compdfkit_Tools.PDFControl;
|
|
using Compdfkit_Tools.PDFControl;
|
|
using ComPDFKitViewer;
|
|
using ComPDFKitViewer;
|
|
-using ComPDFKitViewer.AnnotEvent;
|
|
|
|
-using ComPDFKitViewer.PdfViewer;
|
|
|
|
using Microsoft.Win32;
|
|
using Microsoft.Win32;
|
|
using System;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
@@ -21,6 +19,7 @@ using System.Windows.Controls.Primitives;
|
|
using System.Windows.Input;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Media.Imaging;
|
|
using Compdfkit_Tools.PDFView;
|
|
using Compdfkit_Tools.PDFView;
|
|
|
|
+using ComPDFKit.Tool;
|
|
|
|
|
|
namespace AnnotationViewControl
|
|
namespace AnnotationViewControl
|
|
{
|
|
{
|
|
@@ -100,50 +99,60 @@ namespace AnnotationViewControl
|
|
private void LoadDefaultDocument()
|
|
private void LoadDefaultDocument()
|
|
{
|
|
{
|
|
string defaultFilePath = "ComPDFKit_Annotations_Sample_File.pdf";
|
|
string defaultFilePath = "ComPDFKit_Annotations_Sample_File.pdf";
|
|
- pdfViewer.PDFView.InitDocument(defaultFilePath);
|
|
|
|
|
|
+ pdfViewer.InitDocument(defaultFilePath);
|
|
LoadDocument();
|
|
LoadDocument();
|
|
}
|
|
}
|
|
|
|
|
|
private void LoadDocument()
|
|
private void LoadDocument()
|
|
{
|
|
{
|
|
- pdfViewer.PDFView.Load();
|
|
|
|
- pdfViewer.PDFView.SetShowLink(true);
|
|
|
|
-
|
|
|
|
- pdfViewer.PDFView.InfoChanged -= PdfViewer_InfoChanged;
|
|
|
|
- pdfViewer.PDFView.InfoChanged += PdfViewer_InfoChanged;
|
|
|
|
- PDFGrid.Child = annotationControl;
|
|
|
|
-
|
|
|
|
- annotationControl.PDFViewControl = pdfViewer;
|
|
|
|
- annotationControl.InitWithPDFViewer(pdfViewer.PDFView);
|
|
|
|
- annotationControl.ClearAllToolState();
|
|
|
|
- annotationControl.ExpandRightPropertyPanel(null, Visibility.Collapsed);
|
|
|
|
-
|
|
|
|
- annotationControl.OnCanSaveChanged -= AnnotationControl_OnCanSaveChanged;
|
|
|
|
- annotationControl.OnCanSaveChanged += AnnotationControl_OnCanSaveChanged;
|
|
|
|
- annotationControl.OnAnnotEditHandler -= PdfAnnotationControl_RefreshAnnotList;
|
|
|
|
- annotationControl.OnAnnotEditHandler += PdfAnnotationControl_RefreshAnnotList;
|
|
|
|
-
|
|
|
|
- annotationControl.PDFViewControl.PDFView.SetFormFieldHighlight(true);
|
|
|
|
- PasswordUI.Closed -= PasswordUI_Closed;
|
|
|
|
- PasswordUI.Canceled -= PasswordUI_Canceled;
|
|
|
|
- PasswordUI.Confirmed -= PasswordUI_Confirmed;
|
|
|
|
- PasswordUI.Closed += PasswordUI_Closed;
|
|
|
|
- PasswordUI.Canceled += PasswordUI_Canceled;
|
|
|
|
- PasswordUI.Confirmed += PasswordUI_Confirmed;
|
|
|
|
- ModeComboBox.SelectedIndex = 1;
|
|
|
|
- annotationControl.PDFViewControl.PDFView.ChangeFitMode(FitMode.FitWidth);
|
|
|
|
- CPDFSaclingControl.InitWithPDFViewer(annotationControl.PDFViewControl.PDFView);
|
|
|
|
- CPDFSaclingControl.SetZoomTextBoxText(string.Format("{0}", (int)(annotationControl.PDFViewControl.PDFView.ZoomFactor * 100)));
|
|
|
|
-
|
|
|
|
- ViewSettingBtn.IsChecked = false;
|
|
|
|
- botaBarControl.InitWithPDFViewer(annotationControl.PDFViewControl.PDFView);
|
|
|
|
- botaBarControl.AddBOTAContent(new []{BOTATools.Thumbnail , BOTATools.Outline , BOTATools.Bookmark , BOTATools.Annotation , BOTATools.Search});
|
|
|
|
- botaBarControl.SelectBotaTool(BOTATools.Thumbnail);
|
|
|
|
- annotationControl.SetBOTAContainer(botaBarControl);
|
|
|
|
- annotationControl.InitialPDFViewControl(annotationControl.PDFViewControl);
|
|
|
|
-
|
|
|
|
- panelState.PropertyChanged -= PanelState_PropertyChanged;
|
|
|
|
- panelState.PropertyChanged += PanelState_PropertyChanged;
|
|
|
|
|
|
+ if (pdfViewer != null && pdfViewer.PDFViewTool != null)
|
|
|
|
+ {
|
|
|
|
+ CPDFViewer viewer = pdfViewer.PDFViewTool.GetCPDFViewer();
|
|
|
|
+ CPDFDocument pdfDoc = viewer?.GetDocument();
|
|
|
|
+ if (pdfDoc == null)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //pdfViewer.PDFView.InfoChanged -= PdfViewer_InfoChanged;
|
|
|
|
+ //pdfViewer.PDFView.InfoChanged += PdfViewer_InfoChanged;
|
|
|
|
+ PDFGrid.Child = annotationControl;
|
|
|
|
+
|
|
|
|
+ annotationControl.PDFViewControl = pdfViewer;
|
|
|
|
+ regularViewerControl.PdfViewControl = pdfViewer;
|
|
|
|
+ annotationControl.InitWithPDFViewer(pdfViewer);
|
|
|
|
+ annotationControl.ClearAllToolState();
|
|
|
|
+ annotationControl.ExpandRightPropertyPanel(null, Visibility.Collapsed);
|
|
|
|
+
|
|
|
|
+ annotationControl.OnCanSaveChanged -= AnnotationControl_OnCanSaveChanged;
|
|
|
|
+ annotationControl.OnCanSaveChanged += AnnotationControl_OnCanSaveChanged;
|
|
|
|
+ annotationControl.OnAnnotEditHandler -= PdfAnnotationControl_RefreshAnnotList;
|
|
|
|
+ annotationControl.OnAnnotEditHandler += PdfAnnotationControl_RefreshAnnotList;
|
|
|
|
+
|
|
|
|
+ //annotationControl.PDFViewControl.PDFView.SetFormFieldHighlight(true);
|
|
|
|
+ PasswordUI.Closed -= PasswordUI_Closed;
|
|
|
|
+ PasswordUI.Canceled -= PasswordUI_Canceled;
|
|
|
|
+ PasswordUI.Confirmed -= PasswordUI_Confirmed;
|
|
|
|
+ PasswordUI.Closed += PasswordUI_Closed;
|
|
|
|
+ PasswordUI.Canceled += PasswordUI_Canceled;
|
|
|
|
+ PasswordUI.Confirmed += PasswordUI_Confirmed;
|
|
|
|
+ ModeComboBox.SelectedIndex = 1;
|
|
|
|
+ //annotationControl.PDFViewControl.PDFView.ChangeFitMode(FitMode.FitWidth);
|
|
|
|
+ CPDFSaclingControl.InitWithPDFViewer(annotationControl.PDFViewControl);
|
|
|
|
+ //CPDFSaclingControl.SetZoomTextBoxText(string.Format("{0}", (int)(annotationControl.PDFViewControl.PDFView.ZoomFactor * 100)));
|
|
|
|
+
|
|
|
|
+ ViewSettingBtn.IsChecked = false;
|
|
|
|
+ botaBarControl.InitWithPDFViewer(annotationControl.PDFViewControl);
|
|
|
|
+ botaBarControl.AddBOTAContent(new[]
|
|
|
|
+ {
|
|
|
|
+ BOTATools.Thumbnail, BOTATools.Outline, BOTATools.Bookmark, BOTATools.Annotation, BOTATools.Search
|
|
|
|
+ });
|
|
|
|
+ botaBarControl.SelectBotaTool(BOTATools.Thumbnail);
|
|
|
|
+ annotationControl.SetBOTAContainer(botaBarControl);
|
|
|
|
+ annotationControl.InitialPDFViewControl(annotationControl.PDFViewControl);
|
|
|
|
+ panelState.PropertyChanged -= PanelState_PropertyChanged;
|
|
|
|
+ panelState.PropertyChanged += PanelState_PropertyChanged;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
private void OpenFile()
|
|
private void OpenFile()
|
|
@@ -151,9 +160,9 @@ namespace AnnotationViewControl
|
|
string filePath = CommonHelper.GetExistedPathOrEmpty();
|
|
string filePath = CommonHelper.GetExistedPathOrEmpty();
|
|
if (!string.IsNullOrEmpty(filePath) && annotationControl.PDFViewControl != null)
|
|
if (!string.IsNullOrEmpty(filePath) && annotationControl.PDFViewControl != null)
|
|
{
|
|
{
|
|
- if (pdfViewer.PDFView != null && pdfViewer.PDFView.Document != null)
|
|
|
|
|
|
+ if (pdfViewer != null && pdfViewer.PDFToolManager != null)
|
|
{
|
|
{
|
|
- string oldFilePath = pdfViewer.PDFView.Document.FilePath;
|
|
|
|
|
|
+ string oldFilePath = pdfViewer.PDFToolManager.GetDocument().FilePath;
|
|
if (oldFilePath.ToLower() == filePath.ToLower())
|
|
if (oldFilePath.ToLower() == filePath.ToLower())
|
|
{
|
|
{
|
|
return;
|
|
return;
|
|
@@ -161,14 +170,14 @@ namespace AnnotationViewControl
|
|
}
|
|
}
|
|
|
|
|
|
passwordViewer = new PDFViewControl();
|
|
passwordViewer = new PDFViewControl();
|
|
- passwordViewer.PDFView.InitDocument(filePath);
|
|
|
|
- if (passwordViewer.PDFView.Document == null)
|
|
|
|
|
|
+ passwordViewer.InitDocument(filePath);
|
|
|
|
+ if (passwordViewer.PDFToolManager.GetDocument() == null)
|
|
{
|
|
{
|
|
MessageBox.Show("Open File Failed");
|
|
MessageBox.Show("Open File Failed");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- if (passwordViewer.PDFView.Document.IsLocked)
|
|
|
|
|
|
+ if (passwordViewer.PDFToolManager.GetDocument().IsLocked)
|
|
{
|
|
{
|
|
PasswordUI.SetShowText(System.IO.Path.GetFileName(filePath) + " " + LanguageHelper.CommonManager.GetString("Tip_Encrypted"));
|
|
PasswordUI.SetShowText(System.IO.Path.GetFileName(filePath) + " " + LanguageHelper.CommonManager.GetString("Tip_Encrypted"));
|
|
PasswordUI.ClearPassword();
|
|
PasswordUI.ClearPassword();
|
|
@@ -177,7 +186,7 @@ namespace AnnotationViewControl
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- pdfViewer.PDFView.Document.Release();
|
|
|
|
|
|
+ pdfViewer?.PDFToolManager?.GetDocument().Release();
|
|
pdfViewer = passwordViewer;
|
|
pdfViewer = passwordViewer;
|
|
LoadDocument();
|
|
LoadDocument();
|
|
}
|
|
}
|
|
@@ -190,10 +199,10 @@ namespace AnnotationViewControl
|
|
|
|
|
|
private void PasswordUI_Confirmed(object sender, string e)
|
|
private void PasswordUI_Confirmed(object sender, string e)
|
|
{
|
|
{
|
|
- if (passwordViewer != null && passwordViewer.PDFView != null && passwordViewer.PDFView.Document != null)
|
|
|
|
|
|
+ if (passwordViewer != null && passwordViewer.PDFToolManager != null && passwordViewer.PDFToolManager.GetDocument() != null)
|
|
{
|
|
{
|
|
- passwordViewer.PDFView.Document.UnlockWithPassword(e);
|
|
|
|
- if (passwordViewer.PDFView.Document.IsLocked == false)
|
|
|
|
|
|
+ passwordViewer.PDFToolManager.GetDocument().UnlockWithPassword(e);
|
|
|
|
+ if (passwordViewer.PDFToolManager.GetDocument().IsLocked == false)
|
|
{
|
|
{
|
|
PasswordUI.SetShowError("", Visibility.Collapsed);
|
|
PasswordUI.SetShowError("", Visibility.Collapsed);
|
|
PasswordUI.ClearPassword();
|
|
PasswordUI.ClearPassword();
|
|
@@ -234,9 +243,8 @@ namespace AnnotationViewControl
|
|
|
|
|
|
private void LoadCustomControl()
|
|
private void LoadCustomControl()
|
|
{
|
|
{
|
|
- regularViewerControl.PdfViewControl = pdfViewer;
|
|
|
|
- regularViewerControl.InitWithPDFViewer(pdfViewer.PDFView);
|
|
|
|
- regularViewerControl.PdfViewControl.PDFView.SetMouseMode(MouseModes.Viewer);
|
|
|
|
|
|
+ regularViewerControl.InitWithPDFViewer(pdfViewer);
|
|
|
|
+ regularViewerControl.PdfViewControl.PDFViewTool.SetViewerModel(MouseModes.kViewer);
|
|
regularViewerControl.SetBOTAContainer(null);
|
|
regularViewerControl.SetBOTAContainer(null);
|
|
regularViewerControl.SetBOTAContainer(botaBarControl);
|
|
regularViewerControl.SetBOTAContainer(botaBarControl);
|
|
regularViewerControl.SetDisplaySettingsControl(displaySettingsControl);
|
|
regularViewerControl.SetDisplaySettingsControl(displaySettingsControl);
|
|
@@ -277,7 +285,7 @@ namespace AnnotationViewControl
|
|
private void SaveFileBtn_Click(object sender, RoutedEventArgs e)
|
|
private void SaveFileBtn_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
{
|
|
SaveFile();
|
|
SaveFile();
|
|
- pdfViewer.PDFView.UndoManager.CanSave = false;
|
|
|
|
|
|
+ pdfViewer.PDFViewTool.IsDocumentModified = false;
|
|
}
|
|
}
|
|
|
|
|
|
private void OpenFile_Click(object sender, RoutedEventArgs e)
|
|
private void OpenFile_Click(object sender, RoutedEventArgs e)
|
|
@@ -310,24 +318,22 @@ namespace AnnotationViewControl
|
|
|
|
|
|
if (item.Content as string == "Viewer")
|
|
if (item.Content as string == "Viewer")
|
|
{
|
|
{
|
|
- if (regularViewerControl.PdfViewControl != null && regularViewerControl.PdfViewControl.PDFView != null)
|
|
|
|
|
|
+ if (regularViewerControl.PdfViewControl != null && regularViewerControl.PdfViewControl.PDFViewTool != null)
|
|
{
|
|
{
|
|
PDFGrid.Child = regularViewerControl;
|
|
PDFGrid.Child = regularViewerControl;
|
|
- regularViewerControl.PdfViewControl.PDFView.SetMouseMode(MouseModes.Viewer);
|
|
|
|
- regularViewerControl.PdfViewControl = pdfViewer;
|
|
|
|
- regularViewerControl.InitWithPDFViewer(pdfViewer.PDFView);
|
|
|
|
|
|
+ regularViewerControl.PdfViewControl.PDFViewTool.SetViewerModel(MouseModes.kViewer);
|
|
|
|
+ regularViewerControl.InitWithPDFViewer(pdfViewer);
|
|
regularViewerControl.SetBOTAContainer(botaBarControl);
|
|
regularViewerControl.SetBOTAContainer(botaBarControl);
|
|
regularViewerControl.SetDisplaySettingsControl(displaySettingsControl);
|
|
regularViewerControl.SetDisplaySettingsControl(displaySettingsControl);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (item.Content as string == "Annotation")
|
|
else if (item.Content as string == "Annotation")
|
|
{
|
|
{
|
|
- if (annotationControl.PDFViewControl != null && annotationControl.PDFViewControl.PDFView != null)
|
|
|
|
|
|
+ if (annotationControl.PDFViewControl != null && annotationControl.PDFViewControl.PDFViewTool != null)
|
|
{
|
|
{
|
|
PDFGrid.Child = annotationControl;
|
|
PDFGrid.Child = annotationControl;
|
|
- annotationControl.PDFViewControl.PDFView.SetMouseMode(MouseModes.Viewer);
|
|
|
|
- annotationControl.PDFViewControl = pdfViewer;
|
|
|
|
- annotationControl.InitWithPDFViewer(pdfViewer.PDFView);
|
|
|
|
|
|
+ annotationControl.PDFViewControl.PDFViewTool.SetViewerModel(MouseModes.kViewer);
|
|
|
|
+ annotationControl.InitWithPDFViewer(pdfViewer);
|
|
annotationControl.SetBOTAContainer(botaBarControl);
|
|
annotationControl.SetBOTAContainer(botaBarControl);
|
|
annotationControl.SetDisplaySettingsControl(displaySettingsControl);
|
|
annotationControl.SetDisplaySettingsControl(displaySettingsControl);
|
|
}
|
|
}
|
|
@@ -339,7 +345,7 @@ namespace AnnotationViewControl
|
|
{
|
|
{
|
|
PasswordUI.Visibility = Visibility.Collapsed;
|
|
PasswordUI.Visibility = Visibility.Collapsed;
|
|
FileInfoUI.Visibility = Visibility.Visible;
|
|
FileInfoUI.Visibility = Visibility.Visible;
|
|
- FileInfoControl.InitWithPDFViewer(pdfViewer.PDFView);
|
|
|
|
|
|
+ FileInfoControl.InitWithPDFViewer(pdfViewer);
|
|
PopupBorder.Visibility = Visibility.Visible;
|
|
PopupBorder.Visibility = Visibility.Visible;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -392,9 +398,9 @@ namespace AnnotationViewControl
|
|
public void SaveAsFile()
|
|
public void SaveAsFile()
|
|
{
|
|
{
|
|
{
|
|
{
|
|
- if (pdfViewer != null && pdfViewer.PDFView != null && pdfViewer.PDFView.Document != null)
|
|
|
|
|
|
+ if (pdfViewer != null && pdfViewer.PDFToolManager != null && pdfViewer.PDFToolManager.GetDocument() != null)
|
|
{
|
|
{
|
|
- CPDFDocument pdfDoc = pdfViewer.PDFView.Document;
|
|
|
|
|
|
+ CPDFDocument pdfDoc = pdfViewer.PDFToolManager.GetDocument();
|
|
SaveFileDialog saveDialog = new SaveFileDialog();
|
|
SaveFileDialog saveDialog = new SaveFileDialog();
|
|
saveDialog.Filter = "(*.pdf)|*.pdf";
|
|
saveDialog.Filter = "(*.pdf)|*.pdf";
|
|
saveDialog.DefaultExt = ".pdf";
|
|
saveDialog.DefaultExt = ".pdf";
|
|
@@ -413,11 +419,11 @@ namespace AnnotationViewControl
|
|
/// </summary>
|
|
/// </summary>
|
|
private void SaveFile()
|
|
private void SaveFile()
|
|
{
|
|
{
|
|
- if (pdfViewer != null && pdfViewer.PDFView != null && pdfViewer.PDFView.Document != null)
|
|
|
|
|
|
+ if (pdfViewer != null && pdfViewer.PDFToolManager != null && pdfViewer.PDFToolManager.GetDocument() != null)
|
|
{
|
|
{
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- CPDFDocument pdfDoc = pdfViewer.PDFView.Document;
|
|
|
|
|
|
+ CPDFDocument pdfDoc = pdfViewer.PDFToolManager.GetDocument();
|
|
if (pdfDoc.WriteToLoadedPath())
|
|
if (pdfDoc.WriteToLoadedPath())
|
|
{
|
|
{
|
|
return;
|
|
return;
|