ArcEngine+C#画点、线、面

IFeatureClass pFeatCls;//好像不能放函数体里面,放里出现提示。
IFeature pFeat;

private void JudgeLayerType()
{
IElement pEle;
//在绘制前,清除mainkMapControl中的任何图形元素
IGraphicsContainer pGra = mainMapControl.Map as IGraphicsContainer;
IActiveView pAcitveView = pGra as IActiveView;
pGra.DeleteAllElements();
//画点

if (pFeatCls.ShapeType == esriGeometryType.esriGeometryPoint )
{
IMarkerElement pMakEle = new MarkerElementClass();
pEle = pMakEle as IElement;
IMarkerSymbol pMakSym = new SimpleMarkerSymbolClass();
pMakSym.Color = this.getRGBColor(0, 0, 255);
pMakEle.Symbol = pMakSym;
pEle.Geometry = pFeat.Shape;
pGra.AddElement(pEle, 0);
pAcitveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
}
//画线
else if (pFeatCls.ShapeType == esriGeometryType.esriGeometryPolyline)
{
ILineElement pLineEle = new LineElementClass();
pEle = pLineEle as IElement;
ILineSymbol pLineSym = new SimpleLineSymbolClass();
pLineSym.Color = this.getRGBColor(0, 0, 255);
pLineSym.Width = 2;
pLineEle.Symbol = pLineSym;
pEle.Geometry = pFeat.Shape;
pGra.AddElement(pEle, 0);
pAcitveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
}
//画面
else if (pFeatCls.ShapeType == esriGeometryType.esriGeometryPolygon)
{
IFillShapeElement pFillShapeEle = new PolygonClass() as IFillShapeElement;
pEle = pFillShapeEle as IElement;
IFillSymbol pFillSym = new SimpleFillSymbolClass();
pFillSym.Color = this.getRGBColor(0, 0, 255);
pFillShapeEle.Symbol = pFillSym;
pEle.Geometry = pFeat.Shape;
pGra.AddElement(pEle, 0);
pAcitveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
}
}
 

本文出自 “月明天蓝” 博客,转载请与作者联系!

你可能感兴趣的:(C#)