1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- 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
- {
- /// <summary>
- /// PDFScallingControl.xaml 的交互逻辑
- /// </summary>
- 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);
- }
- }
- }
|