Пример #1
0
        /// <summary>
        /// 地图缩放至指定图形并闪烁
        /// </summary>
        /// <param name="axMapControl">地图控件</param>
        /// <param name="geometry">闪烁的图像</param>
        /// <param name="nFlashes">闪烁次数</param>
        public static void MapZoomToAndFlash(this AxMapControl axMapControl, IGeometry geometry, int nFlashes = 2)
        {
            MapZoomTo(axMapControl.ActiveView, geometry);

            //地图闪烁
            object symbol = null;

            switch (geometry.GeometryType)
            {
            case esriGeometryType.esriGeometryPoint:
                symbol = RenderOpt.GetSimpleMarkerSymbol("ff0000");
                break;

            case esriGeometryType.esriGeometryLine:
            case esriGeometryType.esriGeometryPolyline:
                symbol = RenderOpt.GetSimpleLineSymbol("ff0000");
                break;

            case esriGeometryType.esriGeometryPolygon:
                symbol = RenderOpt.GetSimpleFillSymbol("99ccff", "ff0000");
                break;
            }
            if (symbol == null)
            {
                return;
            }
            axMapControl.FlashShape(geometry, nFlashes, 200, symbol);
        }
Пример #2
0
        /// <summary>
        /// 创建几何图形对应的用于高亮显示的元素
        /// </summary>
        /// <param name="geometry"></param>
        /// <returns></returns>
        private static IElement CreateHightLightElement(IGeometry geometry)
        {
            IElement element   = null;
            IColor   redcolor  = RenderOpt.GetIColor(255, 0, 0, 50);
            IColor   bluecolor = RenderOpt.GetIColor(0, 0, 255);

            switch (geometry.GeometryType)
            {
            case esriGeometryType.esriGeometryLine:
            case esriGeometryType.esriGeometryPolyline:
                element          = new LineElementClass();
                element.Geometry = geometry;
                ((ILineElement)element).Symbol = RenderOpt.GetSimpleLineSymbol(redcolor);
                break;

            case esriGeometryType.esriGeometryPolygon:
                element          = new PolygonElementClass();
                element.Geometry = geometry;
                ((PolygonElementClass)element).Symbol = RenderOpt.GetSimpleFillSymbol(redcolor, bluecolor);
                break;

            case esriGeometryType.esriGeometryPoint:
                element          = new MarkerElementClass();
                element.Geometry = geometry;
                IMarkerSymbol pisymbol = new SimpleMarkerSymbolClass();
                pisymbol.Color = (IColor)redcolor;
                pisymbol.Size  = 6;
                ((MarkerElementClass)element).Symbol = pisymbol;
                break;
            }
            return(element);
        }
Пример #3
0
 //主地图:地图范围(Extent)变化
 private void axMapControlMainMap_OnExtentUpdated(object sender, IMapControlEvents2_OnExtentUpdatedEvent e)
 {
     #region 主地图地图范围Extent变化时,鹰眼中的地图范围Extent也跟随着变化
     IEnvelope          envelope          = (IEnvelope)e.newEnvelope; //得到主地图的新范围
     IGraphicsContainer graphicsContainer = axMapControlEagleMap.Map as IGraphicsContainer;
     IActiveView        activeView        = graphicsContainer as IActiveView;
     graphicsContainer.DeleteAllElements();  //在绘制前,清除axMapControlEagleMap中的任何图形元素
     IRectangleElement rectangleElement = new RectangleElement() as IRectangleElement;
     IElement          element          = rectangleElement as IElement;
     element.Geometry = envelope;
     //产生一个线符号对象,设置鹰眼中的红线框
     ILineSymbol lineSymbol = new SimpleLineSymbol();
     lineSymbol.Width = 1.6;
     lineSymbol.Color = RenderOpt.GetIColor(255, 0, 0);
     //设置填充符号的属性
     IFillSymbol fillSymbol = new SimpleFillSymbol();
     fillSymbol.Color   = RenderOpt.GetIColor(255, 0, 0, 0);
     fillSymbol.Outline = lineSymbol;
     IFillShapeElement fillShapeElement = element as IFillShapeElement;
     fillShapeElement.Symbol = fillSymbol;
     graphicsContainer.AddElement((IElement)fillShapeElement, 0);
     //刷新
     envelope.Expand(2, 2, true);
     activeView.Extent = envelope;
     activeView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
     #endregion
 }
