/// <summary> /// Undo last zoom and update redo-stack /// </summary> public void PreviousZoomState() { if (undoStack.Count > 0) { ZoomState previousState = undoStack.Pop(); if (previousState != null) { if (currentZoomState != null) { redoStack.Push(currentZoomState); } isZoomChangeTriggeredByNavigation = true; Map.Center = previousState.Center; Map.Zoom = previousState.Zoom; } } }
/// <summary> /// Redo last zoom and update undo-stack /// </summary> public void NextZoomState() { if (redoStack.Count > 0) { ZoomState nextState = redoStack.Pop(); if (nextState != null) { if (currentZoomState != null) { undoStack.Push(currentZoomState); } isZoomChangeTriggeredByNavigation = true; Map.Center = nextState.Center; Map.Zoom = nextState.Zoom; } } }
/// <summary> /// Used to store current ZoomState if it changes /// </summary> /// <param name="map"></param> public void MapRendered(Map map) { // More logically this should be done in MapViewOnChange() but that event does not fire // when zoom rectangle or zoompan is performed if (!isZoomChangeTriggeredByNavigation) { if ((currentZoomState == null) || !currentZoomState.Zoom.Equals(map.Zoom) || !currentZoomState.Center.Equals(map.Center)) { if (currentZoomState != null) { undoStack.Push(currentZoomState); redoStack.Clear(); } } } isZoomChangeTriggeredByNavigation = false; currentZoomState = new ZoomState(map.Zoom, map.Center); }
/// <summary> /// Used to store current ZoomState if it changes /// </summary> /// <param name="map"></param> public void MapRendered(Map map) { // More logically this should be done in MapViewOnChange() but that event does not fire // when zoom rectangle or zoompan is performed if (!isZoomChangeTriggeredByNavigation) { if ((currentZoomState == null) || !currentZoomState.Zoom.Equals(map.Zoom) || !currentZoomState.Center.Equals(map.Center)) { if (currentZoomState != null) { undoStack.Push(currentZoomState); redoStack.Clear(); } } } isZoomChangeTriggeredByNavigation = false; currentZoomState = new ZoomState(map.Zoom, map.Center); }