I want to zoom the chart using mouse wheel. But not zoom at mouse point center, but at the specified point center I set.
How can I do it?
Is there any properties for MouseWheelZoomModifier?
- Hiroyuki Seki asked 6 years ago
- You must login to post comments
Hi there
You can override MouseWheelZoomModifier.OnModifierMouseWheel() to customize the behaviour
For example
/// <summary>
/// Called when the Mouse Wheel is scrolled on the parent <see cref="SciChartSurface"/>
/// </summary>
/// <param name="e">Arguments detailing the mouse wheel operation</param>
/// <remarks></remarks>
public override void OnModifierMouseWheel(ModifierMouseArgs e)
{
base.OnModifierMouseWheel(e);
e.Handled = true;
const double mouseWheelDeltaCoef = 120;
using (ParentSurface.SuspendUpdates())
{
double value = -e.Delta / mouseWheelDeltaCoef;
var currDirection = XyDirection;
var currAction = ActionType;
OverrideKeyboardAction(e.Modifier);
// THIS is where we get the mouse point
var mousePoint = GetPointRelativeTo(e.MousePoint, ModifierSurface);
_performAction(mousePoint, value);
TryStoreRangesToZoomHistoryManager();
this.SetCurrentValue(XyDirectionProperty, currDirection);
this.SetCurrentValue(ActionTypeProperty, currAction);
}
Or … the much simpler way – to pass a different point to the base
public class MouseWheelModifierEx : MouseWheelZoomModifier
{
public override void OnModifierMouseWheel(ModifierMouseArgs e)
{
// Override the mouse point
e.MousePoint = new Point(10, 20);
// Call base
base.OnModifierMouseWheel(e);
}
}
Best regards,
Andrew
- Andrew Burnett-Thompson answered 6 years ago
- You must login to post comments
Please login first to submit.