diff --git a/PdfiumViewer/PanningZoomingScrollControl.cs b/PdfiumViewer/PanningZoomingScrollControl.cs index ce205d5..85fb964 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);