Ejemplo n.º 1
0
        private void MapControl_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            if (DrawElementType == EDrawElementType.None || e.button != 1)
            {
                return;
            }

            MapControl.MousePointer = esriControlsMousePointer.esriPointerCrosshair;
            IGraphicsContainer graphicsContainer = (IGraphicsContainer)MapControl.Map;

            #region 绘制元素
            switch (DrawElementType)
            {
            case EDrawElementType.Point:
                var markerElement = graphicsContainer.CreatePointElement(MapControl.ToMapPoint(e.x, e.y));
                markerElement.Symbol = MarkerSymbol;
                break;

            case EDrawElementType.Polyline:
                var lineElement = graphicsContainer.CreatePolylineElement((IPolyline)MapControl.TrackLine());
                lineElement.Symbol = LineSymbol;
                break;

            case EDrawElementType.Polygon:
                var polygonElement = graphicsContainer.CreatePolygonElement((IPolygon)MapControl.TrackPolygon());
                polygonElement.Symbol = FillSymbol;
                break;

            case EDrawElementType.Circle:
                var circleElement = graphicsContainer.CreateCircleElement(MapControl.TrackCircle());
                circleElement.Symbol = FillSymbol;
                break;

            case EDrawElementType.Rectangle:
                var rectangleElement = graphicsContainer.CreateRectangleElement(MapControl.TrackRectangle());
                rectangleElement.Symbol = FillSymbol;
                break;

            case EDrawElementType.Text:
                var textElement = graphicsContainer.CreateTextElement(MapControl.ToMapPoint(e.x, e.y));
                textElement.Symbol = TextSymbol;
                break;
            }
            #endregion

            ((IActiveView)graphicsContainer).PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }