|
@@ -1,5 +1,4 @@
|
|
|
using ComPDFKitViewer;
|
|
|
-using ComPDFKitViewer.PdfViewer;
|
|
|
using System;
|
|
|
using System.Windows;
|
|
|
using System.Windows.Controls;
|
|
@@ -8,16 +7,16 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
{
|
|
|
public partial class CPDFScalingControl : UserControl
|
|
|
{
|
|
|
- public CPDFViewer pdfViewer;
|
|
|
+ public PDFViewControl ViewControl;
|
|
|
|
|
|
public CPDFScalingControl()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
}
|
|
|
|
|
|
- public void InitWithPDFViewer(CPDFViewer pdfViewer)
|
|
|
+ public void InitWithPDFViewer(PDFViewControl viewControl)
|
|
|
{
|
|
|
- this.pdfViewer = pdfViewer;
|
|
|
+ ViewControl = viewControl;
|
|
|
}
|
|
|
|
|
|
private void PDFScalingControl_Loaded(object sender, RoutedEventArgs e)
|
|
@@ -38,82 +37,106 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
|
|
|
private void PDFScalingControl_ScaleDecreaseEvent(object sender, EventArgs e)
|
|
|
{
|
|
|
- if (pdfViewer == null || pdfViewer.Document == null)
|
|
|
+ if (ViewControl == null || ViewControl.PDFViewTool == null)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
- if (pdfViewer.ZoomFactor < 3)
|
|
|
+ CPDFViewer pdfViewer = ViewControl.PDFViewTool.GetCPDFViewer();
|
|
|
+ if (pdfViewer == null)
|
|
|
{
|
|
|
- pdfViewer.Zoom(pdfViewer.ZoomFactor - 0.1);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pdfViewer.GetZoom() < 3)
|
|
|
+ {
|
|
|
+ pdfViewer.SetZoom(pdfViewer.GetZoom() - 0.1);
|
|
|
}
|
|
|
- else if (pdfViewer.ZoomFactor < 6)
|
|
|
+ else if (pdfViewer.GetZoom() < 6)
|
|
|
{
|
|
|
- pdfViewer.Zoom(pdfViewer.ZoomFactor - 0.2);
|
|
|
+ pdfViewer.SetZoom(pdfViewer.GetZoom() - 0.2);
|
|
|
}
|
|
|
- else if (pdfViewer.ZoomFactor <= 10)
|
|
|
+ else if (pdfViewer.GetZoom() <= 10)
|
|
|
{
|
|
|
- pdfViewer.Zoom(pdfViewer.ZoomFactor - 0.3);
|
|
|
+ pdfViewer.SetZoom(pdfViewer.GetZoom() - 0.3);
|
|
|
}
|
|
|
- SetZoomTextBoxText(string.Format("{0}", (int)(pdfViewer.ZoomFactor * 100)));
|
|
|
+ SetZoomTextBoxText(string.Format("{0}", (int)(pdfViewer.GetZoom() * 100)));
|
|
|
}
|
|
|
|
|
|
private void PDFScalingControl_ScaleIncreaseEvent(object sender, EventArgs e)
|
|
|
{
|
|
|
- if (pdfViewer == null || pdfViewer.Document == null)
|
|
|
+ if (ViewControl == null || ViewControl.PDFViewTool == null)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
- if (pdfViewer.ZoomFactor < 3)
|
|
|
+ CPDFViewer pdfViewer = ViewControl.PDFViewTool.GetCPDFViewer();
|
|
|
+ if (pdfViewer == null)
|
|
|
{
|
|
|
- pdfViewer.Zoom(pdfViewer.ZoomFactor + 0.1);
|
|
|
+ return;
|
|
|
}
|
|
|
- else if (pdfViewer.ZoomFactor < 6)
|
|
|
+
|
|
|
+ if (pdfViewer.GetZoom() < 3)
|
|
|
{
|
|
|
- pdfViewer.Zoom(pdfViewer.ZoomFactor + 0.2);
|
|
|
+ pdfViewer.SetZoom(pdfViewer.GetZoom() + 0.1);
|
|
|
}
|
|
|
- else if (pdfViewer.ZoomFactor <= 10)
|
|
|
+ else if (pdfViewer.GetZoom() < 6)
|
|
|
{
|
|
|
- pdfViewer.Zoom(pdfViewer.ZoomFactor + 0.3);
|
|
|
+ pdfViewer.SetZoom(pdfViewer.GetZoom() + 0.2);
|
|
|
}
|
|
|
- SetZoomTextBoxText(string.Format("{0}", (int)(pdfViewer.ZoomFactor * 100)));
|
|
|
+ else if (pdfViewer.GetZoom() <= 10)
|
|
|
+ {
|
|
|
+ pdfViewer.SetZoom(pdfViewer.GetZoom() + 0.3);
|
|
|
+ }
|
|
|
+ SetZoomTextBoxText(string.Format("{0}", (int)pdfViewer.GetZoom() * 100)));
|
|
|
}
|
|
|
|
|
|
private void PDFScalingControl_SetScaleEvent(object sender, string e)
|
|
|
{
|
|
|
- if (pdfViewer == null || pdfViewer.Document == null)
|
|
|
+ if (ViewControl == null || ViewControl.PDFViewTool == null)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ CPDFViewer pdfViewer = ViewControl.PDFViewTool.GetCPDFViewer();
|
|
|
+ if (pdfViewer == null)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
if (!string.IsNullOrEmpty(e))
|
|
|
{
|
|
|
- pdfViewer.Zoom(double.Parse(e) / 100);
|
|
|
- SetZoomTextBoxText(string.Format("{0}", (int)(pdfViewer.ZoomFactor * 100)));
|
|
|
+ pdfViewer.SetZoom(double.Parse(e) / 100);
|
|
|
+ SetZoomTextBoxText(string.Format("{0}", (int)(pdfViewer.GetZoom() * 100)));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void CPDFScalingUI_SetPresetScaleEvent(object sender, string e)
|
|
|
{
|
|
|
- if (pdfViewer == null || pdfViewer.Document == null)
|
|
|
+ if (ViewControl == null || ViewControl.PDFViewTool == null)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ CPDFViewer pdfViewer = ViewControl.PDFViewTool.GetCPDFViewer();
|
|
|
+ if (pdfViewer == null)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
if (e == "Actual size")
|
|
|
{
|
|
|
- pdfViewer.ChangeFitMode(FitMode.FitSize);
|
|
|
+ pdfViewer.SetFitMode(FitModes.FitOriginal);
|
|
|
}
|
|
|
else if (e == "Suitable width")
|
|
|
{
|
|
|
- pdfViewer.ChangeFitMode(FitMode.FitWidth);
|
|
|
+ pdfViewer.SetFitMode(FitModes.FitWidth);
|
|
|
}
|
|
|
else if (e == "Single page size")
|
|
|
{
|
|
|
- pdfViewer.ChangeFitMode(FitMode.FitHeight);
|
|
|
+ pdfViewer.SetFitMode(FitModes.FitHeight);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- pdfViewer.Zoom(double.Parse(e) / 100);
|
|
|
+ pdfViewer.SetZoom(double.Parse(e) / 100);
|
|
|
}
|
|
|
- SetZoomTextBoxText(string.Format("{0}", (int)(pdfViewer.ZoomFactor * 100)));
|
|
|
+ SetZoomTextBoxText(string.Format("{0}", (int)(pdfViewer.GetZoom() * 100)));
|
|
|
}
|
|
|
|
|
|
public void SetZoomTextBoxText(string value)
|
|
@@ -123,7 +146,17 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
|
|
|
private void CPDFPageScalingControl_LostFocus(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
- SetZoomTextBoxText(string.Format("{0}", (int)(pdfViewer.ZoomFactor * 100)));
|
|
|
+ if (ViewControl == null || ViewControl.PDFViewTool == null)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ CPDFViewer pdfViewer = ViewControl.PDFViewTool.GetCPDFViewer();
|
|
|
+ if (pdfViewer == null)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ SetZoomTextBoxText(string.Format("{0}", (int)(pdfViewer.GetZoom() * 100)));
|
|
|
}
|
|
|
}
|
|
|
}
|