@@ -30,13 +30,22 @@ public ZoomRectangleManipulator(IPlotView plotView)
3030 {
3131 }
3232
33+ /// <summary>
34+ /// Gets or sets a value indicating whether zooming is enabled.
35+ /// </summary>
36+ private bool IsZoomEnabled { get ; set ; }
37+
3338 /// <summary>
3439 /// Occurs when a manipulation is complete.
3540 /// </summary>
3641 /// <param name="e">The <see cref="OxyPlot.OxyMouseEventArgs" /> instance containing the event data.</param>
3742 public override void Completed ( OxyMouseEventArgs e )
3843 {
3944 base . Completed ( e ) ;
45+ if ( ! this . IsZoomEnabled )
46+ {
47+ return ;
48+ }
4049
4150 this . PlotView . HideZoomRectangle ( ) ;
4251
@@ -57,6 +66,8 @@ public override void Completed(OxyMouseEventArgs e)
5766
5867 this . PlotView . InvalidatePlot ( ) ;
5968 }
69+
70+ e . Handled = true ;
6071 }
6172
6273 /// <summary>
@@ -66,13 +77,17 @@ public override void Completed(OxyMouseEventArgs e)
6677 public override void Delta ( OxyMouseEventArgs e )
6778 {
6879 base . Delta ( e ) ;
80+ if ( ! this . IsZoomEnabled )
81+ {
82+ return ;
83+ }
6984
7085 var plotArea = this . PlotView . ActualModel . PlotArea ;
7186
72- double x = Math . Min ( this . StartPosition . X , e . Position . X ) ;
73- double w = Math . Abs ( this . StartPosition . X - e . Position . X ) ;
74- double y = Math . Min ( this . StartPosition . Y , e . Position . Y ) ;
75- double h = Math . Abs ( this . StartPosition . Y - e . Position . Y ) ;
87+ var x = Math . Min ( this . StartPosition . X , e . Position . X ) ;
88+ var w = Math . Abs ( this . StartPosition . X - e . Position . X ) ;
89+ var y = Math . Min ( this . StartPosition . Y , e . Position . Y ) ;
90+ var h = Math . Abs ( this . StartPosition . Y - e . Position . Y ) ;
7691
7792 if ( this . XAxis == null || ! this . XAxis . IsZoomEnabled )
7893 {
@@ -88,6 +103,7 @@ public override void Delta(OxyMouseEventArgs e)
88103
89104 this . zoomRectangle = new OxyRect ( x , y , w , h ) ;
90105 this . PlotView . ShowZoomRectangle ( this . zoomRectangle ) ;
106+ e . Handled = true ;
91107 }
92108
93109 /// <summary>
@@ -116,8 +132,17 @@ public override CursorType GetCursorType()
116132 public override void Started ( OxyMouseEventArgs e )
117133 {
118134 base . Started ( e ) ;
119- this . zoomRectangle = new OxyRect ( this . StartPosition . X , this . StartPosition . Y , 0 , 0 ) ;
120- this . PlotView . ShowZoomRectangle ( this . zoomRectangle ) ;
135+
136+ this . IsZoomEnabled = ( this . XAxis != null && this . XAxis . IsZoomEnabled )
137+ || ( this . YAxis != null && this . YAxis . IsZoomEnabled ) ;
138+
139+ if ( this . IsZoomEnabled )
140+ {
141+ this . zoomRectangle = new OxyRect ( this . StartPosition . X , this . StartPosition . Y , 0 , 0 ) ;
142+ this . PlotView . ShowZoomRectangle ( this . zoomRectangle ) ;
143+ }
144+
145+ e . Handled |= this . IsZoomEnabled ;
121146 }
122147 }
123148}
0 commit comments