Esempio n. 1
0
        /// <summary>
        /// 主地图OnExtentUpdated事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void axMapControl1_OnExtentUpdated(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnExtentUpdatedEvent e)
        {
            //刷新axMapControl2
            axMapControl2.Refresh();
            //以主地图的Extent作为鹰眼红线框的大小范围
            IEnvelope pEnvelope = axMapControl1.Extent;
            //鹰眼强制转换为IGraphicsContainer
            //IGraphicsContainer是绘图容器接口, 主要功能是在MapControl控件类上添加绘图要素。
            IGraphicsContainer pGraphicsContainer = axMapControl2.Map as IGraphicsContainer;
            //鹰眼强制转换为pActiveView
            IActiveView pActiveView = pGraphicsContainer as IActiveView;

            //删除鹰眼原有要素
            pGraphicsContainer.DeleteAllElements();
            //实例化矩形框要素
            IRectangleElement pRectangleElement = new RectangleElementClass();
            //强转矩形要素框为要素
            IElement pElement = pRectangleElement as IElement;

            //赋值几何实体的最小外接矩形, 即包络线
            pElement.Geometry = pEnvelope;

            //使用面要素刷新(存在覆盖注释问题)
            //DrawPolyline2(pGraphicsContainer, pActiveView, pElement);

            //使用线要素刷新(已解决重叠问题)(推荐使用)
            //使用IScreenDisplay的DrawPolyline方法,在鹰眼视图画出红线框
            DrawPolyline(axMapControl2.ActiveView, pEnvelope);
        }
Esempio n. 2
0
        /// <summary>
        /// 当主图视野发生变化时,重新绘制鸟瞰图中的红色矩形框
        /// </summary>
        private void axMapControl1_OnExtentUpdated(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnExtentUpdatedEvent e)
        {
            // 得到新范围
            IEnvelope          pEnvelope          = (IEnvelope)e.newEnvelope;
            IGraphicsContainer pGraphicsContainer = axMapControl2.Map as IGraphicsContainer;
            IActiveView        pActiveView        = pGraphicsContainer as IActiveView;

            //在绘制前,清除axMapControl2中的任何图形元素
            pGraphicsContainer.DeleteAllElements();
            IRectangleElement pRectangleEle = new RectangleElementClass();
            IElement          pElement      = pRectangleEle as IElement;

            pElement.Geometry = pEnvelope;
            //设置鹰眼图中的红线框
            IRgbColor pColor = new RgbColorClass();

            pColor.Red = 255; pColor.Green = 0; pColor.Blue = 0; pColor.Transparency = 255;
            //产生一个线符号对象
            ILineSymbol pOutline = new SimpleLineSymbolClass();

            pOutline.Width = 3; pOutline.Color = pColor;
            //设置颜色属性
            pColor     = new RgbColorClass();
            pColor.Red = 255; pColor.Green = 0; pColor.Blue = 0; pColor.Transparency = 0;
            //设置填充符号的属性
            IFillSymbol pFillSymbol = new SimpleFillSymbolClass();

            pFillSymbol.Color = pColor; pFillSymbol.Outline = pOutline;
            IFillShapeElement pFillShapeEle = pElement as IFillShapeElement;

            pFillShapeEle.Symbol = pFillSymbol;
            pGraphicsContainer.AddElement((IElement)pFillShapeEle, 0);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);//部分刷新
        }
