While adding a new feature to a feature layer I like to show the size (area)/length of the sketch so that the user has a better feedback while placing the vertexes.
So I hook up MapControl's OnMouseMove and get the IEngineEditSketch
. But that one only gives me the size/length without the current mouse position beeing a vertex. So I tried to add that point to a clone but the size of the clone still is the size without the actual mouse position.
So how can I show the user the size/length the feature would have, if he/she would add a vertex at the current mouse position?
private void mapControl_OnMouseMove(object sender, IMapControlEvents2_OnMouseMoveEvent e)
{
if (m_engineEditor.EditState == esriEngineEditState.esriEngineStateEditing)
{
IEngineEditSketch editSketch = m_engineEditor as IEngineEditSketch;
if (editSketch != null)
{
switch (editSketch.GeometryType)
{
case esriGeometryType.esriGeometryPoint:
// TODO
break;
case esriGeometryType.esriGeometryPolygon:
IPolygon polygon = editSketch.Geometry as IPolygon;
if (polygon != null)
{
IClone clone = polygon as IClone;
if (clone != null)
{
IPolygon copyPolygon = clone.Clone() as IPolygon;
IPointCollection copyPoints = copyPolygon as IPointCollection;
if (copyPolygon != null && copyPoints != null)
{
IPoint thisPoint = new PointClass() { X = e.mapX, Y = e.mapY };
copyPoints.AddPoint(thisPoint);
copyPolygon.Close();
IArea area = copyPolygon as IArea;
if (area != null)
{
StatusText = String.Format("Area: {0}", area.Area);
}
}
}
}
break;
case esriGeometryType.esriGeometryPolyline:
// TODO
break;
default:
break;
}
}
}
}