arcgis engine 鹰眼的主要代码

来源:互联网 发布:域名权能转到个人吗 编辑:程序博客网 时间:2024/04/28 13:07

主要是实现主窗口的OnExtentUpdate事件,首先获取鹰眼窗口的map作为activeView和GraphicContainer。然后在graphicContainer中画图,将画好的fillShapeElement加到graphicContainer中,最后更新activeView。

private void axMapControl1_OnExtentUpdated(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnExtentUpdatedEvent e)
       {
           ESRI.ArcGIS.Geometry.IEnvelope envelope = (ESRI.ArcGIS.Geometry.IEnvelope)e.newEnvelope;
           ESRI.ArcGIS.Carto.IGraphicsContainer graphicsContainer = axMapControl2.Map as ESRI.ArcGIS.Carto.IGraphicsContainer;

           ESRI.ArcGIS.Carto.IActiveView activeView = graphicsContainer as ESRI.ArcGIS.Carto.IActiveView;

           graphicsContainer.DeleteAllElements();

           ESRI.ArcGIS.Carto.IElement element = new ESRI.ArcGIS.Carto.RectangleElementClass();
           element.Geometry = envelope;

           ESRI.ArcGIS.Display.ILineSymbol outlineSymbol = new ESRI.ArcGIS.Display.SimpleLineSymbolClass();
           outlineSymbol.Width = 2;
           outlineSymbol.Color = getColor(255, 0, 0, 255);

           ESRI.ArcGIS.Display.IFillSymbol fillSymbol = new ESRI.ArcGIS.Display.SimpleFillSymbolClass();
           fillSymbol.Color = getColor(255, 0, 0, 0);
           fillSymbol.Outline = outlineSymbol;

           ESRI.ArcGIS.Carto.IFillShapeElement fillShapeElement = element as ESRI.ArcGIS.Carto.IFillShapeElement;
           fillShapeElement.Symbol = fillSymbol;

           graphicsContainer.AddElement((ESRI.ArcGIS.Carto.IElement)fillShapeElement, 0);
           activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
       }

原创粉丝点击