void OpenStreetMapViewer_MouseWheel(object sender, MouseEventArgs e) { if (e.Delta > 0) { Zoom += 1; CenterCoord = TileCoordinatesConverter.GetCoordinates(zoom, getTileCoordinatesFromLocation(e.Location)); } if (e.Delta < 0) { Zoom -= 1; } }
private void OpenStreetMapViewer_MouseMove(object sender, MouseEventArgs e) { // pointed coordinate PointF pointTile = new PointF((float)e.X / (float)tileManager.TileSize.Width + topLeftTile.X, (float)e.Y / (float)tileManager.TileSize.Height + topLeftTile.Y); coordinatePointed(TileCoordinatesConverter.GetCoordinates(zoom, pointTile)); actMousePosition = e.Location; //tooltip hide/ show if (toolTip != null) { if (e.X < toolTip.Left || e.X > toolTip.Right || e.Y < toolTip.Top || e.Y > toolTip.Bottom) { removeToolTip(); } } else if (startedAction == ActionType.none) { int offset = 5; foreach (OverlayItem item in overlayItems) { Point loc = getLocationForCoordinates(item.Coord); if (loc.X >= e.X - offset && loc.X <= e.X + offset && loc.Y >= e.Y - offset && loc.Y <= e.Y + offset) { addToolTip(loc, item.ToolTip); break; } } } // repaint if (startedAction != ActionType.none) { Invalidate(); } }
private void OpenStreetMapViewer_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { if (startedAction == ActionType.mark && ModifierKeys == markModifiers) { PointF pointTile = TileCoordinatesConverter.GetCoordinates(zoom, getTileCoordinatesFromLocation(e.Location)); float xMin = Math.Min(lastClickedCoord.X, pointTile.X); float xMax = Math.Max(lastClickedCoord.X, pointTile.X); float yMin = Math.Min(lastClickedCoord.Y, pointTile.Y); float yMax = Math.Max(lastClickedCoord.Y, pointTile.Y); TopLeftCoord = new PointF(xMin, yMax); BottomRightCoord = new PointF(xMax, yMin); coordinatesMarked(new PointF(xMin, yMax), new PointF(xMax, yMin)); } if (startedAction == ActionType.move && ModifierKeys == moveModifiers) { PointF pointTile = TileCoordinatesConverter.GetCoordinates(zoom, getTileCoordinatesFromLocation(e.Location)); PointF diff = new PointF(lastClickedCoord.X - pointTile.X, lastClickedCoord.Y - pointTile.Y); CenterCoord = new PointF(CenterCoord.X + diff.X, CenterCoord.Y + diff.Y); } } startedAction = ActionType.none; }
private void OpenStreetMapViewer_MouseDown(object sender, MouseEventArgs e) { if (startedAction == ActionType.none && e.Button == MouseButtons.Left) { lastClickedCoord = TileCoordinatesConverter.GetCoordinates(zoom, getTileCoordinatesFromLocation(e.Location)); lastMouseClick = e.Location; if (ModifierKeys == markModifiers) { startedAction = ActionType.mark; } else if (ModifierKeys == moveModifiers) { startedAction = ActionType.move; } else { startedAction = ActionType.none; } } else { startedAction = ActionType.none; } }
private void OpenStreetMapViewer_MouseClick(object sender, MouseEventArgs e) { coordinateClicked(TileCoordinatesConverter.GetCoordinates(zoom, getTileCoordinatesFromLocation(e.Location))); }