Browse Source

其他 - 使用滚轮缩放时更新显示

sunhaonan 1 year ago
parent
commit
9038c1cf4c

+ 12 - 0
Demo/Examples/Compdfkit_Tools/PDFView/PDFScaling/PDFScalingControl/CPDFScalingControl.xaml.cs

@@ -2,6 +2,7 @@
 using System;
 using System.Windows;
 using System.Windows.Controls;
+using System.Windows.Input;
 
 namespace Compdfkit_Tools.PDFControl
 {
@@ -19,12 +20,22 @@ namespace Compdfkit_Tools.PDFControl
             ViewControl = viewControl;
         }
 
+        private void PDFControl_MouseWheelZoomHandler(object sender, ComPDFKitViewer.MouseWheelZoomArgs e)
+        {
+            if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
+            {
+                CPDFViewer pdfViewer = ViewControl.PDFViewTool.GetCPDFViewer();
+                SetZoomTextBoxText(string.Format("{0}", (int)(pdfViewer.GetZoom() * 100)));
+            }
+        }
+
         private void PDFScalingControl_Loaded(object sender, RoutedEventArgs e)
         {
             CPDFScalingUI.SetScaleEvent += PDFScalingControl_SetScaleEvent;
             CPDFScalingUI.ScaleIncreaseEvent += PDFScalingControl_ScaleIncreaseEvent;
             CPDFScalingUI.ScaleDecreaseEvent += PDFScalingControl_ScaleDecreaseEvent;
             CPDFScalingUI.SetPresetScaleEvent += CPDFScalingUI_SetPresetScaleEvent;
+            ViewControl.PDFViewTool.GetCPDFViewer().MouseWheelZoomHandler += PDFControl_MouseWheelZoomHandler;
         }
 
         private void CPDFScalingUI_Unloaded(object sender, RoutedEventArgs e)
@@ -33,6 +44,7 @@ namespace Compdfkit_Tools.PDFControl
             CPDFScalingUI.ScaleIncreaseEvent -= PDFScalingControl_ScaleIncreaseEvent;
             CPDFScalingUI.ScaleDecreaseEvent -= PDFScalingControl_ScaleDecreaseEvent;
             CPDFScalingUI.SetPresetScaleEvent -= CPDFScalingUI_SetPresetScaleEvent;
+            ViewControl.PDFViewTool.GetCPDFViewer().MouseWheelZoomHandler -= PDFControl_MouseWheelZoomHandler;
         }
 
         private void PDFScalingControl_ScaleDecreaseEvent(object sender, EventArgs e)