private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e) { if (miStartEditing.Enabled == false) //Start Editing { DataOperator dataOperator = new DataOperator(axMapControl1.Map); ILayer layer = dataOperator.GetLayerByName(sEditLayerName); // Get the layer to edit IFeatureLayer featureLayer = layer as IFeatureLayer; IFeature feature; if (featureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPoint) //Edit point { IPoint point = new PointClass(); point.PutCoords(e.mapX, e.mapY); feature = dataOperator.AddGeometryToLayer(sEditLayerName, point); AddFeature addFeatureName = new AddFeature(feature, axMapControl1.Map, this); addFeatureName.ShowDialog(); } else if (featureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon) { if (drawPolygon == null)//Continue creating polygons when editting is not stopped { drawPolygon = new DrawPolygon(sEditLayerName, axMapControl1.Map, this); drawPolygon.set_drawStart(true); IPoint point = new PointClass(); point.PutCoords(e.mapX, e.mapY); drawPolygon.set_startPoint(point); //set start point drawPolygon.OnCreate(axMapControl1.Object); drawPolygon.set_polyFeedback(point); } } return; } }
public override void OnDblClick() //Stop drawing polygon { if (_drawStart) { _polygon = _polyFeedback.Stop(); DataOperator dataOperator = new DataOperator(m_map); ILayer layer = dataOperator.GetLayerByName(sLayerName); IFeatureLayer featureLayer = layer as IFeatureLayer; IFeature feature = dataOperator.AddGeometryToLayer(sLayerName, _polygon); //Add the new geometry to layer AddFeature addFeature = new AddFeature(feature, m_map, m_frmMain); addFeature.ShowDialog(); //Change the attributes _startPoint = null; } }