/// <summary> /// Alters the zoom of the map, maintaing the same point underneath the mouse at the new zoom level. /// </summary> /// <param name="e">The MouseWheelEventArgs that contains the event data.</param> protected override void OnMouseWheel(MouseWheelEventArgs e) { base.OnMouseWheel(e); int newZoom = TileGenerator.GetValidZoom(Zoom + (e.Delta / Mouse.MouseWheelDeltaForOneLine)); Point mouse = e.GetPosition(this); BeginUpdate(); _offsetX.ChangeZoom(newZoom, mouse.X); _offsetY.ChangeZoom(newZoom, mouse.Y); // Set this after we've altered the offsets. Zoom = newZoom; EndUpdate(); }
private static object OnZoomPropertyCoerceValue(DependencyObject d, object baseValue) { return(TileGenerator.GetValidZoom((int)baseValue)); }