public IArrowMarkerSymbol CreateArrowMarkerSymbol(IRgbColor color = null,
                                                          double length   = 5,
                                                          int angle       = 90,
                                                          double width    = 1)
        {
            IArrowMarkerSymbol arrowMarkerSymbol = new ArrowMarkerSymbol();

            arrowMarkerSymbol.Angle = angle;
            arrowMarkerSymbol.Style = esriArrowMarkerStyle.esriAMSPlain;
            if (color == null)
            {
                color = getRGB(50, 96, 220) as IRgbColor;
            }
            arrowMarkerSymbol.Color  = color;
            arrowMarkerSymbol.Width  = width;
            arrowMarkerSymbol.Length = length;
            return(arrowMarkerSymbol);
        }
Exemple #2
0
        /// <summary>
        /// 带箭头的线段
        /// </summary>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <param name="fillColor"></param>
        public static void TrackLine(IPoint start, IPoint end, Color fillColor)
        {
            //将线段打断生成两条线段 以实现线段中间箭头显示
            IPoint middle = new PointClass();

            middle.PutCoords((end.X + start.X) / 2, (end.Y + start.Y) / 2);

            IActiveView        pActiveView        = Program.myMap.ActiveView;
            IGraphicsContainer pGraphicsContainer = pActiveView.GraphicsContainer;

            IPolyline pLine  = new PolylineClass();
            IPolyline pLine1 = new PolylineClass();

            pLine.FromPoint  = start;
            pLine.ToPoint    = middle;
            pLine1.FromPoint = middle;
            pLine1.ToPoint   = end;
            pLine.Project(pActiveView.FocusMap.SpatialReference);
            pLine1.Project(pActiveView.FocusMap.SpatialReference);

            ICartographicLineSymbol pCartoLineSymbol = new CartographicLineSymbol();

            pCartoLineSymbol.Cap = esriLineCapStyle.esriLCSRound;

            ILineProperties pLineProp = pCartoLineSymbol as ILineProperties;

            pLineProp.DecorationOnTop = true;

            ILineDecoration pLineDecoration = new LineDecoration();
            ISimpleLineDecorationElement pSimpleLineDecoElem = new SimpleLineDecorationElement();

            pSimpleLineDecoElem.AddPosition(1);
            IArrowMarkerSymbol pArrowMarkerSym = new ArrowMarkerSymbol();

            pArrowMarkerSym.Size             = 12;
            pArrowMarkerSym.Color            = GetColor(fillColor.R, fillColor.G, fillColor.B);
            pSimpleLineDecoElem.MarkerSymbol = pArrowMarkerSym as IMarkerSymbol;
            pLineDecoration.AddElement(pSimpleLineDecoElem as ILineDecorationElement);
            pLineProp.LineDecoration = pLineDecoration;

            ILineSymbol pLineSymbol = pCartoLineSymbol as ILineSymbol;

            pLineSymbol.Color = GetColor(fillColor.R, fillColor.G, fillColor.B);;
            pLineSymbol.Width = 2;

            ILineElement pLineElem  = new LineElementClass();
            ILineElement pLineElem1 = new LineElementClass();

            pLineElem.Symbol  = pLineSymbol;
            pLineElem1.Symbol = pLineSymbol;

            IElement pElem  = pLineElem as IElement;
            IElement pElem1 = pLineElem1 as IElement;

            pElem.Geometry  = pLine;
            pElem1.Geometry = pLine1;

            pGraphicsContainer.AddElement(pElem, 0);
            pGraphicsContainer.AddElement(pElem1, 0);
            pActiveView.Refresh();
        }