|
@@ -5,6 +5,8 @@ using ComPDFKit.Tool;
|
|
|
using ComPDFKit.Tool.SettingParam;
|
|
|
using Compdfkit_Tools.PDFControlUI;
|
|
|
using ComPDFKitViewer;
|
|
|
+using ComPDFKitViewer.BaseObject;
|
|
|
+using ComPDFKitViewer.Widget;
|
|
|
using Nager.Country.Currencies;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
@@ -15,6 +17,7 @@ using System.Windows;
|
|
|
using System.Windows.Controls;
|
|
|
using System.Windows.Input;
|
|
|
using static ComPDFKit.Tool.CPDFToolManager;
|
|
|
+using static Compdfkit_Tools.PDFControlUI.CPDFViewModeUI;
|
|
|
using SplitMode = Compdfkit_Tools.PDFControlUI.CPDFViewModeUI.SplitMode;
|
|
|
|
|
|
namespace Compdfkit_Tools.PDFControl
|
|
@@ -27,15 +30,16 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
private CPDFViewerTool viewerTool;
|
|
|
private CPDFToolManager toolManager;
|
|
|
|
|
|
- private AnnotParam annotParam;
|
|
|
-
|
|
|
public CPDFViewerTool PDFViewTool { get;private set; }
|
|
|
public CPDFToolManager PDFToolManager { get;private set; }
|
|
|
|
|
|
- public CPDFViewerTool SelectedPDFViewTool { get;private set; }
|
|
|
+ public CPDFViewerTool FocusPDFViewTool { get;private set; }
|
|
|
|
|
|
- public event EventHandler SplitPDFViewToolCreated;
|
|
|
+ //public event EventHandler SplitPDFViewToolCreated;
|
|
|
public event EventHandler SelectedPDFViewToolChanged;
|
|
|
+ public event EventHandler<MouseEventObject> MouseLeftButtonDownHandler;
|
|
|
+ public event EventHandler<MouseEventObject> MouseLeftButtonUpHandler;
|
|
|
+ public event EventHandler<MouseEventObject> MouseMoveHandler;
|
|
|
|
|
|
#region Properties
|
|
|
|
|
@@ -46,40 +50,55 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
public PDFViewControl()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
- //if (ViewerTool==null)
|
|
|
- //{
|
|
|
- // PDFViewTool = ViewerTool= new CPDFViewerTool();
|
|
|
- // PDFViewTool.GetCPDFViewer().MouseWheelZoomHandler += PDFViewControl_MouseWheelZoomHandler;
|
|
|
- // PDFViewTool.SizeChanged += PDFViewTool_SizeChanged;
|
|
|
- // if (pDFToolManager == null)
|
|
|
- // {
|
|
|
- // PDFToolManager= pDFToolManager = new CPDFToolManager(PDFViewTool);
|
|
|
- // }
|
|
|
- // else
|
|
|
- // {
|
|
|
- // pDFToolManager.Remove();
|
|
|
- // PDFToolManager= pDFToolManager = new CPDFToolManager(PDFViewTool);
|
|
|
- // }
|
|
|
- //}
|
|
|
- //else
|
|
|
- //{
|
|
|
- // PDFViewTool = ViewerTool;
|
|
|
- // PDFToolManager = pDFToolManager;
|
|
|
- //}
|
|
|
viewerTool = new CPDFViewerTool();
|
|
|
toolManager = new CPDFToolManager(viewerTool);
|
|
|
PDFViewTool = viewerTool;
|
|
|
PDFToolManager = toolManager;
|
|
|
- SelectedPDFViewTool = viewerTool;
|
|
|
+ PDFToolManager.SetToolType(CPDFToolManager.ToolType.Viewer);
|
|
|
+
|
|
|
+ splitViewerTool = new CPDFViewerTool();
|
|
|
+ splitToolManager = new CPDFToolManager(splitViewerTool);
|
|
|
+ splitToolManager.SetToolType(CPDFToolManager.ToolType.Viewer);
|
|
|
+ splitViewerTool.SizeChanged += SplitViewerTool_SizeChanged;
|
|
|
+
|
|
|
+ FocusPDFViewTool = viewerTool;
|
|
|
PDFView.Child = PDFViewTool;
|
|
|
+
|
|
|
PDFViewTool.SizeChanged += PDFViewTool_SizeChanged;
|
|
|
PDFViewTool.GetCPDFViewer().MouseWheelZoomHandler += PDFViewControl_MouseWheelZoomHandler;
|
|
|
- PDFToolManager.SetToolType(CPDFToolManager.ToolType.Viewer);
|
|
|
+ PDFToolManager.MouseLeftButtonDownHandler += PDFToolManager_MouseLeftButtonDownHandler;
|
|
|
+ PDFToolManager.MouseLeftButtonUpHandler += PDFToolManager_MouseLeftButtonUpHandler;
|
|
|
+ PDFToolManager.MouseMoveHandler += PDFToolManager_MouseMoveHandler;
|
|
|
+
|
|
|
+ splitViewerTool.GetCPDFViewer().MouseWheelZoomHandler += SplitPDFViewControl_MouseWheelZoomHandler;
|
|
|
+ splitToolManager.MouseLeftButtonDownHandler += PDFToolManager_MouseLeftButtonDownHandler;
|
|
|
+ splitToolManager.MouseLeftButtonUpHandler += PDFToolManager_MouseLeftButtonUpHandler;
|
|
|
+ splitToolManager.MouseMoveHandler += PDFToolManager_MouseMoveHandler;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void PDFToolManager_MouseMoveHandler(object sender, MouseEventObject e)
|
|
|
+ {
|
|
|
+ MouseMoveHandler?.Invoke(this, e);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void PDFToolManager_MouseLeftButtonUpHandler(object sender, MouseEventObject e)
|
|
|
+ {
|
|
|
+ MouseLeftButtonUpHandler?.Invoke(sender, e);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void PDFToolManager_MouseLeftButtonDownHandler(object sender, MouseEventObject e)
|
|
|
+ {
|
|
|
+ MouseLeftButtonDownHandler?.Invoke(sender,e);
|
|
|
}
|
|
|
|
|
|
private void PDFViewTool_SizeChanged(object sender, SizeChangedEventArgs e)
|
|
|
{
|
|
|
- PDFViewTool.GetCPDFViewer().UpDateRenderFrame();
|
|
|
+ PDFViewTool?.GetCPDFViewer()?.UpDateRenderFrame();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void SplitViewerTool_SizeChanged(object sender, SizeChangedEventArgs e)
|
|
|
+ {
|
|
|
+ splitViewerTool?.GetCPDFViewer()?.UpDateRenderFrame();
|
|
|
}
|
|
|
|
|
|
public void InitDocument(string Path)
|
|
@@ -91,6 +110,11 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
|
|
|
PDFViewTool.GetCPDFViewer().SetFitMode(FitModes.FitHeight);
|
|
|
PDFViewTool.GetCPDFViewer().SetViewMode(ViewModes.SingleContinuous);
|
|
|
+
|
|
|
+ splitViewerTool.GetCPDFViewer().InitDoc(pdfDoc);
|
|
|
+
|
|
|
+ splitViewerTool.GetCPDFViewer().SetFitMode(FitModes.FitHeight);
|
|
|
+ splitViewerTool.GetCPDFViewer().SetViewMode(ViewModes.SingleContinuous);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -102,7 +126,7 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
PDFViewTool.GetCPDFViewer().SetFitMode(FitModes.FitZoom);
|
|
|
double zoom = PDFViewTool.GetCPDFViewer().GetZoom();
|
|
|
PDFViewTool.GetCPDFViewer().SetZoom(CheckZoomLevel(zoom, Convert.ToBoolean(e.WheelBehavior)));
|
|
|
- PDFViewTool.GetCPDFViewer().UpDateRenderFrame();
|
|
|
+ PDFViewTool?.GetCPDFViewer()?.UpDateRenderFrame();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -114,7 +138,7 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
splitViewerTool.GetCPDFViewer().SetFitMode(FitModes.FitZoom);
|
|
|
double zoom = splitViewerTool.GetCPDFViewer().GetZoom();
|
|
|
splitViewerTool.GetCPDFViewer().SetZoom(CheckZoomLevel(zoom, Convert.ToBoolean(e.WheelBehavior)));
|
|
|
- splitViewerTool.GetCPDFViewer().UpDateRenderFrame();
|
|
|
+ splitViewerTool?.GetCPDFViewer()?.UpDateRenderFrame();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -127,7 +151,6 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
break;
|
|
|
case SplitMode.Vertical:
|
|
|
RemoveSplitViewerTool();
|
|
|
- CreateSplitViewerTool();
|
|
|
if(splitViewerTool != null)
|
|
|
{
|
|
|
VerticalSplitter.Visibility = Visibility.Visible;
|
|
@@ -140,7 +163,6 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
break;
|
|
|
case SplitMode.Horizontal:
|
|
|
RemoveSplitViewerTool();
|
|
|
- CreateSplitViewerTool();
|
|
|
if(splitViewerTool != null)
|
|
|
{
|
|
|
HorizontalSplitter.Visibility = Visibility.Visible;
|
|
@@ -152,91 +174,99 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
break;
|
|
|
}
|
|
|
UpdateFrame();
|
|
|
+ UpdateAnnotFrame();
|
|
|
}
|
|
|
|
|
|
public void UpdateFrame()
|
|
|
{
|
|
|
- viewerTool.GetCPDFViewer().UpDateRenderFrame();
|
|
|
+ viewerTool?.GetCPDFViewer()?.UpDateRenderFrame();
|
|
|
splitViewerTool?.GetCPDFViewer()?.UpDateRenderFrame();
|
|
|
}
|
|
|
|
|
|
+ public void UpdateAnnotFrame()
|
|
|
+ {
|
|
|
+ viewerTool?.GetCPDFViewer()?.UpDateAnnotFrame();
|
|
|
+ splitViewerTool?.GetCPDFViewer()?.UpDateAnnotFrame();
|
|
|
+ }
|
|
|
+
|
|
|
public void SetToolType(ToolType type)
|
|
|
{
|
|
|
- toolManager.SetToolType(type);
|
|
|
+ toolManager?.SetToolType(type);
|
|
|
splitToolManager?.SetToolType(type);
|
|
|
}
|
|
|
|
|
|
public void SetCreateAnnotType(C_ANNOTATION_TYPE type)
|
|
|
{
|
|
|
- toolManager.SetCreateAnnotType(type);
|
|
|
+ toolManager?.SetCreateAnnotType(type);
|
|
|
splitToolManager?.SetCreateAnnotType(type);
|
|
|
}
|
|
|
|
|
|
public void SetCreateWidgetType(C_WIDGET_TYPE type)
|
|
|
{
|
|
|
- toolManager.SetCreateWidgetType(type);
|
|
|
+ toolManager?.SetCreateWidgetType(type);
|
|
|
splitToolManager?.SetCreateWidgetType(type);
|
|
|
}
|
|
|
|
|
|
public void SetAnnotParam(AnnotParam param)
|
|
|
{
|
|
|
- annotParam = param;
|
|
|
DefaultSettingParam defaultSettingParam = viewerTool.GetDefaultSettingParam();
|
|
|
- DefaultSettingParam splitDefaultSettingParam = splitViewerTool?.GetDefaultSettingParam();
|
|
|
- defaultSettingParam.SetAnnotParam(annotParam);
|
|
|
- splitDefaultSettingParam?.SetAnnotParam(annotParam);
|
|
|
+ DefaultSettingParam splitSettingParam = splitViewerTool.GetDefaultSettingParam();
|
|
|
+ defaultSettingParam.SetAnnotParam(param);
|
|
|
+ splitSettingParam.SetAnnotParam(param);
|
|
|
}
|
|
|
|
|
|
public void SetIsShowStampMouse(bool isShow)
|
|
|
{
|
|
|
- viewerTool.GetCPDFViewer().SetIsShowStampMouse(isShow);
|
|
|
+ viewerTool?.GetCPDFViewer()?.SetIsShowStampMouse(isShow);
|
|
|
splitViewerTool?.GetCPDFViewer()?.SetIsShowStampMouse(isShow);
|
|
|
}
|
|
|
|
|
|
public void SetDrawModes(DrawModeData drawMode)
|
|
|
{
|
|
|
- viewerTool.GetCPDFViewer().SetDrawModes(drawMode.DrawMode);
|
|
|
+ viewerTool?.GetCPDFViewer()?.SetDrawModes(drawMode.DrawMode);
|
|
|
splitViewerTool?.GetCPDFViewer()?.SetDrawModes(drawMode.DrawMode);
|
|
|
UpdateFrame();
|
|
|
}
|
|
|
|
|
|
- private void CreateSplitViewerTool()
|
|
|
+ public void SetStampMouseImage(byte[] imageArray,int imageWidth,int imageHeight)
|
|
|
{
|
|
|
- if (viewerTool.GetCPDFViewer().GetDocument() != null)
|
|
|
+ viewerTool?.GetCPDFViewer()?.SetStampMouseImage(imageArray, imageWidth, imageHeight);
|
|
|
+ splitViewerTool?.GetCPDFViewer()?.SetStampMouseImage(imageArray, imageWidth, imageHeight);
|
|
|
+ }
|
|
|
+
|
|
|
+ public bool SetStampMouseImage(string filePath)
|
|
|
+ {
|
|
|
+ if((bool)(viewerTool?.GetCPDFViewer()?.SetStampMouseImage(filePath)) && (bool)splitViewerTool?.GetCPDFViewer()?.SetStampMouseImage(filePath))
|
|
|
{
|
|
|
- splitViewerTool = new CPDFViewerTool();
|
|
|
- splitViewerTool.GetCPDFViewer().InitDoc(viewerTool.GetCPDFViewer().GetDocument());
|
|
|
- splitToolManager = new CPDFToolManager(splitViewerTool);
|
|
|
- splitViewerTool.SizeChanged += SplitViewerTool_SizeChanged;
|
|
|
- splitViewerTool.GetCPDFViewer().MouseWheelZoomHandler += SplitPDFViewControl_MouseWheelZoomHandler;
|
|
|
-
|
|
|
- ToolType toolType = toolManager.GetToolType();
|
|
|
- splitToolManager.SetToolType(toolType);
|
|
|
- if (toolType == ToolType.CreateAnnot)
|
|
|
- {
|
|
|
- C_ANNOTATION_TYPE createAnnotType = toolManager.GetAnnotType();
|
|
|
- splitToolManager.SetCreateAnnotType(createAnnotType);
|
|
|
- DefaultSettingParam defaultSettingParam = splitViewerTool.GetDefaultSettingParam();
|
|
|
- defaultSettingParam.SetAnnotParam(annotParam);
|
|
|
- }
|
|
|
- if(toolType == ToolType.FormEdit)
|
|
|
- {
|
|
|
- splitToolManager.SetCreateWidgetType((annotParam as FormParm).WidgetType);
|
|
|
- DefaultSettingParam defaultSettingParam = splitViewerTool.GetDefaultSettingParam();
|
|
|
- defaultSettingParam.SetAnnotParam(annotParam);
|
|
|
- }
|
|
|
- SplitPDFViewToolCreated?.Invoke(this, EventArgs.Empty);
|
|
|
+ return true;
|
|
|
}
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
- private void SplitViewerTool_SizeChanged(object sender, SizeChangedEventArgs e)
|
|
|
+ public void SetIsVisibleCustomMouse(bool isVisbleCustomMouse)
|
|
|
+ {
|
|
|
+ viewerTool?.GetCPDFViewer()?.SetIsVisibleCustomMouse(isVisbleCustomMouse);
|
|
|
+ splitViewerTool?.GetCPDFViewer()?.SetIsVisibleCustomMouse(isVisbleCustomMouse);
|
|
|
+ }
|
|
|
+
|
|
|
+ public CPDFViewer GetCPDFViewer()
|
|
|
{
|
|
|
- splitViewerTool.GetCPDFViewer().UpDateRenderFrame();
|
|
|
+ return FocusPDFViewTool?.GetCPDFViewer();
|
|
|
+ }
|
|
|
+
|
|
|
+ public BaseWidget GetCacheHitTestWidget()
|
|
|
+ {
|
|
|
+ return FocusPDFViewTool?.GetCacheHitTestWidget();
|
|
|
+ }
|
|
|
+
|
|
|
+ public BaseAnnot GetCacheHitTestAnnot()
|
|
|
+ {
|
|
|
+ return FocusPDFViewTool?.GetCacheHitTestAnnot();
|
|
|
}
|
|
|
|
|
|
private void RemoveSplitViewerTool()
|
|
|
{
|
|
|
- PDFViewTool.GetCPDFViewer().UpDateRenderFrame();
|
|
|
+ UpdateFrame();
|
|
|
VerticalSplitter.Visibility = Visibility.Collapsed;
|
|
|
HorizontalSplitter.Visibility = Visibility.Collapsed;
|
|
|
VerticalView.Visibility = Visibility.Collapsed;
|
|
@@ -245,8 +275,6 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
ViewToolGrid.ColumnDefinitions[2].Width = new GridLength(0);
|
|
|
ViewToolGrid.RowDefinitions[1].Height = new GridLength(0);
|
|
|
ViewToolGrid.RowDefinitions[2].Height = new GridLength(0);
|
|
|
- splitViewerTool = null;
|
|
|
- splitToolManager = null;
|
|
|
VerticalView.Child = null;
|
|
|
HorizontalView.Child = null;
|
|
|
}
|
|
@@ -256,10 +284,10 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
switch((sender as Border).Tag)
|
|
|
{
|
|
|
case "ViewerTool":
|
|
|
- SelectedPDFViewTool = viewerTool;
|
|
|
+ FocusPDFViewTool = viewerTool;
|
|
|
break;
|
|
|
case "SplitViewerTool":
|
|
|
- SelectedPDFViewTool = splitViewerTool;
|
|
|
+ FocusPDFViewTool = splitViewerTool;
|
|
|
break;
|
|
|
}
|
|
|
SelectedPDFViewToolChanged?.Invoke(this,EventArgs.Empty);
|