using compdfkit_tools.Common; using ComPDFKitViewer.PdfViewer; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace compdfkit_tools.PDFControl { /// /// PDFScallingControl.xaml 的交互逻辑 /// public partial class CPDFScalingControl : UserControl { public CPDFViewer pdfViewer; public CPDFScalingControl() { InitializeComponent(); CPDFScalingUI.Loaded += PDFScalingControl_Loaded; } public void InitWithPDFViewer(CPDFViewer pdfViewer) { this.pdfViewer = pdfViewer; } private void PDFScalingControl_Loaded(object sender, RoutedEventArgs e) { CPDFScalingUI.SetScaleEvent += PDFScalingControl_SetScaleEvent; CPDFScalingUI.ScaleIncreaseEvent += PDFScalingControl_ScaleIncreaseEvent; CPDFScalingUI.ScaleDecreaseEvent += PDFScalingControl_ScaleDecreaseEvent; CPDFScalingUI.SetPresetScaleEvent += CPDFScalingUI_SetPresetScaleEvent; } private void PDFScalingControl_ScaleDecreaseEvent(object sender, EventArgs e) { if (pdfViewer == null || pdfViewer.Document == null) { return; } CPDFScalingUI.Scale -= 10; pdfViewer.Zoom((double)(CPDFScalingUI.Scale) / 100); } private void PDFScalingControl_ScaleIncreaseEvent(object sender, EventArgs e) { if (pdfViewer == null || pdfViewer.Document == null) { return; } CPDFScalingUI.Scale += 10; pdfViewer.Zoom((double)(CPDFScalingUI.Scale) / 100); } private void PDFScalingControl_SetScaleEvent(object sender, string e) { if (pdfViewer == null || pdfViewer.Document == null) { return; } if (!string.IsNullOrEmpty(e)) { pdfViewer.Zoom(double.Parse(e) / 100); } } private void CPDFScalingUI_SetPresetScaleEvent(object sender, string e) { if (pdfViewer == null || pdfViewer.Document == null) { return; } pdfViewer.Zoom(double.Parse(e) / 100); } } }