private void UserControl_MouseWheel(object sender, MouseWheelEventArgs e)
{
e.Handled = true;
double x = 0, y = 0;
if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
{
var previousLocation = _lastLocation;
var old = Zoom;
if (e.Delta > 0 && Zoom < 10)
{
ZoomIn();
}
else if (e.Delta < 0 && Zoom > 0.1)
{
ZoomOut();
}
if (!Zoom.Equals(old))
{
y = _lastLocation.Y - previousLocation.Y;
x = _lastLocation.X - previousLocation.X;
if (ContextMenuContainer.ContextMenuVisibility == Visibility.Visible)
{
ContextMenuContainer.ContextMenuVisibility = Visibility.Collapsed;
}
MoveMap(x, y);
}
}
else
{
if (e.Delta > 0)
{
y = 30/Zoom;
}
else if (e.Delta < 0)
{
y = -30/Zoom;
}
MoveMap(x, y);
}
}