ArcEngine中画shape点的另一种方法
废话不多说,直接上代码。
public override void OnMouseDown(int Button, int Shift, int X, int Y)
{
//base.OnMouseDown(Button, Shift, X, Y);
IFeatureLayer pFeatureLayer = mapControl.Map.get_Layer(0) as IFeatureLayer;
IFeatureClass fc = pFeatureLayer.FeatureClass;
IFeatureClassWrite fr = fc as IFeatureClassWrite;
IWorkspaceEdit pWorkspaceEdit = (fc as IDataset).Workspace as IWorkspaceEdit;
IFeature pFeature;
IPoint pPoint;
//开始事物操作
pWorkspaceEdit.StartEditing(false);
//开始编辑
pWorkspaceEdit.StartEditOperation();
pFeature = fc.CreateFeature();
pPoint = new PointClass();
IPoint Mp = mapControl.ToMapPoint(X, Y);
pPoint.PutCoords(Mp.X, Mp.Y);
pPoint.SpatialReference = mapControl.SpatialReference;
pFeature.Shape = pPoint;
pFeature.Store();
mapControl.ActiveView.Refresh();
if (Button == 2)
{
pWorkspaceEdit.StopEditOperation();
pWorkspaceEdit.StopEditing(true);
}
}
转载自:https://blog.csdn.net/Scarlett_OHara/article/details/51163573