From b3a515a86016b35557d2f4c49614117ebf399a5c Mon Sep 17 00:00:00 2001 From: fds-ssg Date: Thu, 7 Dec 2017 16:29:17 -0500 Subject: [PATCH] Add PanningEnabled property so consumers can disable panning --- PdfiumViewer/PanningZoomingScrollControl.cs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/PdfiumViewer/PanningZoomingScrollControl.cs b/PdfiumViewer/PanningZoomingScrollControl.cs index ce205d5d..85fb9646 100644 --- a/PdfiumViewer/PanningZoomingScrollControl.cs +++ b/PdfiumViewer/PanningZoomingScrollControl.cs @@ -36,6 +36,19 @@ static PanningZoomingScrollControl() public event EventHandler ZoomChanged; + /// + /// If true, cursor will be a hand and the mouse can be used to pan + /// within the document. If false, cursor will be an arrow and + /// mouse operations can be defined by consumers of the control. + /// + [DefaultValue(true)] + public bool PanningEnabled = true; + + private bool ShouldPan + { + get { return _canPan && PanningEnabled; } + } + protected virtual void OnZoomChanged(EventArgs e) { var ev = ZoomChanged; @@ -226,7 +239,7 @@ protected override bool IsInputKey(Keys keyData) protected override void OnSetCursor(SetCursorEventArgs e) { - if (_canPan && e.HitTest == HitTest.Client) + if (ShouldPan && e.HitTest == HitTest.Client) e.Cursor = PanCursor; base.OnSetCursor(e); @@ -243,7 +256,7 @@ protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); - if (e.Button != MouseButtons.Left || !_canPan) + if (e.Button != MouseButtons.Left || !ShouldPan) return; Capture = true; @@ -255,7 +268,7 @@ protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); - if (!Capture) + if (!Capture || !ShouldPan) return; var offset = new Point(e.Location.X - _dragStart.X, e.Location.Y - _dragStart.Y);