Esempio n. 3
0
        private void DrawRectangle(IEnvelope pEnvelope)
        {
            IGraphicsContainer pGraphicsContainer = axMapControl2.Map as IGraphicsContainer;
            IActiveView        pActiveView        = pGraphicsContainer as IActiveView;

            pGraphicsContainer.DeleteAllElements();
            IRectangleElement pRectangleElement = new RectangleElementClass();
            IElement          pElement          = pRectangleElement as IElement;

            pElement.Geometry = pEnvelope;
            IRgbColor pRgbColor = new RgbColorClass();

            pRgbColor.Red          = 255;
            pRgbColor.Blue         = 0;
            pRgbColor.Green        = 0;
            pRgbColor.Transparency = 255;
            ILineSymbol pLineSymbol = new SimpleLineSymbolClass();

            pLineSymbol.Width      = 3;
            pLineSymbol.Color      = pRgbColor;
            pRgbColor.Red          = 255;
            pRgbColor.Blue         = 0;
            pRgbColor.Green        = 0;
            pRgbColor.Transparency = 0;
            IFillSymbol pFillSymbol = new SimpleFillSymbolClass();

            pFillSymbol.Outline = pLineSymbol;
            pFillSymbol.Color   = pRgbColor;
            IFillShapeElement pFillShapeElement = pElement as IFillShapeElement;

            pFillShapeElement.Symbol = pFillSymbol;
            pGraphicsContainer.AddElement((IElement)pFillShapeElement, 0);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Esempio n. 4
0
        private void mainMapControl_OnExtentUpdated(object sender, IMapControlEvents2_OnExtentUpdatedEvent e)
        {
            IEnvelope pEnvelope = e.newEnvelope as IEnvelope;

            ISimpleLineSymbol pSimpleLineSymbol = new SimpleLineSymbolClass();

            pSimpleLineSymbol.Style = esriSimpleLineStyle.esriSLSDash;
            pSimpleLineSymbol.Width = 2;
            pSimpleLineSymbol.Color = this.getRGBColor(0, 0, 0);

            ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbolClass();

            pSimpleFillSymbol.Color   = this.getRGBColor(255, 0, 0);
            pSimpleFillSymbol.Outline = pSimpleLineSymbol as ILineSymbol;
            pSimpleFillSymbol.Style   = esriSimpleFillStyle.esriSFSHollow;


            IRectangleElement pRectangleElement = new RectangleElementClass();
            IElement          pElement          = pRectangleElement as IElement;

            pElement.Geometry = pEnvelope as IGeometry;
            IFillShapeElement pFillShapeElement = pRectangleElement as IFillShapeElement;

            pFillShapeElement.Symbol = pSimpleFillSymbol as IFillSymbol;

            IGraphicsContainer pGraphicsContainer = this.EagleaxMapControl.Map as IGraphicsContainer;

            pGraphicsContainer.DeleteAllElements();
            pGraphicsContainer.AddElement(pElement, 0);

            this.EagleaxMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Esempio n. 5
0
        private void axMapControl1_OnExtentUpdated(object sender, IMapControlEvents2_OnExtentUpdatedEvent e)
        {
            //新建一个矩形元素对象
            IElement ele = new RectangleElementClass();

            //矩形设置为主地图的显示范围
            ele.Geometry = axMapControl1.Extent;
            //新建一个简单填充样式对象
            IFillSymbol symbol = new SimpleFillSymbolClass();
            //新建一个RGB颜色对象
            IRgbColor clr = new RgbColorClass();

            //设置填充样式对象的颜色为无色、透明
            clr.NullColor    = true;
            clr.Transparency = 0;
            symbol.Color     = clr;
            //新建一个线样式对象
            ILineSymbol linSymbol = new SimpleLineSymbolClass();
            //设置填充样式对象的边框为红色
            IRgbColor linClr = new RgbColorClass();

            linClr.Red      = 255;
            linSymbol.Color = linClr;
            symbol.Outline  = linSymbol;
            //用填充样式对象来绘制矩形元素
            ((IFillShapeElement)ele).Symbol = symbol;
            //删除鹰眼中的所有元素
            axMapControl2.ActiveView.GraphicsContainer.DeleteAllElements();
            //将矩形元素添加到鹰眼中,并局部刷新
            axMapControl2.ActiveView.GraphicsContainer.AddElement(ele, 0);
            axMapControl2.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Esempio n. 6
0
        /// <summary>
        /// 主窗体视图范围变化
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void axMapControl1_OnExtentUpdated(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnExtentUpdatedEvent e)
        {
            //获得当前地图视图的外包矩形
            IEnvelope pEnvelope = (IEnvelope)e.newEnvelope;

            //获得GraphicsContainer对象用来管理元素对象
            IGraphicsContainer pGraphicsContainer = axMapControl2.Map as IGraphicsContainer;

            //清除对象中的所有图形元素
            pGraphicsContainer.DeleteAllElements();

            //获得矩形图形元素
            IRectangleElement pRectangleEle = new RectangleElementClass();
            IElement          pElement      = pRectangleEle as IElement;

            pElement.Geometry = pEnvelope;


            //设置FillShapeElement对象的symbol
            IFillShapeElement pFillShapeEle = pElement as IFillShapeElement;

            pFillShapeEle.Symbol = this.Presenter.getFillSymbol();

            //进行填充
            pGraphicsContainer.AddElement((IElement)pFillShapeEle, 0);

            //刷新视图
            IActiveView pActiveView = pGraphicsContainer as IActiveView;

            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Esempio n. 7
0
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            {
                IEnvelope envelope = this.m_pMapControl.TrackRectangle();
                if (envelope == null)
                {
                    return;
                }
                IRectangleElement rectangleElement = new RectangleElementClass();
                IElement          element          = (IElement)rectangleElement;
                element.Geometry = envelope as IGeometry;
                ISimpleFillSymbol pSFSym;
                IFillShapeElement pElemFillShp;
                pElemFillShp = (IFillShapeElement)element;
                pSFSym       = new SimpleFillSymbolClass();
                Color  color  = ColorTranslator.FromHtml(SystemInfo.Instance.FillColor);
                IColor pColor = new RgbColorClass();
                pColor.RGB          = color.B * 65536 + color.G * 256 + color.R;
                pSFSym.Color        = pColor;
                pSFSym.Style        = esriSimpleFillStyle.esriSFSSolid;
                pElemFillShp.Symbol = pSFSym;

                this.m_pMapControl.ActiveView.GraphicsContainer.AddElement(element, 0);
                this.m_pMapControl.ActiveView.Refresh();
            }
            base.OnMouseDown(button, shift, x, y, mapX, mapY);
        }
Esempio n. 8
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (this.mapGridBorderPropertyPage_0.OutlineSymbol != null)
     {
         IElement    element = new RectangleElementClass();
         IFillSymbol symbol  = new SimpleFillSymbolClass
         {
             Outline = this.mapGridBorderPropertyPage_0.OutlineSymbol
         };
         (symbol as ISimpleFillSymbol).Style   = esriSimpleFillStyle.esriSFSNull;
         (element as IFillShapeElement).Symbol = symbol;
         IEnvelope envelope = (this.imapFrame_0 as IElement).Geometry.Envelope;
         envelope.Expand(1.0, 1.0, false);
         element.Geometry = envelope;
         IFrameElement element2 = new FrameElementClass();
         (element2 as IElement).Geometry = envelope;
         IGroupElement group = new GroupElementClass();
         this.igraphicsContainer_0.MoveElementToGroup(element, group);
         this.igraphicsContainer_0.MoveElementToGroup(element2 as IElement, group);
         this.igraphicsContainer_0.AddElement(group as IElement, 0);
     }
     if (this.mapGridBorderPropertyPage_0.IsGenerateGraphics)
     {
         this.m_pMapGrid.GenerateGraphics(this.imapFrame_0, this.igraphicsContainer_0);
     }
 }
Esempio n. 9
0
 private void DrawEagleExtent(IEnvelope myEnvelope)
 {
     if (EnviVars.instance.EagleVisible)
     {
         this._mapControlEagle.ActiveView.GraphicsContainer.DeleteAllElements();
         IRectangleElement rectangleElement = new RectangleElementClass();
         IElement          element          = rectangleElement as IElement;
         element.Geometry = myEnvelope;
         IRgbColor rgbColor = new RgbColorClass();
         rgbColor.Red   = 255;
         rgbColor.Green = 0;
         rgbColor.Blue  = 0;
         ILineSymbol lineSymbol = new SimpleLineSymbolClass();
         lineSymbol.Color = rgbColor;
         lineSymbol.Width = 1.5;
         IRgbColor rgbColor2 = new RgbColorClass();
         rgbColor2.Transparency = 0;
         IFillSymbol fillSymbol = new SimpleFillSymbolClass();
         fillSymbol.Color   = rgbColor2;
         fillSymbol.Outline = lineSymbol;
         IFillShapeElement fillShapeElement = rectangleElement as IFillShapeElement;
         fillShapeElement.Symbol = fillSymbol;
         this._mapControlEagle.ActiveView.GraphicsContainer.AddElement(element, 0);
         this._mapControlEagle.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
     }
 }
Esempio n. 10
0
        //在鹰眼地图上面画矩形框
        public static void DrawRectangle(IEnvelope pIEnvelope)
        {
            //在绘制前,清除鹰眼中之前绘制的矩形框
            IGraphicsContainer pGraphicsContainer = Variable.pEagleEyeMapFrm.EagelEyeMapControl.Map as IGraphicsContainer;
            IActiveView        pActiveView        = pGraphicsContainer as IActiveView;

            pGraphicsContainer.DeleteAllElements();
            //得到当前视图范围
            IRectangleElement pRectangleElement = new RectangleElementClass();
            IElement          pElement          = pRectangleElement as IElement;

            pElement.Geometry = pIEnvelope;
            //设置矩阵框(实质为中间透明度面)
            IRgbColor pRgbColor = new RgbColorClass();

            pRgbColor = GetRgbColor(255, 0, 0);
            pRgbColor.Transparency = 255;
            ILineSymbol pOutLine = new SimpleLineSymbolClass();

            pOutLine.Width = 2;            pOutLine.Color = pRgbColor;

            IFillSymbol pFillSymbol = new SimpleFillSymbolClass();

            pRgbColor = new RgbColorClass();
            pRgbColor.Transparency = 0;
            pFillSymbol.Color      = pRgbColor;
            pFillSymbol.Outline    = pOutLine;
            //向鹰眼中添加矩形框
            IFillShapeElement pFillShapeElement = pElement as IFillShapeElement;

            pFillShapeElement.Symbol = pFillSymbol;
            pGraphicsContainer.AddElement((IElement)pFillShapeElement, 0);
            //刷新
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Esempio n. 11
0
        /// <summary>
        /// 在图形容器中创建元素
        /// </summary>
        /// <param name="graphicsContainer">图形容器,新建的元素将添加到该图形容器中</param>
        /// <param name="geometry">几何图形</param>
        /// <param name="eType">元素类型(点、线、面、文本等)</param>
        /// <returns></returns>
        public static IElement CreateElement(this IGraphicsContainer graphicsContainer, IGeometry geometry, EDrawElementType eType)
        {
            IElement element = null;

            switch (eType)
            {
            case EDrawElementType.Point:
                if (!(geometry is IPoint))
                {
                    throw new ArgumentException($"参数{nameof(geometry)}不是点({typeof(IPoint)}),无法由此创建点元素");
                }
                element = new MarkerElementClass();
                break;

            case EDrawElementType.Polyline:
                if (!(geometry is IPolyline))
                {
                    throw new ArgumentException($"参数{nameof(geometry)}不是折线({typeof(IPolyline)}),无法由此创建线元素");
                }
                element = new LineElementClass();
                break;

            case EDrawElementType.Polygon:
                if (!(geometry is IPolygon))
                {
                    throw new ArgumentException($"参数{nameof(geometry)}不是多边形({typeof(IPolygon)}),无法由此创建多边形元素");
                }
                element = new PolygonElementClass();
                break;

            case EDrawElementType.Circle:
                if (!(geometry is IPolygon))
                {
                    throw new ArgumentException($"参数{nameof(geometry)}不是多边形({typeof(IPolygon)}),无法由此创建圆形元素");
                }
                element = new PolygonElementClass();
                break;

            case EDrawElementType.Rectangle:
                if (!(geometry is IEnvelope))
                {
                    throw new ArgumentException($"参数{nameof(geometry)}不是矩形框({typeof(IEnvelope)}),无法由此创建矩形元素");
                }
                element = new RectangleElementClass();
                break;

            case EDrawElementType.Text:
                if (!(geometry is IPoint))
                {
                    throw new ArgumentException($"参数{nameof(geometry)}不是点({typeof(IPoint)}),无法由此创建文本元素");
                }
                element = new TextElementClass();
                break;
            }
            element.Geometry = geometry;
            graphicsContainer.AddElement(element, 0);
            return(element);
        }
Esempio n. 12
0
        /// <summary>
        /// 在图形容器中创建矩形元素
        /// </summary>
        /// <param name="graphicsContainer">图形容器,新建的元素将添加到该图形容器中</param>
        /// <param name="envelope">矩形,用于创建矩形元素</param>
        /// <returns></returns>
        public static IFillShapeElement CreateRectangleElement(this IGraphicsContainer graphicsContainer, IEnvelope envelope)
        {
            IFillShapeElement rectangleEmenet = new RectangleElementClass();
            IElement          element         = (IElement)rectangleEmenet;

            element.Geometry = envelope;

            graphicsContainer.AddElement(element, 0);
            return(rectangleEmenet);
        }
Esempio n. 13
0
        /// <summary>
        /// 创建图形元素
        /// </summary>
        /// <param name="pGeometry">几何图形</param>
        /// <param name="lineColor">边框颜色</param>
        /// <param name="fillColor">填充颜色</param>
        /// <returns></returns>
        private static IElement CreateElement(IGeometry pGeometry, IRgbColor lineColor, IRgbColor fillColor)
        {
            if (pGeometry == null || lineColor == null || fillColor == null)
            {
                return(null);
            }
            IElement pElem = null;

            try
            {
                if (pGeometry is IEnvelope)
                {
                    pElem = new RectangleElementClass();
                }
                else if (pGeometry is IPolygon)
                {
                    pElem = new PolygonElementClass();
                }
                else if (pGeometry is ICircularArc)
                {
                    ISegment           pSegCircle = pGeometry as ISegment;//QI
                    ISegmentCollection pSegColl   = new PolygonClass();
                    object             o          = Type.Missing;
                    pSegColl.AddSegment(pSegCircle, ref o, ref o);
                    IPolygon pPolygon = pSegColl as IPolygon;
                    pGeometry = pPolygon as IGeometry;
                    pElem     = new CircleElementClass();
                }
                else if (pGeometry is IPolyline)
                {
                    pElem = new LineElementClass();
                }

                if (pElem == null)
                {
                    return(null);
                }
                pElem.Geometry = pGeometry;
                IFillShapeElement pFElem  = pElem as IFillShapeElement;
                ISimpleFillSymbol pSymbol = new SimpleFillSymbolClass();
                pSymbol.Color         = fillColor;
                pSymbol.Outline.Color = lineColor;
                pSymbol.Style         = esriSimpleFillStyle.esriSFSCross;
                if (pSymbol == null)
                {
                    return(null);
                }
                pFElem.Symbol = pSymbol;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return(pElem);
        }
Esempio n. 14
0
        private void UCMap_OnExtentUpdated(object sender, IMapControlEvents2_OnExtentUpdatedEvent e)
        {
            if (scaleUpdated != null)
            {
                scaleUpdated(MapScale);
            }

            ucMapNavigate1.MapScale = (int)base.MapScale;

            // 得到新范围
            IEnvelope          pEnv = (IEnvelope)e.newEnvelope;
            IGraphicsContainer pGra = this.Map as IGraphicsContainer;
            IActiveView        pAv  = pGra as IActiveView;

            //在绘制前,清除axMapControl2中的任何图形元素
            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 = 1;
            pOutline.Color = pColor;

            //设置颜色属性
            pColor              = new RgbColorClass();
            pColor.Red          = 255;
            pColor.Green        = 0;
            pColor.Blue         = 0;
            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);
        }
Esempio n. 15
0
        private void axSceneControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.ISceneControlEvents_OnMouseDownEvent e)
        {
            ICamera   pCamera = this.axSceneControl1.Camera;
            IPoint    point   = pCamera.Target;
            IEnvelope pEnv    = new EnvelopeClass();

            pEnv.XMax = point.X + 2;
            pEnv.XMin = point.X - 2;
            pEnv.YMax = point.Y + 2;
            pEnv.YMin = point.Y - 2;

            IRectangleElement pRectangleEle = new RectangleElementClass();
            IElement          pEle          = pRectangleEle as IElement;

            pEle.Geometry = pEnv;

            //设置线框的边线对象,包括颜色和线宽
            IRgbColor pColor = new RgbColorClass();

            pColor.Red          = 238;
            pColor.Green        = 99;
            pColor.Blue         = 99;
            pColor.Transparency = 255;
            // 产生一个线符号对象
            ILineSymbol pOutline = new SimpleLineSymbolClass();

            pOutline.Width = 1;
            pOutline.Color = pColor;

            // 设置颜色属性
            pColor.Red          = 238;
            pColor.Green        = 99;
            pColor.Blue         = 99;
            pColor.Transparency = 0;

            // 设置线框填充符号的属性
            IFillSymbol pFillSymbol = new SimpleFillSymbolClass();

            pFillSymbol.Color   = pColor;
            pFillSymbol.Outline = pOutline;
            IFillShapeElement pFillShapeEle = pEle as IFillShapeElement;

            pFillShapeEle.Symbol = pFillSymbol;

            // 得到鹰眼视图中的图形元素容器
            IGraphicsContainer pGra = axMapControl1.Map as IGraphicsContainer;
            IActiveView        pAv  = pGra as IActiveView;

            // 在绘制前,清除 axMapControl1 中的任何图形元素
            pGra.DeleteAllElements();
            // 鹰眼视图中添加线框
            pGra.AddElement((IElement)pFillShapeEle, 0);
            // 刷新鹰眼
            pAv.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Esempio n. 16
0
        public void DrawEnvelope(IEnvelope envelope)
        {
            if (envelope == null)
            {
                return;
            }
            try
            {
                //将鹰眼地图设置为地理容器,再设置为活动视图
                IGraphicsContainer pGraphicsContainer = this.axMapControl.Map as IGraphicsContainer;
                IActiveView        pActiveView        = pGraphicsContainer as IActiveView;
                //清除鹰眼地图中的任何图形元素
                pGraphicsContainer.DeleteAllElements();
                //设置矩形范围
                IRectangleElement pRectangeEle = new RectangleElementClass();
                IElement          pElement     = pRectangeEle as IElement;
                pElement.Geometry = envelope;

                //创建鹰眼图中的红线框
                IRgbColor pColor = new RgbColor();
                pColor.Red          = 255;
                pColor.Blue         = 0;
                pColor.Green        = 0;
                pColor.Transparency = 255;
                //创建线符号对象
                ILineSymbol pOutline = new SimpleLineSymbolClass();
                pOutline.Width = 2;
                pOutline.Color = pColor;

                //设置颜色属性
                pColor              = new RgbColorClass();
                pColor.Red          = 255;
                pColor.Blue         = 0;
                pColor.Green        = 0;
                pColor.Transparency = 0;

                //设置填充符号
                IFillSymbol pFillSymbol = new SimpleFillSymbolClass();
                pFillSymbol.Color   = pColor;
                pFillSymbol.Outline = pOutline;

                IFillShapeElement pFillShapeEle = pElement as IFillShapeElement;
                pFillShapeEle.Symbol = pFillSymbol;

                pGraphicsContainer.AddElement((IElement)pFillShapeEle, 0);
                pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

                interEnvelope = envelope;
            }
            catch (Exception ex)
            {
                LoggingService.Error(ex.Message + "\r\n" + ex.StackTrace);
            }
        }
Esempio n. 17
0
        /// <summary>
        /// 创建图形元素
        /// </summary>
        /// <param name="geometry">几何图形</param>
        /// <param name="lineColor">边界颜色</param>
        /// <param name="fillColor">填充颜色</param>
        /// <returns>图形元素</returns>
        public static IElement CreateElement(IGeometry geometry, IRgbColor lineColor, IRgbColor fillColor)
        {
            if (geometry == null || lineColor == null || fillColor == null)
            {
                return(null);
            }
            IElement element = null;

            // 判断图形的类型
            if (geometry is IEnvelope)
            {
                element = new RectangleElementClass();
            }
            else if (geometry is IPolygon)
            {
                element = new PolygonElementClass();
            }
            else if (geometry is ICircularArc)
            {
                ISegment           segment           = geometry as ISegment;
                ISegmentCollection segmentCollection = new PolygonClass();
                segmentCollection.AddSegment(segment, Type.Missing, Type.Missing);
                IPolygon polygon = segmentCollection as IPolygon;
                geometry = polygon as IGeometry;
                element  = new CircleElementClass();
            }
            else if (geometry is IPolyline)
            {
                element = new LineElementClass();
            }

            if (element == null)
            {
                return(null);
            }

            element.Geometry = geometry;
            ISimpleFillSymbol symbol = new SimpleFillSymbolClass();

            symbol.Outline.Color = lineColor;
            symbol.Color         = fillColor;
            symbol.Style         = esriSimpleFillStyle.esriSFSCross;
            if (symbol == null)
            {
                return(null);
            }
            IFillShapeElement fillShapeElement = element as IFillShapeElement;

            fillShapeElement.Symbol = symbol;

            return(element);
        }
        private void axPageLayoutControl1_OnExtentUpdated(object sender, IPageLayoutControlEvents_OnExtentUpdatedEvent e)
        {
            //QI for IEnvelope
            IEnvelope envelope = (IEnvelope)e.newEnvelope;

            //Get the IElement interface by finding an element by its name
            IElement element = m_PageLayoutControl.FindElementByName("ZoomExtent", 1);

            if (element != null)
            {
                //Delete the graphic
                m_PageLayoutControl.GraphicsContainer.DeleteElement(element);
            }
            element = new RectangleElementClass();

            //Get the IRGBColor interface
            IRgbColor color = new RgbColorClass();

            //Set the color properties
            color.RGB          = 255;
            color.Transparency = 255;

            //Get the ILine symbol interface
            ILineSymbol outline = new SimpleLineSymbolClass();

            //Set the line symbol properties
            outline.Width = 10;
            outline.Color = color;

            //Set the color properties
            color              = new RgbColorClass();
            color.RGB          = 255;
            color.Transparency = 0;

            //Get the IFillSymbol properties
            IFillSymbol fillSymbol = new SimpleFillSymbolClass();

            //Set the fill symbol properties
            fillSymbol.Color   = color;
            fillSymbol.Outline = outline;

            //QI for IFillShapeElement interface through the IElement interface
            IFillShapeElement fillShapeElement = (IFillShapeElement)element;

            //Set the symbol property
            fillShapeElement.Symbol = fillSymbol;

            //Add the element
            m_PageLayoutControl.AddElement(element, e.newEnvelope, Type.Missing, "ZoomExtent", -1);
            //Refresh the graphics
            m_PageLayoutControl.Refresh(esriViewDrawPhase.esriViewGraphics, Type.Missing, Type.Missing);
        }
Esempio n. 19
0
            public static void DrawRectangle(IMapControl2 mapControl, IEnvelope envelope, IRgbColor fillColor, IRgbColor outColor, int outWidth)
            {
                IElement pElement = new RectangleElementClass()
                {
                    Symbol   = CreateSimpleFillSymbol(fillColor, outColor, outWidth),
                    Geometry = envelope
                };
                IGraphicsContainer pGC = mapControl.Map as IGraphicsContainer;

                pGC.DeleteAllElements();
                pGC.AddElement(pElement, 0);
                mapControl.Refresh(esriViewDrawPhase.esriViewGraphics);
            }
Esempio n. 20
0
        public void OverViewSynchronizeDraw(object sender, IMapControlEvents2_OnExtentUpdatedEvent e)
        {
            IEnvelope pEnv;

            pEnv = (IEnvelope)e.newEnvelope;

            IGraphicsContainer pGraphicsContrainer;

            IActiveView pActiveView;

            pGraphicsContrainer = (IGraphicsContainer)m_axMapControl.Map;
            pActiveView         = (IActiveView)pGraphicsContrainer;

            //在绘制新的矩形框前,清除Map对象中的任何图形元素
            pGraphicsContrainer.DeleteAllElements();

            IRectangleElement pRectangleEle = new RectangleElementClass();

            IElement pEle = (IElement)pRectangleEle;

            pEle.Geometry = pEnv;

            IRgbColor pColor;

            pColor              = new RgbColorClass();
            pColor.Red          = 255;
            pColor.Transparency = 255;

            ILineSymbol pOutLine = new SimpleLineSymbolClass();

            pOutLine.Width = 1;
            pOutLine.Color = pColor;

            pColor              = new RgbColorClass();
            pColor.Red          = 255;
            pColor.Transparency = 0;

            IFillSymbol pFillSymbol = new SimpleFillSymbolClass();

            pFillSymbol.Color   = pColor;
            pFillSymbol.Outline = pOutLine;

            IFillShapeElement pFillShapeEle;

            pFillShapeEle        = (IFillShapeElement)pEle;
            pFillShapeEle.Symbol = pFillSymbol;
            pEle = (IElement)pFillShapeEle;

            pGraphicsContrainer.AddElement(pEle, 0);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Esempio n. 21
0
        private void AddRectangleElement()
        {
            IEnvelope pEnvelope = axMapControl1.TrackRectangle();

            if (pEnvelope == null)
            {
                return;
            }
            IRectangleElement pRectangleElement = new RectangleElementClass();
            IElement          pElement          = pRectangleElement as IElement;

            pElement.Geometry = pEnvelope;
            AddElement(pElement);
        }
Esempio n. 22
0
        public static void DrawExtent(IEnvelope envelope, AxMapControl axMapControl_HawkEye)
        {
            IRgbColor fillColor = CreateRgbColor(0, 0, 0, 0);
            IRgbColor outColor  = CreateRgbColor(255, 0, 0);
            IElement  pElement  = new RectangleElementClass()
            {
                Geometry = envelope,
                Symbol   = CreateSimpleFillSymbol(fillColor, outColor, 2)
            };
            IGraphicsContainer pGC = axMapControl_HawkEye.Map as IGraphicsContainer;

            pGC.DeleteAllElements();
            pGC.AddElement(pElement, 0);
            axMapControl_HawkEye.Refresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Esempio n. 23
0
        /// <summary>
        /// 在地图上绘制图形(单一)
        /// </summary>
        /// <param name="envelope">图形外包络</param>
        /// <param name="mapControl">绘制目标(地图控件对象)</param>
        public static void DrawMapShape(IEnvelope envelope, IMapControl2 mapControl)
        {
            IElement pElement = new RectangleElementClass()
            {
                Geometry = envelope
            };
            IFillShapeElement pFillShapeElement = pElement as IFillShapeElement;

            pFillShapeElement.Symbol = getFillSymbol(getLineSymbol());
            IGraphicsContainer pGC = mapControl.Map as IGraphicsContainer;

            pGC.DeleteAllElements();
            pGC.AddElement(pElement, 0);
            mapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Esempio n. 24
0
    public void axMapControl1_OnExtentUpdated(AxMapControl axMapControl1, AxMapControl axMapControl2, object sender, IMapControlEvents2_OnExtentUpdatedEvent e)
    {
        //创建鹰眼中线框
        IEnvelope         pEnv          = (IEnvelope)e.newEnvelope;
        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.Red          = 255;
        pColor.Green        = 0;
        pColor.Blue         = 0;
        pColor.Transparency = 0;

        // 设置线框填充符号的属性
        IFillSymbol pFillSymbol = new SimpleFillSymbolClass();

        pFillSymbol.Color   = pColor;
        pFillSymbol.Outline = pOutline;
        IFillShapeElement pFillShapeEle = pEle as IFillShapeElement;

        pFillShapeEle.Symbol = pFillSymbol;

        // 得到鹰眼视图中的图形元素容器
        IGraphicsContainer pGra = axMapControl2.Map as IGraphicsContainer;
        IActiveView        pAv  = pGra as IActiveView;

        // 在绘制前,清除 axMapControl2 中的任何图形元素
        pGra.DeleteAllElements();
        // 鹰眼视图中添加线框
        pGra.AddElement((IElement)pFillShapeEle, 0);
        // 刷新鹰眼
        pAv.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
    }
Esempio n. 25
0
        /// <summary>
        /// 获得三维视图的显示范围,并在二维地图上显示
        /// </summary>
        /// <param name="pViewer"></param>
        void m_GlobeDisplayEvents_AfterDraw(ISceneViewer pViewer)
        {
            m_MapExtent = new EnvelopeClass();

            m_GlobeViewUtil.QueryVisibleGeographicExtent(m_MapExtent);

            IGraphicsContainer pGra = axMapControl1.Map as IGraphicsContainer;
            IActiveView        pAv  = pGra as IActiveView;

            pGra.DeleteAllElements();

            IRectangleElement rec = new RectangleElementClass();
            IElement          ele = rec as IElement;

            ele.Geometry = m_MapExtent;
            //创建颜色对象
            IRgbColor pColor = new RgbColorClass();

            pColor.Red   = 255;
            pColor.Green = 0;
            pColor.Blue  = 0;
            //创建线型对象并设置颜色和宽度
            ILineSymbol line = new SimpleLineSymbolClass();

            line.Color = pColor;
            line.Width = 2;

            pColor              = new RgbColorClass();
            pColor.Red          = 255;
            pColor.Green        = 0;
            pColor.Blue         = 0;
            pColor.Transparency = 0;//设置透明度

            IFillSymbol fill = new SimpleFillSymbolClass();

            fill.Outline = line;
            fill.Color   = pColor;

            IFillShapeElement pFillElement = ele as IFillShapeElement;

            pFillElement.Symbol = fill;



            pGra.AddElement((IElement)pFillElement, 0);

            pAv.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Esempio n. 26
0
        private static IElement CreateFillElement(IGeometry pGeometry, ISimpleFillSymbol pFillSym)
        {
            IFillShapeElement pFillEle = new RectangleElementClass();
            pFillEle.Symbol = pFillSym;
            IElement pElement = pFillEle as IElement;

            pElement.Geometry = pGeometry;

            IScreenDisplay pScrDisp = ArcMap.Document.ActiveView.ScreenDisplay;
            pElement.Activate(pScrDisp);

            pScrDisp.StartDrawing(0, (System.Int16)esriScreenCache.esriNoScreenCache);
            pElement.Draw(pScrDisp, null);
            pScrDisp.FinishDrawing();

            return pElement;
        }
Esempio n. 27
0
        private void axMapControl1_OnExtentUpdated(object sender, IMapControlEvents2_OnExtentUpdatedEvent e)
        {
            //定义边界对象
            IEnvelope pEnv;

            pEnv = e.newEnvelope as IEnvelope;
            IGraphicsContainer pGraphicsContainer;
            IActiveView        pActiveView;

            //获取鹰眼图地图数据的图形容器句柄
            pGraphicsContainer = axMapControl2.Map as IGraphicsContainer;
            pActiveView        = pGraphicsContainer as IActiveView;
            pGraphicsContainer.DeleteAllElements();
            IRectangleElement pRectangleEle;

            pRectangleEle = new RectangleElementClass();
            IElement pEle;

            pEle          = pRectangleEle as IElement;
            pEle.Geometry = pEnv;
            IRgbColor pColor;

            pColor              = new RgbColor();
            pColor.RGB          = 255;
            pColor.Transparency = 255;
            ILineSymbol pOutline;

            pOutline            = new SimpleLineSymbol();
            pOutline.Width      = 1;
            pOutline.Color      = pColor;
            pColor              = new RgbColor();
            pColor.RGB          = 255;
            pColor.Transparency = 0;
            IFillSymbol pFillSymbol;

            pFillSymbol         = new SimpleFillSymbol();
            pFillSymbol.Color   = pColor;
            pFillSymbol.Outline = pOutline;
            IFillShapeElement pFillshapeEle;

            pFillshapeEle        = pEle as IFillShapeElement;
            pFillshapeEle.Symbol = pFillSymbol;
            pEle = pFillshapeEle as IElement;
            pGraphicsContainer.AddElement(pEle, 0);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Esempio n. 28
0
        public static IFillShapeElement GetRectangleElement(IGeometry geometry)
        {
            IRectangleElement rectangleElement = new RectangleElementClass();
            IElement          element          = rectangleElement as IElement;

            //设置元素Geometry为当前范围
            element.Geometry = geometry;

            //创建红色矩形框符号,先线符号然后面符号
            ILineSymbol outline    = GetSimpleLineSymbol(2, GetRgbaColor(255, 0, 0, 255));
            IFillSymbol fillSymbol = GetSimpleFillSymbol(outline, GetRgbaColor(255, 0, 0, 0));

            //设置元素Symbol
            IFillShapeElement fillShapeElement = element as IFillShapeElement;

            fillShapeElement.Symbol = fillSymbol;
            return(fillShapeElement);
        }
Esempio n. 29
0
        private void Hawkeye_DrawExtent(IEnvelope envelope)
        {
            IGraphicsContainer pGC = axMapControl_hawkeye.Map as IGraphicsContainer;

            pGC.DeleteAllElements();
            IElement pElement = new RectangleElementClass()
            {
                Geometry = envelope,
                Symbol   = AeUtils.CreateSimpleFillSymbol(
                    AeUtils.CreateRgbColor(),          // 填充颜色 - 透明
                    AeUtils.CreateRgbColor(255, 0, 0), // 边框颜色 - 红色
                    2                                  // 边框大小
                    )
            };

            pGC.AddElement(pElement, 0);
            axMapControl_hawkeye.Refresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Esempio n. 30
0
        private void axMapControl1_OnExtentUpdated(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnExtentUpdatedEvent e)
        {
            IEnvelope          pEnvelope          = (IEnvelope)e.newEnvelope;
            IGraphicsContainer pGraphicsContainer = axMapControl2.Map as IGraphicsContainer;
            IActiveView        pActiveView        = pGraphicsContainer as IActiveView;

            pGraphicsContainer.DeleteAllElements();
            IRectangleElement pRectangleEle = new RectangleElementClass();
            IElement          pElement      = pRectangleEle as IElement;

            pElement.Geometry = pEnvelope;
            IRgbColor pColor = new RgbColorClass();

            pColor.Red          = 255;
            pColor.Green        = 0;
            pColor.Blue         = 0;
            pColor.Transparency = 255;
            ILineSymbol pOutline = new SimpleLineSymbolClass();

            pOutline.Width = 3;
            pOutline.Color = pColor;
            //设置颜色属性
            pColor              = new RgbColorClass();
            pColor.Red          = 255;
            pColor.Green        = 0;
            pColor.Blue         = 0;
            pColor.Transparency = 0;

            IFillSymbol pFillSymbol = new SimpleFillSymbolClass();

            pFillSymbol.Color   = pColor;
            pFillSymbol.Outline = pOutline;
            IFillShapeElement pFillShapeEle = pElement as IFillShapeElement;

            pFillShapeEle.Symbol = pFillSymbol;
            pGraphicsContainer.AddElement((IElement)pFillShapeEle, 0);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

            IPoint ll, Ur;

            ll = axMapControl1.Extent.LowerLeft;
            Ur = axMapControl1.Extent.LowerRight;
            toolStripStatusLabel1.Text = "(" + Convert.ToString(ll.X) + "," + Convert.ToString(ll.Y) + ")";
        }
        private static IElement CreateFillElement(IGeometry pGeometry, ISimpleFillSymbol pFillSym)
        {
            IFillShapeElement pFillEle = new RectangleElementClass();

            pFillEle.Symbol = pFillSym;
            IElement pElement = pFillEle as IElement;

            pElement.Geometry = pGeometry;

            IScreenDisplay pScrDisp = ArcMap.Document.ActiveView.ScreenDisplay;

            pElement.Activate(pScrDisp);

            pScrDisp.StartDrawing(0, (System.Int16)esriScreenCache.esriNoScreenCache);
            pElement.Draw(pScrDisp, null);
            pScrDisp.FinishDrawing();

            return(pElement);
        }
Esempio n. 32
0
 private void axMapControl1_OnExtentUpdated(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnExtentUpdatedEvent e)
 {
     //得到新范围
     IEnvelope pEnvelop = (IEnvelope)e.newEnvelope;
     IGraphicsContainer pGraphicsContainer = Global.eagleeye.Map as IGraphicsContainer;
     IActiveView pActiveView = pGraphicsContainer as IActiveView;
     //在绘制前。清除axMapControl2 中的任何图形元素
     pGraphicsContainer.DeleteAllElements();
     IRectangleElement pRectangleEle = new RectangleElementClass();
     IElement pElement = pRectangleEle as IElement;
     pElement.Geometry = pEnvelop;
     //设置鹰眼中的红线框
     IRgbColor pColor = new RgbColorClass();
     pColor.Red = 255;
     pColor.Green = 0;
     pColor.Blue = 0;
     pColor.Transparency = 255;
     //产生一个线符号对象
     ILineSymbol pOutline = new SimpleLineSymbolClass();
     pOutline.Width = 1;
     pOutline.Color = pColor;
     //设置颜色属性
     pColor = new RgbColorClass();
     pColor.Red = 255;
     pColor.Green = 0;
     pColor.Blue = 0;
     pColor.Transparency = 0;
     //设置填充符号的属性
     IFillSymbol pFillSymbol = new SimpleFillSymbolClass();
     pFillSymbol.Color = pColor;
     pFillSymbol.Outline = pOutline;
     IFillShapeElement pFillShapeEle = pElement as IFillShapeElement;
     pFillShapeEle.Symbol = pFillSymbol;
     pGraphicsContainer.AddElement((IElement)pFillShapeEle, 0);
     pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
 }
Esempio n. 33
0
        private void mainMapControl_OnExtentUpdated(object sender, IMapControlEvents2_OnExtentUpdatedEvent e)
        {
            IEnvelope pEnvelope = e.newEnvelope as IEnvelope;

            ISimpleLineSymbol pSimpleLineSymbol = new SimpleLineSymbolClass();
            pSimpleLineSymbol.Style = esriSimpleLineStyle.esriSLSDash;
            pSimpleLineSymbol.Width = 2;
            pSimpleLineSymbol.Color = this.getRGBColor(0, 0, 0);

            ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbolClass();
            pSimpleFillSymbol.Color = this.getRGBColor(255, 0, 0);
            pSimpleFillSymbol.Outline = pSimpleLineSymbol as ILineSymbol;
            pSimpleFillSymbol.Style = esriSimpleFillStyle.esriSFSHollow;

            IRectangleElement pRectangleElement = new RectangleElementClass();
            IElement pElement = pRectangleElement as IElement;
            pElement.Geometry = pEnvelope as IGeometry;
            IFillShapeElement pFillShapeElement = pRectangleElement as IFillShapeElement;
            pFillShapeElement.Symbol = pSimpleFillSymbol as IFillSymbol;

            IGraphicsContainer pGraphicsContainer = this.EagleaxMapControl.Map as IGraphicsContainer;
            pGraphicsContainer.DeleteAllElements();
            pGraphicsContainer.AddElement(pElement, 0);

            this.EagleaxMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Esempio n. 34
0
        /// <summary>
        /// 把Geometry弄成一个element,添加到地图上
        /// </summary>
        /// <param name="pGeometry"></param>
        private void AddElement(IGeometry pGeometry)
        {
            try
            {
                IElement pElement = null;

                ISimpleLineSymbol pSimpleLineSymbol = new SimpleLineSymbolClass();
                pSimpleLineSymbol.Width = 2;
                pSimpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;

                ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbolClass();
                pSimpleFillSymbol.Style = esriSimpleFillStyle.esriSFSSolid;
                pSimpleFillSymbol.Outline = pSimpleLineSymbol;

                if (pGeometry.GeometryType == esriGeometryType.esriGeometryPolyline)//多义线
                {
                    ILineElement pLineElement = new LineElementClass();
                    pLineElement.Symbol = pSimpleLineSymbol;
                    pElement = pLineElement as IElement;
                    pElement.Geometry = pGeometry;
                }
                else if (pGeometry.GeometryType == esriGeometryType.esriGeometryCircularArc)//圆
                {
                    ISegmentCollection pSegmentCollection;
                    pSegmentCollection = new PolygonClass();
                    object Missing = Type.Missing;//注意
                    pSegmentCollection.AddSegment(pGeometry as ISegment, ref Missing, ref Missing);//后两个参数必须是这样,帮助说的,为什么??

                    pElement = new CircleElementClass();
                    pElement.Geometry = pSegmentCollection as IGeometry;
                    IFillShapeElement pFillShapeElement = pElement as IFillShapeElement;
                    pFillShapeElement.Symbol = pSimpleFillSymbol;
                }
                else if (pGeometry.GeometryType == esriGeometryType.esriGeometryEnvelope)//矩形
                {
                    pElement = new RectangleElementClass();
                    pElement.Geometry = pGeometry;
                    IFillShapeElement pFillShapeElement = pElement as IFillShapeElement;
                    pFillShapeElement.Symbol = pSimpleFillSymbol;
                }
                else if (pGeometry.GeometryType == esriGeometryType.esriGeometryPolygon)//多边形
                {
                    pElement = new PolygonElementClass();
                    pElement.Geometry = pGeometry;
                    IFillShapeElement pFillShapeElement = pElement as IFillShapeElement;
                    pFillShapeElement.Symbol = pSimpleFillSymbol;
                }
                else if (pGeometry.GeometryType == esriGeometryType.esriGeometryBezier3Curve)//Bezier曲线
                {
                    pElement = new LineElementClass();
                    pElement.Geometry = pGeometry;
                    ILineElement pLineElement = pElement as ILineElement;
                    pLineElement.Symbol = pSimpleLineSymbol;
                }

                this.pGraphicContainer.AddElement(pElement, 0);
                this.axMapControl1.Refresh(esriViewDrawPhase.esriViewGraphics, null, null);

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 35
0
        public MainFrm()
        {
            //
            // Required for Windows Form Designer support
            //
            SAoption = new SpatialAnalysisOption("c:\\temp");
            IMapDocument pMapDocument = new MapDocumentClass();

            modPublicClass = new ModPublicClass(pMapDocument, @"D:\PPT\��ѵPPT\CSHARPDEMO\CSharp\data", "data.mxd");
            InitializeComponent();
            m_AOI = new RectangleElementClass();
            IElementProperties property = m_AOI as IElementProperties;
            property.Name = "Map_AOI";

            ResetFillSymbol();
            //���ƹ�����
            _toolBarManager = new ToolBarManager(this, this);

            // The control Text property is used to draw the bar name while floating
            // and on view/hide menu.

            toolBar1.Text = "��������";
            toolBar2.Text = "�������������";

            // Add toolbar (default position)
            _toolBarManager.AddControl(toolBar1, DockStyle.Top);

            _toolBarManager.AddControl(toolBar2, DockStyle.None);
            _toolBarManager.AddControl(axToolbarControl1, DockStyle.None);
            pNetFlagArray = new ArrayClass();
        }
        private List<string> ExportSymbol(IStyleGallery sg,string symbolType, int col, int row, int size,int width, int labelsize, int label_h, int size_w, int size_h, double height, string cat, IPageLayout3 layout)
        {
            List<string> pdfpages = new List<string>();
            IGraphicsContainer con = layout as IGraphicsContainer;
            IPage page = layout.Page;
            int r = 0;
            int c = 0;
            int p = 0;
            IEnumStyleGalleryItem items = sg.get_Items(symbolType, "", cat);
            IStyleGalleryItem item = items.Next();
            while (item != null)
            {
                #region Symbol
                if (symbolType == "Marker Symbols")
                {
                    IMarkerElement mele = new MarkerElementClass();
                    IPoint ptn = new PointClass();
                    ptn.PutCoords(c * size_w + size / 2, height - (r * size_h + size / 2));
                    IElement ele_i = mele as IElement;
                    ele_i.Geometry = ptn;
                    IMarkerSymbol sym_m = item.Item as IMarkerSymbol;
                    sym_m.Size = size;
                    mele.Symbol = sym_m;
                    con.AddElement(ele_i, 0);
                }
                else if (symbolType == "Line Symbols")
                {
                    ILineElement lele = new LineElementClass();
                    IPolyline line = new PolylineClass();
                    IPoint ptn_f = new PointClass();
                    ptn_f.PutCoords(c * size_w + size / 4, height - (r * size_h + size * 3 / 4));
                    IPoint ptn_t = new PointClass();
                    ptn_t.PutCoords(c * size_w + size * 3 / 4, height - (r * size_h + size / 4));
                    line.FromPoint = ptn_f;
                    line.ToPoint = ptn_t;
                    IElement ele_i = lele as IElement;
                    ele_i.Geometry = line;
                    ILineSymbol sym_l = item.Item as ILineSymbol;
                    sym_l.Width = width;
                    lele.Symbol = sym_l;
                    con.AddElement(ele_i, 0);
                }
                else if (symbolType == "Fill Symbols")
                {
                    IRectangleElement fele = new RectangleElementClass();
                    IFillShapeElement fsele = fele as IFillShapeElement;
                    IEnvelope env_f = new EnvelopeClass();
                    env_f.PutCoords(c * size_w + size / 4, height - (r * size_h + size * 3 / 4), c * size_w + size * 3 / 4, height - (r * size_h + size / 4));
                    IElement ele_i = fele as IElement;
                    ele_i.Geometry = env_f;
                    IFillSymbol sym_f = item.Item as IFillSymbol;
                    fsele.Symbol = sym_f;
                    con.AddElement(ele_i, 0);
                }

                #endregion

                if (cbGrid.Checked)
                {
                    #region Grid
                    IEnvelope env_g = new EnvelopeClass();
                    env_g.PutCoords(c * size_w, height - r * size_h, c * size_w + size_w, height - r * size_h - size_h);
                    IRectangleElement gele = new RectangleElementClass();
                    IElement ele_g = gele as IElement;
                    ele_g.Geometry = env_g;
                    IFillSymbol sym_g = new SimpleFillSymbolClass();
                    IRgbColor color_g = new RgbColorClass();
                    color_g.NullColor = true;
                    sym_g.Color = color_g;
                    IFillShapeElement fshp_g = ele_g as IFillShapeElement;
                    fshp_g.Symbol = sym_g;
                    con.AddElement(ele_g, 0);
                    #endregion
                }

                #region Label
                ITextElement tele = new ParagraphTextElementClass();
                IElement ele_t = tele as IElement;
                tele.Text = item.Name;
                IEnvelope env_l = new EnvelopeClass();
                env_l.PutCoords(c * size_w, height - r * size_h - size_h + label_h, c * size_w + size_w, height - r * size_h - size_h);
                env_l.PutCoords(c * size_w, height - r * size_h - size_h + label_h, c * size_w + size_w, height - r * size_h - size_h);
                env_l.PutCoords(c * size_w, height - r * size_h - size_h + label_h, c * size_w + size_w, height - r * size_h - size_h);
                env_l.PutCoords(c * size_w, height - r * size_h - size_h + label_h, c * size_w + size_w, height - r * size_h - size_h);
                env_l.PutCoords(c * size_w, height - r * size_h - size_h + label_h, c * size_w + size_w, height - r * size_h - size_h);
                ele_t.Geometry = env_l;
                ITextSymbol sym_label = new TextSymbolClass();
                sym_label.Size = labelsize/2;
                IRgbColor color = new RgbColorClass();
                color.NullColor = true;
                ISimpleLineSymbol sym_border = new SimpleLineSymbolClass();
                sym_border.Color = color;
                ISymbolBorder border = new SymbolBorderClass();
                border.LineSymbol = sym_border;
                IFrameProperties fp = ele_t as IFrameProperties;
                fp.Border = border;
                con.AddElement(ele_t, 0);
                #endregion

                if (c < col - 1)
                {
                    c++;
                }
                else
                {
                    c = 0;
                    if (r < row - 1)
                    {
                        r++;
                    }
                    else
                    {
                        IActiveView av = layout as IActiveView;
                        string temp_pdf = System.IO.Path.GetTempFileName() + ".pdf";
                        ExportPDF(av, temp_pdf);
                        pdfpages.Add(temp_pdf);
                        con.DeleteAllElements();
                        r = 0;
                        c = 0;
                        p++;
                    }
                }
                item = items.Next();
            }
            if (con.Next() != null)
            {
                IActiveView av = layout as IActiveView;
                string temp_pdf = System.IO.Path.GetTempFileName() + ".pdf";
                ExportPDF(av, temp_pdf);
                pdfpages.Add(temp_pdf);
                con.DeleteAllElements();
            }
            return pdfpages;
        }
        private void axPageLayoutControl1_OnExtentUpdated(object sender, IPageLayoutControlEvents_OnExtentUpdatedEvent e)
        {
            //QI for IEnvelope
            IEnvelope envelope = (IEnvelope)e.newEnvelope;

            //Get the IElement interface by finding an element by its name 
            IElement element = m_PageLayoutControl.FindElementByName("ZoomExtent", 1);
            if (element != null)
            {
                //Delete the graphic
                m_PageLayoutControl.GraphicsContainer.DeleteElement(element);
            }
            element = new RectangleElementClass();

            //Get the IRGBColor interface
            IRgbColor color = new RgbColorClass();
            //Set the color properties
            color.RGB = 255;
            color.Transparency = 255;

            //Get the ILine symbol interface
            ILineSymbol outline = new SimpleLineSymbolClass();
            //Set the line symbol properties
            outline.Width = 10;
            outline.Color = color;

            //Set the color properties
            color = new RgbColorClass();
            color.RGB = 255;
            color.Transparency = 0;

            //Get the IFillSymbol properties
            IFillSymbol fillSymbol = new SimpleFillSymbolClass();
            //Set the fill symbol properties
            fillSymbol.Color = color;
            fillSymbol.Outline = outline;

            //QI for IFillShapeElement interface through the IElement interface
            IFillShapeElement fillShapeElement = (IFillShapeElement)element;
            //Set the symbol property
            fillShapeElement.Symbol = fillSymbol;

            //Add the element
            m_PageLayoutControl.AddElement(element, e.newEnvelope, Type.Missing, "ZoomExtent", -1);
            //Refresh the graphics
            m_PageLayoutControl.Refresh(esriViewDrawPhase.esriViewGraphics, Type.Missing, Type.Missing);
        }
Esempio n. 38
0
 private void setMap2(IMapControlEvents2_OnExtentUpdatedEvent e)
 {
     //动态生产鹰眼红框
     // 得到新范围
     IEnvelope pEnv = (IEnvelope)e.newEnvelope;   //传递参数,e指mapcontrol1
     IGraphicsContainer pGra = axMapControl2.Map as IGraphicsContainer;
     IActiveView pAv = pGra as IActiveView;
     //在绘制前,清除axMapControl2中的任何图形元素
     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 = new RgbColorClass();
     pColor.Red = 255;
     pColor.Green = 0;
     pColor.Blue = 0;
     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);
 }
        private void axMapControl1_OnExtentUpdated(object sender, IMapControlEvents2_OnExtentUpdatedEvent e)
        {
            double scale = axMapControl1.ActiveView.FocusMap.MapScale;
            string a = scale.ToString("#0.00");
            this.scaletextbox.Text = "1:" + a;

            IEnvelope penvelope = (IEnvelope)e.newEnvelope;

            IGraphicsContainer pgraghicscontainer = axMapControl2.Map as IGraphicsContainer;
            IActiveView pactiveview = pgraghicscontainer as IActiveView;

            pgraghicscontainer.DeleteAllElements();
            IRectangleElement prectangle = new RectangleElementClass();
            IElement pelement = prectangle as IElement;
            pelement.Geometry = penvelope;

            IRgbColor pcolor1 = new RgbColorClass();
            pcolor1.Red = 255; pcolor1.Green = 0; pcolor1.Blue = 0; pcolor1.Transparency = 0;
            IRgbColor pcolor2 = new RgbColorClass();
            pcolor2.Red = 255; pcolor2.Green = 0; pcolor2.Blue = 0; pcolor2.Transparency = 255;

            ISimpleFillSymbol simplefillsymbol = new SimpleFillSymbolClass();
            simplefillsymbol.Color = pcolor1;
            simplefillsymbol.Outline.Color = pcolor2;
            simplefillsymbol.Outline.Width = 3;
            IFillShapeElement pfillshapefile = pelement as IFillShapeElement;
            pfillshapefile.Symbol = simplefillsymbol;
            pgraghicscontainer.AddElement((IElement)pfillshapefile, 0);
            axMapControl2.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Esempio n. 40
0
        private void UCMap_OnExtentUpdated(object sender, IMapControlEvents2_OnExtentUpdatedEvent e)
        {
            if (scaleUpdated != null)
                scaleUpdated(MapScale);

            ucMapNavigate1.MapScale = (int) base.MapScale;

            // �õ��·�Χ
            IEnvelope pEnv = (IEnvelope) e.newEnvelope;
            IGraphicsContainer pGra = this.Map as IGraphicsContainer;
            IActiveView pAv = pGra as IActiveView;

            //�ڻ���ǰ�����axMapControl2�е��κ�ͼ��Ԫ��
            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 = 1;
            pOutline.Color = pColor;

            //������ɫ����
            pColor = new RgbColorClass();
            pColor.Red = 255;
            pColor.Green = 0;
            pColor.Blue = 0;
            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);
        }
Esempio n. 41
0
        /// <summary>
        /// Drawing the graphic element of the pixel box.
        /// </summary>
        /// <param name="boxSymbol">The graphic symbol of the drawing box.</param>
        /// <param name="pixelPos">The postion of drawing cell.</param>
        /// <param name="activeLayer">Raster layer to be symbolized.</param>
        /// <returns>An IFillShapeElement implimentation as IElement</returns>
        private static IElement DrawBoxElement(ISimpleFillSymbol boxSymbol, Position pixelPos, ILayer activeLayer = null)
        {
            // Probably should be removed.
            ILayer layer = activeLayer == null ? Editor.ActiveLayer : activeLayer;

            IActiveView activeView = ArcMap.Document.ActiveView;

            IFillShapeElement fillShapeElement = new RectangleElementClass();
            fillShapeElement.Symbol = (IFillSymbol)boxSymbol;

            // Retrive the cell coordinate and the cell size
            double x, y;
            IRasterLayer rasterLayer = (IRasterLayer)layer;
            IRaster2 raster = (IRaster2)rasterLayer.Raster;
            raster.PixelToMap(pixelPos.Column, pixelPos.Row, out x, out y);
            IRasterProps rasterProp = (IRasterProps)raster;
            IPnt cellSize = rasterProp.MeanCellSize();

            // Define the extent of the selection box
            IEnvelope envelop = new EnvelopeClass();
            envelop.XMin = x - cellSize.X / 2;
            envelop.XMax = x + cellSize.X / 2;
            envelop.YMin = y - cellSize.Y / 2;
            envelop.YMax = y + cellSize.Y / 2;

            IElement element = (IElement)fillShapeElement;
            element.Geometry = (IGeometry)envelop;

            activeView.GraphicsContainer.AddElement(element, 0);

            return element;
        }