1

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;
      }
    }
  }
}
2
  • do u have a solution for your question ?
    – webrider43
    Oct 11, 2016 at 14:20
  • This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. You can also add a bounty to draw more attention to this question once you have enough reputation. - From Review Oct 11, 2016 at 14:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.