/// <summary> /// Called when the mouse button is pressed down. Records the /// mouse position, to be used to move map center when the /// mouse button is released. /// </summary> /// <param name="sender">Sender object.</param> /// <param name="args">Event data.</param> private void OnButtonPress(object sender, ButtonPressEventArgs args) { try { isDragging = true; CartesianToGeoCoords(args.Event.X, args.Event.Y, out double lat, out double lon); mouseAtDragStart = new ApsimCoordinate(lat, lon); } catch (Exception err) { ShowError(err); } }
/// <summary> /// Show the given markers on the map and set the center/zoom level. /// </summary> /// <param name="coordinates">Coordinates of the markers.</param> /// <param name="locNames">Names of the marekrs (unused currently).</param> /// <param name="zoom">Zoom level of the map.</param> /// <param name="center">Location of the center of the map.</param> public void ShowMap(List <ApsimCoordinate> coordinates, List <string> locNames, double zoom, ApsimCoordinate center) { if (map != null) { map.Dispose(); } map = new MapTag(center, zoom, coordinates).ToSharpMap(); map.Size = new Size(defaultWidth, defaultHeight); if (image.Allocation.Width > 1 && image.Allocation.Height > 1) { RefreshMap(); } }