Пример #4
0
        //主地图:鼠标点击(绘制图形、查询、数据编辑)
        private void axMapControlMainMap_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            int statusFlag = CommonLib.MapMouseFlag;

            if (e.button == 2)
            {
                if (statusFlag <= 7)
                {
                    _toolBarMenu.PopupMenu(e.x, e.y, axMapControlMainMap.hWnd);
                }
            }
            else if (e.button == 4)
            {
                esriControlsMousePointer pointer = axMapControlMainMap.MousePointer;
                axMapControlMainMap.MousePointer = esriControlsMousePointer.esriPointerPan;
                axMapControlMainMap.Pan();
                axMapControlMainMap.MousePointer = pointer;
            }

            if (statusFlag <= 1)
            {
                return;
            }
            axMapControlMainMap.MousePointer = esriControlsMousePointer.esriPointerCrosshair;//鼠标指针:十字状
            IPoint pPoint = axMapControlMainMap.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);

            #region 8-9:测距离、测面积
            if (statusFlag >= 8 && statusFlag <= 9)
            {
                measureResultPanel.Visible = true;
                switch (statusFlag)
                {
                case 8:     //测距离
                    if (e.button == 1)
                    {
                        if (!_measureTool.IsSurveying)
                        {
                            _measureTool.LengthStart(axMapControlMainMap.ToMapPoint(e.x, e.y));
                        }
                        else
                        {
                            _measureTool.AddPoint(axMapControlMainMap.ToMapPoint(e.x, e.y));
                        }
                    }
                    else
                    {
                        if (_measureTool.IsSurveying)
                        {
                            object lineSymbolObj = RenderOpt.GetSimpleLineSymbol("ff0000");
                            axMapControlMainMap.DrawShape(_measureTool.SurveyEnd(axMapControlMainMap.ToMapPoint(e.x, e.y)), ref lineSymbolObj);
                            measureResultLabel.Text  = "总长度:" + _measureTool.TotalLength.ToString("F2") + "米" + Environment.NewLine + Environment.NewLine;
                            measureResultLabel.Text += "当前长度: " + _measureTool.CurrentLength.ToString("F2") + "米";
                            measureResultLabel.Refresh();
                            _measureTool.SurveyEnd(axMapControlMainMap.ToMapPoint(e.x, e.y));
                        }
                    }
                    break;

                case 9:     //测面积
                    if (e.button == 1)
                    {
                        if (!_measureTool.IsSurveying)
                        {
                            _measureTool.AreaStart(axMapControlMainMap.ToMapPoint(e.x, e.y));
                            _areaPointCount = 1;
                        }
                        else
                        {
                            _measureTool.AddPoint(axMapControlMainMap.ToMapPoint(e.x, e.y));
                            _areaPointCount++;
                        }
                    }
                    else
                    {
                        if (_measureTool.IsSurveying && _areaPointCount > 1)
                        {
                            object fillSymbolObj = RenderOpt.GetSimpleFillSymbol("99ccff", "ff0000");
                            axMapControlMainMap.DrawShape(_measureTool.SurveyEnd(axMapControlMainMap.ToMapPoint(e.x, e.y)), ref fillSymbolObj);
                            measureResultLabel.Text = "面积:" + _measureTool.Area.ToString("#########.##") + "平方米";
                            measureResultLabel.Refresh();
                            _measureTool.SurveyEnd(axMapControlMainMap.ToMapPoint(e.x, e.y));
                        }
                    }
                    break;
                }
            }
            #endregion

            #region 11-19:空间查询(画点、线、面)
            else if (statusFlag >= 11 && statusFlag <= 19)
            {
                object symbol = null;
                switch (statusFlag)
                {
                case 11:
                    CommonLib.MapGeometry = new PointClass {
                        X = e.mapX, Y = e.mapY
                    };
                    symbol = RenderOpt.GetSimpleMarkerSymbol("ff0000");
                    break;

                case 12:
                    CommonLib.MapGeometry = axMapControlMainMap.TrackLine();
                    symbol = RenderOpt.GetSimpleLineSymbol("ff0000");
                    break;

                case 13:
                    CommonLib.MapGeometry = axMapControlMainMap.TrackPolygon();
                    symbol = RenderOpt.GetSimpleFillSymbol("99ccff", "ff0000");
                    break;

                case 14:
                    CommonLib.MapGeometry = axMapControlMainMap.TrackRectangle();
                    symbol = RenderOpt.GetSimpleFillSymbol("99ccff", "ff0000");
                    break;

                default:
                    CommonLib.MapGeometry = null;
                    break;
                }

                if (CommonLib.MapGeometry != null)
                {
                    axMapControlMainMap.DrawShape(CommonLib.MapGeometry, ref symbol);
                }
            }
            #endregion
        }
