I’ve verified it steps thru the code as I would expect; however, it only ever zooms in further. The intent of this modifier is to only zoom out when the mouse is dragged up and left. I.e.
Mouse down
Drag up/left
Mouse up
class ZoomOutModifier : ZoomExtentsModifier
{
double _x;
double _y;
MouseButtons _button = MouseButtons.None;
public override void OnModifierDoubleClick(ModifierMouseArgs e)
{
// do not zoom to extents on a double click
e.Handled = true;
}
public override void OnModifierMouseDown(ModifierMouseArgs e)
{
base.OnModifierMouseDown(e);
// where was the mouse button on the chart surface?
_x = e.MousePoint.X;
_y = e.MousePoint.Y;
// which button was clicked? we're only going to zoom
// out on a left button click.
_button = e.MouseButtons;
}
public override void OnModifierMouseUp(ModifierMouseArgs e)
{
// are we left and up from where the mouse was clicked?
if (MouseButtons.Left == _button &&
e.MousePoint.X < _x &&
e.MousePoint.Y < _y)
{
using (var updater = ParentSurface.SuspendUpdates())
{
ParentSurface.ZoomExtents();
ParentSurface.ResumeUpdates(updater);
}
e.Handled = true;
}
else
base.OnModifierMouseUp(e);
}
}
- Chris Kirkman asked 4 years ago
- last active 4 years ago