IEnvelope pEnv = (IEnvelope)e.newEnvelope;
IGraphicsContainer pGra = axMapControl1.Map as IGraphicsContainer;
IActiveView pAv = pGra as IActiveView;
pGra.DeleteAllElements();
IRectangleElement pRectangleEle = new RectangleElementClass();
IElement pEle = pRectangleEle as IElement;
pEle.Geometry = pEnv;
IRgbColor pColor = new RgbColorClass();
pColor.Red = 255;
pColor.Green = 0;
pColor.Blue = 0;
pColor.Transparency = 255;
ILineSymbol pOutline = new SimpleLineSymbolClass();
pOutline.Width = 2;
pOutline.Color = pColor;
pColor.Transparency = 0;
IFillSymbol pFillSymbol = new SimpleFillSymbolClass();
pFillSymbol.Color = pColor;
pFillSymbol.Outline = pOutline;
IFillShapeElement pFillShapeEle = pEle as IFillShapeElement;
pFillShapeEle.Symbol = pFillSymbol;
pGra.AddElement((IElement)pFillShapeEle, 0);
pAv.PartialRefresh(esriViewDrawPhase.esriViewGraphics,null,null);
仔细思考了一下,使用了ArcMap,添加了一些Element,这些Element是指Draw工具栏添加的图形文字等东西.,这些东西是一张地图拥有一个,而不是一个图层拥有一个,是存储在mxd文件中,而不是存储在shp文件中的。
所有这个Element是用来显示的东西,而不是实际的地图数据。
有个用法,比如为选择的Feature建立一个Element ,然后将它特殊显示。