// Pan the image and handle hovering private void mapImage_MouseMove(object sender, MouseEventArgs e) { if (e.Button == _panButton) { _imageCenter.X += e.X - _prevX; _imageCenter.Y += e.Y - _prevY; ((PictureBox)sender).Invalidate(); _prevX = e.X; _prevY = e.Y; } bool inRange = false; if (MapDrawing.PointsOfInterest != null) { foreach (var poi in MapDrawing.PointsOfInterest.Reverse()) { if (poi.Enabled && poi.InRange(e.Location, _imageCenter, _imageSize)) { _hoverPoi = poi; inRange = true; break; } } } ((PictureBox)sender).Cursor = inRange ? Cursors.Hand : Cursors.SizeAll; if (!inRange) { _hoverPoi = null; } }
// Set up previous coordinates for panning and handle point selection private void mapImage_MouseDown(object sender, MouseEventArgs e) { if (e.Button == _panButton) { _prevX = e.X; _prevY = e.Y; } if (e.Button == _selectButton) { bool inRange = false; if (MapDrawing.PointsOfInterest != null) { foreach (var poi in MapDrawing.PointsOfInterest.Reverse()) { if (poi.Enabled && poi.InRange(e.Location, _imageCenter, _imageSize)) { inRange = true; _selectedPoi = poi; _detailsForm.UpdateDetails(poi); break; } } } if (!inRange) { _selectedPoi = null; } else { } } if (e.Button == _selectArbitraryButton) { //float x = (e.X - _imageCenter.X) / (float)(zoomSlider.Value * 4); //float y = (e.Y - _imageCenter.Y) / (float)(zoomSlider.Value * 4); //gpsDataX.Text = x.ToString(); //gpsDataZ.Text = y.ToString(); //using (System.IO.StreamWriter writer = new System.IO.StreamWriter("locations.csv", true)) // writer.WriteLineAsync($"\"{outputName.Text}\",\"{x}\",\"{y}\""); } ((PictureBox)sender).Invalidate(); }
public void UpdateDetails(MapDrawing.PointOfInterest poi) { titleLabel.Text = poi.Name; }