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; } }
private void stopEditingToolStripMenuItem_Click(object sender, EventArgs e) { miStopEditing.Enabled = false; miStartEditing.Enabled = true; if (drawPolygon != null) { drawPolygon.set_drawStart(false);//Stop creating polygons drawPolygon = null; } }