/// <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(this.Zoom + (e.Delta / Mouse.MouseWheelDeltaForOneLine)); Point mouse = e.GetPosition(this); this.BeginUpdate(); _offsetX.ChangeZoom(newZoom, mouse.X); _offsetY.ChangeZoom(newZoom, mouse.Y); this.Zoom = newZoom; // Set this after we've altered the offsets this.EndUpdate(); }
private static object OnZoomPropertyCoerceValue(DependencyObject d, object baseValue) { return(TileGenerator.GetValidZoom((int)baseValue)); }