private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { double x, y, lat, lon; _getXY(e.Location, out x, out y); _ortho.ToSphere(x, y, out lat, out lon); string text = null; WSMCountry cDef = _ttC.GetDataAtPointer(e) as WSMCountry; string country = (cDef == null ? "Sea" : cDef.Name); if (!double.IsNaN(lat) && !double.IsNaN(lon)) { text = "Latitude:" + GeoCoordinateUtilities.FormatLatitude(lat) + " Longitude:" + GeoCoordinateUtilities.FormatLongitude(lon); _pointerGeoCoordinate = new GeoCoordinate(lat, lon); } else { _pointerGeoCoordinate = null; country = "SPACE"; } text += (" [" + country + "]"); _pointerText = text; if (!toolStripButtonPICK.Checked && _mdOrtho != null) { // moving view double deltaDeg = 90.0 / _worldScreenRadius; double φ0 = _mdOrtho.φ0 + deltaDeg * (e.Location.Y - _mdsy); if (φ0 > 90) { φ0 = 90; } if (φ0 < -90) { φ0 = -90; } double λ0 = _mdOrtho.λ0 - deltaDeg * (e.Location.X - _mdsx); λ0 = OrthographicProjection.SanitizeLongitude(λ0); trackBar1.Value = (int)Math.Round(φ0 * 100); trackBar2.Value = (int)Math.Round(λ0 * 100); _updateProjection(); _invalidateAllLayers(true); return; } // not moving view _mouseOverCountry = cDef; _layerDynamic1.Dirty = true; _layerDynamic2.Dirty = true; pictureBox1.Refresh(); }
private BaseCoordinate GetCentralGeoCoordinate() { List <GeoCoordinate> geoCoords = new List <GeoCoordinate>(); foreach (WSMPolygon poly1 in Collection) { foreach (var pt1 in poly1.Collection) { geoCoords.Add(new GeoCoordinate(pt1.Latitude, pt1.Longitude)); } } GeoCoordinate gc = GeoCoordinateUtilities.GetCentralGeoCoordinate(geoCoords); BaseCoordinate fC = new BaseCoordinate(gc); return(fC); }
private void _paintDYNAMIC2(Graphics g) { Point loc = pictureBox1.PointToClient(MousePosition); if (_mouseOverCountry != null) { // outlines _drawCountryOutline(g, _mouseOverCountry, Pens.Red); if (Math.Abs(loc.X - _countryAnnotPos.X) > 20 || Math.Abs(loc.Y - _countryAnnotPos.Y) > 20) { _countryAnnotPos = loc; } _drawStandoutString(g, _mouseOverCountry.Name, Brushes.White, _countryAnnotPos.X, _countryAnnotPos.Y - 20); } if (toolStripButtonPICK.Checked) { if (_pointerGeoCoordinate != null) { List <PointF> ptList = new List <PointF>(); double x, y; for (double azimuth = 0; azimuth < 360; azimuth += 10) { GeoCoordinate gc = GeoCoordinateUtilities.GetEndPoint(_pointerGeoCoordinate, azimuth, _pickRadius); if (_ortho.ToTangentPlane(gc.Latitude, gc.Longitude, out x, out y)) { PointF pt = _convertF(x, y); ptList.Add(pt); } } if (ptList.Count > 2) { g.FillPolygon(_radBrush, ptList.ToArray()); } } } _drawStandoutString(g, _pointerText, Brushes.White, 2, pictureBox1.Height - 20); }