Пример #5
0
        private void axMapControlMainMap_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            int statusFlag = CommonLib.MapMouseFlag;

            if (statusFlag <= 1)
            {
                return;
            }

            AxMapControlMainMap.MousePointer = esriControlsMousePointer.esriPointerCrosshair;//鼠标指针:十字状
            IPoint pPoint = AxMapControlMainMap.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);

            #region 11-19:空间查询(画点、线、面)
            if (statusFlag >= 11 && statusFlag <= 19)
            {
                object symbol = null;
                switch (statusFlag)
                {
                case 11:
                    IPoint point = new ESRI.ArcGIS.Geometry.Point();
                    point.X = e.mapX;
                    point.Y = e.mapY;
                    CommonLib.MapGeometry = point;
                    symbol = RenderOpt.GetSimpleMarkerSymbol("ff0000");
                    break;

                case 12:
                    CommonLib.MapGeometry = AxMapControlMainMap.TrackLine();
                    symbol = RenderOpt.GetSimpleLineSymbol("ff0000");
                    break;

                case 13:
                    CommonLib.MapGeometry = AxMapControlMainMap.TrackPolygon();
                    symbol = RenderOpt.GetSimpleFillSymbol("99ccff", "ff0000");
                    break;

                case 14:
                    CommonLib.MapGeometry = AxMapControlMainMap.TrackRectangle();
                    symbol = RenderOpt.GetSimpleFillSymbol("99ccff", "ff0000");
                    break;

                default:
                    CommonLib.MapGeometry = null;
                    break;
                }

                if (CommonLib.MapGeometry != null)
                {
                    //axMapControlMainMap.Map.SelectByShape(CommonLib.MapGeometry, null, false);
                    //axMapControlMainMap.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
                    AxMapControlMainMap.DrawShape(CommonLib.MapGeometry, ref symbol);
                }
            }
            #endregion
            #region
            //#region 绘制图形
            //if (CommonLib.MapMouseFlag >= 1 && CommonLib.MapMouseFlag <= 4)
            //{
            //    //初始化Color
            //    IRgbColor rgbColor1 = new RgbColor();
            //    rgbColor1.Red = 255;
            //    rgbColor1.Green = 255;
            //    rgbColor1.Blue = 0;

            //    //初始化Symbol
            //    object symbol = null;
            //    if (geometry.GeometryType == esriGeometryType.esriGeometryPolyline) //线
            //    {
            //        ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbol();
            //        simpleLineSymbol.Color = rgbColor1;
            //        simpleLineSymbol.Width = 5;
            //        symbol = simpleLineSymbol;
            //    }
            //    else
            //    {
            //        ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbol();
            //        simpleFillSymbol.Color = rgbColor1;
            //        symbol = simpleFillSymbol;
            //    }

            //    axMapControlMainMap.DrawShape(geometry, ref symbol);
            //}
            //else if (CommonLib.MapMouseFlag == 5)
            //{
            //    //初始化Color
            //    IRgbColor rgbColor2 = new RgbColor();
            //    rgbColor2.Red = 255;
            //    rgbColor2.Green = 0;
            //    rgbColor2.Blue = 0;

            //    //初始化Symbol
            //    object symbol = null;
            //    ITextSymbol textSymbol = new TextSymbol();
            //    textSymbol.Color = rgbColor2;
            //    symbol = textSymbol;

            //    axMapControlMainMap.DrawText(geometry, "顶你个肺", ref symbol);
            //}
            //#endregion

            //#region 空间选择
            //if (CommonLib.MapMouseFlag >= 11 && CommonLib.MapMouseFlag <= 15)
            //{
            //    axMapControlMainMap.Map.SelectByShape(geometry, null, false);
            //}
            //axMapControlMainMap.Refresh();

            //#endregion
            #endregion
        }