private void CreatePolyline()
{
try
{
if (Point1 == null || Point2 == null)
return;
var construct = new Polyline() as IConstructGeodetic;
if (construct == null)
return;
if (srf3 == null)
{
// if you don't use the activator, you will get exceptions
Type srType = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment");
srf3 = Activator.CreateInstance(srType) as ISpatialReferenceFactory3;
}
var linearUnit = srf3.CreateUnit((int)esriSRUnitType.esriSRUnit_Meter) as ILinearUnit;
construct.ConstructGeodeticLineFromPoints(GetEsriGeodeticType(), Point1, Point2, linearUnit, esriCurveDensifyMethod.esriCurveDensifyByDeviation, -1.0);
var mxdoc = ArcMap.Application.Document as IMxDocument;
var av = mxdoc.FocusMap as IActiveView;
UpdateDistance(construct as IGeometry);
UpdateAzimuth(construct as IGeometry);
//var color = new RgbColorClass() { Red = 255 } as IColor;
AddGraphicToMap(construct as IGeometry);
ResetPoints();
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}