I am looking to create polygons (halos/rings) around the mouse cursor. I have figured out how to create the halos by using System.Windows.Forms.Control.MousePosition and then converting into lat/long by using MapView.Active.ScreenToMap. I have also used a MouseHook from the Win32Api to give me a MouseMove event. This allows me to associate the polygon to the mouse cursor and move it around the map as an overlay.
The problem that I am having now is that I can only create a polygon (halo/ring) with a radius in pixels. I need to be able to use map units, like feet, meters, miles, kilometers, etc. For example, I want to create a polygon (halo/ring) that has a radius of 100 feet.
Is there some way to accomplish this?
The following is a method that I am using that takes pixels to create the halo, just in case it would be of help to someone:
private ArcGIS.Core.Geometry.Polygon CreateHaloPolygon(MapPoint mapPoint, int pixels, out double radius)
{
// Get the halo radius
Point screenPoint = MapView.Active.MapToScreen(mapPoint);
Point radiusScreenPoint = new Point((screenPoint.X + pixels), screenPoint.Y);
MapPoint radiusMapPoint = MapView.Active.ScreenToMap(radiusScreenPoint);
radius = GeometryEngine.Instance.Distance(mapPoint, radiusMapPoint);
// Build a circle geometry
Coordinate2D coord2D = new Coordinate2D(mapPoint);
EllipticArcSegment arcSegment = EllipticArcBuilder.CreateEllipticArcSegment(coord2D, radius, esriArcOrientation.esriArcClockwise, SpatialReferences.WGS84); //MapView.Active.Map.SpatialReference);
PolygonBuilder polyBuilder = new PolygonBuilder(new[] { arcSegment });
return polyBuilder.ToGeometry();
}