コード例 #1
0
        /// <summary>
        /// Flash a line feature on the map
        /// <param name="pDisplay">The map screen</param>
        /// <param name="pGeometry">The geometry of the feature to be flashed</param>
        /// <param name="direction">The digitized direction of the barrier with respect to the underlying source feature</param>
        /// </summary>
        private void FlashLine(IScreenDisplay pDisplay, IGeometry pGeometry, esriNetworkEdgeDirection direction)
        {
            // The flash will be on a line symbol with an arrow on it
            ICartographicLineSymbol ipArrowLineSymbol = new CartographicLineSymbolClass();

            // the line color will be red
            IRgbColor ipRgbRedColor = new RgbColorClass();

            ipRgbRedColor.Red = 192;

            // the arrow will be black
            IRgbColor ipRgbBlackColor = new RgbColorClass();

            ipRgbBlackColor.RGB = 0;

            // set up the arrow that will be displayed along the line
            IArrowMarkerSymbol ipArrowMarker = new ArrowMarkerSymbolClass();

            ipArrowMarker.Style  = esriArrowMarkerStyle.esriAMSPlain;
            ipArrowMarker.Length = 18;
            ipArrowMarker.Width  = 12;
            ipArrowMarker.Color  = ipRgbBlackColor;

            // set up the line itself
            ipArrowLineSymbol.Width = 4;
            ipArrowLineSymbol.Color = ipRgbRedColor;

            // Set up the Raster Op-Code to help the flash mechanism
            ((ISymbol)ipArrowMarker).ROP2     = esriRasterOpCode.esriROPNotXOrPen;
            ((ISymbol)ipArrowLineSymbol).ROP2 = esriRasterOpCode.esriROPNotXOrPen;

            // decorate the line with the arrow symbol
            ISimpleLineDecorationElement ipSimpleLineDecorationElement = new SimpleLineDecorationElementClass();

            ipSimpleLineDecorationElement.Rotate          = true;
            ipSimpleLineDecorationElement.PositionAsRatio = true;
            ipSimpleLineDecorationElement.MarkerSymbol    = ipArrowMarker;
            ipSimpleLineDecorationElement.AddPosition(0.5);
            ILineDecoration ipLineDecoration = new LineDecorationClass();

            ipLineDecoration.AddElement(ipSimpleLineDecorationElement);
            ((ILineProperties)ipArrowLineSymbol).LineDecoration = ipLineDecoration;

            // the arrow is initially set to correspond to the digitized direction of the line
            //  if the barrier direction is against digitized, then we need to flip the arrow direction
            if (direction == esriNetworkEdgeDirection.esriNEDAgainstDigitized)
            {
                ipSimpleLineDecorationElement.FlipAll = true;
            }

            // Flash the line
            //  Two calls are made to Draw.  Since the ROP2 setting is NotXOrPen, the first call
            //  draws the symbol with our new symbology and the second call redraws what was originally
            //  in the place of the symbol
            pDisplay.SetSymbol(ipArrowLineSymbol as ISymbol);
            pDisplay.DrawPolyline(pGeometry);
            System.Threading.Thread.Sleep(300);
            pDisplay.DrawPolyline(pGeometry);
        }
コード例 #2
0
        public static void DrawLine(IPoint fromPoint, IPoint toPoint)
        {
            IPolyline pPolyline = new PolylineClass()
            {
                FromPoint = fromPoint,
                ToPoint   = toPoint
            };
            IRgbColor pColor = Func.CreateRgbColor(0, 0, 0);
            ICartographicLineSymbol pCartoLineSymbol = new CartographicLineSymbolClass()
            {
                Cap   = esriLineCapStyle.esriLCSRound,
                Color = pColor,
                Width = 1
            };
            ILineProperties pLineProp = pCartoLineSymbol as ILineProperties;

            pLineProp.DecorationOnTop = true;
            ILineDecoration pLineDecoration = new LineDecorationClass();
            ISimpleLineDecorationElement pSimpleLineDecoElem = new SimpleLineDecorationElementClass()
            {
                MarkerSymbol = new ArrowMarkerSymbolClass()
                {
                    Size  = 16,
                    Color = pColor
                }
            };

            pSimpleLineDecoElem.AddPosition(1);
            pLineDecoration.AddElement(pSimpleLineDecoElem as ILineDecorationElement);
            pLineProp.LineDecoration = pLineDecoration;
            ILineSymbol pLineSymbol = pCartoLineSymbol as ILineSymbol;
            IElement    pElement    = new LineElementClass()
            {
                Symbol   = pLineSymbol,
                Geometry = pPolyline
            };
            IGraphicsContainer pGC = m_pMapC2.Map as IGraphicsContainer;

            pGC.AddElement(pElement, 0);
            IEnvelope pEnvelope = pPolyline.Envelope;

            pEnvelope.Expand(5, 5, true);
            m_pMapC2.Extent = pEnvelope;
            m_pMapC2.Refresh();
        }
コード例 #3
0
        public static ILineSymbol CreateLineDirectionSymbol()
        {
            ILineSymbol symbol = new CartographicLineSymbolClass();

            symbol.Color = ColorHelper.CreateColor(0, 0, 200);
            LineDecorationClass class2 = new LineDecorationClass();
            SimpleLineDecorationElementClass lineDecorationElement = new SimpleLineDecorationElementClass();

            lineDecorationElement.AddPosition(0.3);
            lineDecorationElement.AddPosition(0.7);
            lineDecorationElement.PositionAsRatio = true;
            IMarkerSymbol symbol2 = (lineDecorationElement.MarkerSymbol as IClone).Clone() as IMarkerSymbol;

            symbol2.Size  = 9.0;
            symbol2.Color = ColorHelper.CreateColor(0, 200, 0);
            lineDecorationElement.MarkerSymbol = symbol2;
            class2.AddElement(lineDecorationElement);
            (symbol as ILineProperties).LineDecoration = class2;
            return(symbol);
        }
コード例 #4
0
        private static ILineSymbol DefineProfileLineSymbol(MilSpaceGraphicsTypeEnum graphicsType)
        {
            //TODO: Get symbol from ESRITools
            IRgbColor rgbColor = grapchucsTypeColors[graphicsType]();


            //Define an arrow marker
            IArrowMarkerSymbol arrowMarkerSymbol = new ArrowMarkerSymbolClass();

            arrowMarkerSymbol.Color  = rgbColor;
            arrowMarkerSymbol.Size   = 6;
            arrowMarkerSymbol.Length = 8;
            arrowMarkerSymbol.Width  = 6;
            //Add an offset to make sure the square end of the line is hidden
            arrowMarkerSymbol.XOffset = 0.8;

            //Create cartographic line symbol
            ICartographicLineSymbol cartographicLineSymbol = new CartographicLineSymbolClass();

            cartographicLineSymbol.Color = rgbColor;
            cartographicLineSymbol.Width = 1;

            //Define simple line decoration
            ISimpleLineDecorationElement simpleLineDecorationElement = new SimpleLineDecorationElementClass();

            //Place the arrow at the end of the line (the "To" point in the geometry below)
            simpleLineDecorationElement.AddPosition(1);
            simpleLineDecorationElement.MarkerSymbol = arrowMarkerSymbol;

            //Define line decoration
            ILineDecoration lineDecoration = new LineDecorationClass();

            lineDecoration.AddElement(simpleLineDecorationElement);

            //Set line properties
            ILineProperties lineProperties = (ILineProperties)cartographicLineSymbol;

            lineProperties.LineDecoration = lineDecoration;

            return(cartographicLineSymbol);
        }
コード例 #5
0
        private ILineSymbol _GetZingerSymbol()
        {
            // Create a color
            Color     color       = Color.Green;
            IRgbColor symbolColor = new RgbColorClass();

            symbolColor.Red   = color.R;
            symbolColor.Green = color.G;
            symbolColor.Blue  = color.B;

            // Create an arrow marker
            IArrowMarkerSymbol arrowMarker = new ArrowMarkerSymbolClass();

            arrowMarker.Color  = symbolColor;
            arrowMarker.Length = 6.125;
            arrowMarker.Width  = 7.0;

            // Create an decoration element from arrow marker to be positioned on the line
            ISimpleLineDecorationElement decorationElement = new SimpleLineDecorationElementClass();

            decorationElement.MarkerSymbol = arrowMarker;
            decorationElement.AddPosition(0.5);
            decorationElement.PositionAsRatio = true;

            // Create a line decoration to be added to the line
            ILineDecoration lineDecoration = new LineDecorationClass();

            lineDecoration.AddElement(decorationElement);

            // Create the line symbol with decoration
            ICartographicLineSymbol lineSymbol = new CartographicLineSymbolClass();

            lineSymbol.Color = symbolColor;
            ILineProperties lineProperties = (ILineProperties)lineSymbol;

            lineProperties.LineDecoration = lineDecoration;

            return(lineSymbol);
        }
コード例 #6
0
ファイル: GraphicsLayerManager.cs プロジェクト: VsPun/DPP
        private static ILineSymbol DefineProfileDecorationLineSymbol(MilSpaceGraphicsTypeEnum graphicsType, IRgbColor color,
                                                                     int width = 2, LineType lineType = LineType.Arrow)
        {
            //TODO: Get symbol from ESRITools

            //Create cartographic line symbol
            ICartographicLineSymbol cartographicLineSymbol = new CartographicLineSymbolClass();

            cartographicLineSymbol.Color = color;
            cartographicLineSymbol.Width = width;

            //Define line decoration
            ILineDecoration lineDecoration = new LineDecorationClass();

            if (lineType == LineType.Arrow || lineType == LineType.DefaultLine)
            {
                //Define simple line decoration
                ISimpleLineDecorationElement simpleLineDecorationElement = new SimpleLineDecorationElementClass();

                //Place the arrow at the end of the line(the "To" point in the geometry below)
                simpleLineDecorationElement.AddPosition(1);

                //Define an arrow marker
                IArrowMarkerSymbol arrowMarkerSymbol = new ArrowMarkerSymbolClass();
                arrowMarkerSymbol.Color  = color;
                arrowMarkerSymbol.Size   = 5;
                arrowMarkerSymbol.Length = 8;
                arrowMarkerSymbol.Width  = 5 + width;

                //Add an offset to make sure the square end of the line is hidden
                arrowMarkerSymbol.XOffset = 0.8;
                simpleLineDecorationElement.MarkerSymbol = arrowMarkerSymbol;

                lineDecoration.AddElement(simpleLineDecorationElement);
            }

            if (lineType == LineType.Point || lineType == LineType.DefaultLine)
            {
                //Define simple line decoration
                ISimpleLineDecorationElement simpleLineDecorationElement = new SimpleLineDecorationElementClass();

                simpleLineDecorationElement.AddPosition(0);

                SimpleMarkerSymbol circleMarkerSymbol = new SimpleMarkerSymbol()
                {
                    Color = color,
                    Size  = 5,
                    Style = esriSimpleMarkerStyle.esriSMSCircle,
                };

                //Add an offset to make sure the square end of the line is hidden
                circleMarkerSymbol.XOffset = 0.8;
                simpleLineDecorationElement.MarkerSymbol = circleMarkerSymbol;

                lineDecoration.AddElement(simpleLineDecorationElement);
            }

            //Set line properties
            ILineProperties lineProperties = (ILineProperties)cartographicLineSymbol;

            lineProperties.LineDecoration = lineDecoration;

            return(cartographicLineSymbol);
        }
コード例 #7
0
        public static void DrawArrow(IActiveView pActiveView, CPoint frcpt, CPoint tocpt,
                                     double dblArrowLength = 6, double dblArrowWidth = 6,
                                     int intRed            = 0, int intGreen = 0, int intBlue = 0)
        {
            var iColor = CHelpFunc.GenerateIRgbColor(intRed, intGreen, intBlue) as IColor;

            //Define an arrow marker
            IArrowMarkerSymbol arrowMarkerSymbol = new ArrowMarkerSymbolClass();

            arrowMarkerSymbol.Color = iColor;
            //arrowMarkerSymbol.Size = 6;  //it seems size has no effect
            arrowMarkerSymbol.Length = dblArrowLength;
            arrowMarkerSymbol.Width  = dblArrowWidth;
            //Add an offset to make sure the square end of the line is hidden
            //arrowMarkerSymbol.XOffset = 0.8;

            //Create cartographic line symbol
            ICartographicLineSymbol cartographicLineSymbol = new CartographicLineSymbolClass();

            cartographicLineSymbol.Color = iColor;
            cartographicLineSymbol.Width = 1;

            //Define simple line decoration
            ISimpleLineDecorationElement simpleLineDecorationElement = new SimpleLineDecorationElementClass();

            //Place the arrow at the end of the line (the "To" point in the geometry below)
            simpleLineDecorationElement.AddPosition(1);
            simpleLineDecorationElement.MarkerSymbol = arrowMarkerSymbol;

            //Define line decoration
            ILineDecoration lineDecoration = new LineDecorationClass();

            lineDecoration.AddElement(simpleLineDecorationElement);

            //Set line properties
            ILineProperties lineProperties = (ILineProperties)cartographicLineSymbol;

            lineProperties.LineDecoration = lineDecoration;

            //Define line element
            ILineElement lineElement = new LineElementClass();

            lineElement.Symbol = (ILineSymbol)cartographicLineSymbol;

            var cpl = new CPolyline(-1, frcpt, tocpt);

            //Cast to Element and set geometry
            var element = (IElement)lineElement;

            element.Geometry = cpl.JudgeAndSetPolyline();

            //Set the name
            //IElementProperties3 elementProperties3.Name = elementName;

            //Add element to graphics container
            pActiveView.GraphicsContainer.AddElement(element, 0);


            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);



            #region a useful example https://community.esri.com/thread/69395
            ////Set the element name
            //string elementName = "ArrowTest";

            ////Get the graphics container from the page layout (set elsewhere)
            //IActiveView activeView = (IActiveView)pageLayout;
            //IGraphicsContainer graphicsContainer = (IGraphicsContainer)pageLayout;

            ////Find all existing elements with specified name
            ////Build a list of elements and then loop over the list to delete them
            //List<IElement> elementsToDelete = new List<IElement>();
            //graphicsContainer.Reset();
            //IElementProperties3 elementProperties3 = null;
            //IElement element = null;
            //while ((element = graphicsContainer.Next()) != null)
            //{
            //    elementProperties3 = (IElementProperties3)element;
            //    if (elementProperties3.Name == elementName)
            //    {
            //        elementsToDelete.Add(element);
            //    }
            //}

            //foreach (IElement elementToDelete in elementsToDelete)
            //{
            //    graphicsContainer.DeleteElement(elementToDelete);
            //}

            ////Define color
            //IRgbColor rgbColor = new RgbColorClass();
            //rgbColor.RGB = Color.Black.ToArgb();

            ////Define an arrow marker
            //IArrowMarkerSymbol arrowMarkerSymbol = new ArrowMarkerSymbolClass();
            //arrowMarkerSymbol.Color = rgbColor;
            //arrowMarkerSymbol.Size = 6;
            //arrowMarkerSymbol.Length = 8;
            //arrowMarkerSymbol.Width = 6;
            ////Add an offset to make sure the square end of the line is hidden
            //arrowMarkerSymbol.XOffset = 0.8;

            ////Create cartographic line symbol
            //ICartographicLineSymbol cartographicLineSymbol = new CartographicLineSymbolClass();
            //cartographicLineSymbol.Color = rgbColor;
            //cartographicLineSymbol.Width = 1;

            ////Define simple line decoration
            //ISimpleLineDecorationElement simpleLineDecorationElement = new SimpleLineDecorationElementClass();
            ////Place the arrow at the end of the line (the "To" point in the geometry below)
            //simpleLineDecorationElement.AddPosition(1);
            //simpleLineDecorationElement.MarkerSymbol = arrowMarkerSymbol;

            ////Define line decoration
            //ILineDecoration lineDecoration = new LineDecorationClass();
            //lineDecoration.AddElement(simpleLineDecorationElement);

            ////Set line properties
            //ILineProperties lineProperties = (ILineProperties)cartographicLineSymbol;
            //lineProperties.LineDecoration = lineDecoration;

            ////Define line element
            //ILineElement lineElement = new LineElementClass();
            //lineElement.Symbol = (ILineSymbol)cartographicLineSymbol;

            ////Create the line geometry
            //IPoint fromPoint = new PointClass();
            //fromPoint.X = 4.0;
            //fromPoint.Y = 0.8;

            //IPoint toPoint = new PointClass();
            //toPoint.X = 5.0;
            //toPoint.Y = 0.8;

            //IPolyline polyline = new PolylineClass();
            //polyline.FromPoint = fromPoint;
            //polyline.ToPoint = toPoint;

            ////Cast to Element and set geometry
            //element = (IElement)lineElement;
            //element.Geometry = polyline;

            ////Set the name
            //elementProperties3.Name = elementName;

            ////Add element to graphics container
            //graphicsContainer.AddElement(element, 0);

            ////Clear the graphics selection (graphics are selected when added)
            //IGraphicsContainerSelect graphicsContainerSelect = (IGraphicsContainerSelect)graphicsContainer;
            //graphicsContainerSelect.UnselectAllElements();

            //activeView.Refresh();
            #endregion
        }
コード例 #8
0
        protected override void OnClick()
        {
            // Create two points. 
            IPoint fromPoint = new Point();
            fromPoint.PutCoords(1300757, 554219);
            IPoint toPoint = new Point();
            toPoint.PutCoords(1300759, 554217);
            // Note: Spatial Reference = NAD_1983_StatePlane_Washington_North_FIPS_4601_Feet

            // ****** No Need to go through IPointCollection  ****

            //// Add the points to a point collection
            //object missing = Type.Missing;
            //IPointCollection pointCollection = new Multipoint();
            //pointCollection.AddPoint(fromPoint, ref missing, ref missing);  
            //pointCollection.AddPoint(toPoint, ref missing, ref missing);

            // ****** No Need to go through IPointCollection  ****


            // Get a reference to a feature class from ArcMap
            IMap map = ArcMap.Document.ActiveView as IMap;
            ILayer layer = map.get_Layer(0);
            IFeatureLayer featureLayer = layer as FeatureLayer;
            IFeatureClass featureClass = featureLayer.FeatureClass;
            IFeature feature = featureClass.CreateFeature();

            IPolyline polyline = new PolylineClass();
            polyline.FromPoint = fromPoint;
            polyline.ToPoint = toPoint;

            //IPolyline polyline = pointCollection as IPolyline; // This leads to a null polyline
            feature.Shape = polyline as IGeometry;
            feature.Store();

            // ---- Symbolize the polyline with the ArrorMarker at both ends of the line -----------
            // See: http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/index.html#//0001000008w8000000  

            ICartographicLineSymbol ipArrowLineSymbol = new CartographicLineSymbol();

            // the line color will be red
            IRgbColor ipRgbRedColor = new RgbColorClass();
            ipRgbRedColor.Red = 192;

            // the arrow will be black
            IRgbColor ipRgbBlackColor = new RgbColorClass();
            ipRgbBlackColor.RGB = 0;

            // set up the arrow that will be displayed along the line
            IArrowMarkerSymbol ipArrowMarker = new ArrowMarkerSymbolClass();
            ipArrowMarker.Style = esriArrowMarkerStyle.esriAMSPlain;
            ipArrowMarker.Length = 18;
            ipArrowMarker.Width = 12;
            ipArrowMarker.Color = ipRgbBlackColor;

            // set up the line itself
            ipArrowLineSymbol.Width = 4;
            ipArrowLineSymbol.Color = ipRgbRedColor;

            // decorate the line with the arrow symbol
            ISimpleLineDecorationElement ipSimpleLineDecorationElement = new SimpleLineDecorationElementClass();
            ipSimpleLineDecorationElement.Rotate = true;
            ipSimpleLineDecorationElement.PositionAsRatio = true;
            ipSimpleLineDecorationElement.MarkerSymbol = ipArrowMarker;
            ipSimpleLineDecorationElement.AddPosition(0.0);
            ipSimpleLineDecorationElement.AddPosition(1.0);
            ipSimpleLineDecorationElement.FlipFirst = true;
            ILineDecoration ipLineDecoration = new LineDecorationClass();
            ipLineDecoration.AddElement(ipSimpleLineDecorationElement);
            ((ILineProperties)ipArrowLineSymbol).LineDecoration = ipLineDecoration;

            // Create renderer and apply it to the layer
            ISimpleRenderer simpleRenderer = new SimpleRendererClass();
            simpleRenderer.Symbol = ipArrowLineSymbol as ISymbol;
            IGeoFeatureLayer geoFeatureLayer = featureLayer as IGeoFeatureLayer;
            geoFeatureLayer.Renderer = simpleRenderer as IFeatureRenderer;

            IMxDocument mxDocument = ArcMap.Application.Document as IMxDocument;
            mxDocument.ActiveView.Refresh();
            mxDocument.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, geoFeatureLayer, mxDocument.ActiveView.Extent);
            mxDocument.UpdateContents();

            // ---- Symbolize the polyline with the ArrorMarker at both ends of the line -----------



            ArcMap.Application.CurrentTool = null;
        }
コード例 #9
0
ファイル: FrmSymbol.cs プロジェクト: eglrp/TESTPROJECT-1
        //线 设计
        private void colorLine_SelectedColorChanged(object sender, EventArgs e)
        {
            if (pStyleGalleryItem == null)
            {
                MessageBox.Show("请选择线样式", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            ILineSymbol pLineSymbol = pStyleGalleryItem.Item as ILineSymbol;

            if (pLineSymbol == null)
            {
                return;
            }

            pLineSymbol.Color = ClsGDBDataCommon.ColorToIColor(colorLine.SelectedColor);
            //新添加,用于更改线修饰颜色
            if (pLineSymbol is IMultiLayerLineSymbol)
            {
                IMultiLayerLineSymbol pMultiLyerLine = pLineSymbol as IMultiLayerLineSymbol;
                int nLCount = pMultiLyerLine.LayerCount;
                for (int j = 0; j < nLCount; j++)
                {
                    ILineSymbol     Psymbol   = pMultiLyerLine.get_Layer(j);
                    ILineProperties pLineProp = Psymbol as ILineProperties;

                    List <ILineDecorationElement> Linedeclist = new List <ILineDecorationElement>();
                    if (pLineProp != null)
                    {
                        ILineDecoration pLineDec = pLineProp.LineDecoration;
                        if (pLineDec != null)
                        {
                            int ncount = pLineDec.ElementCount;
                            for (int i = 0; i < ncount; i++)
                            {
                                ILineDecorationElement pLineDecEle = pLineDec.get_Element(i);
                                Linedeclist.Add(pLineDecEle);
                            }
                            if (Linedeclist.Count > 0)
                            {
                                for (int i = 0; i < ncount; i++)
                                {
                                    ISimpleLineDecorationElement pSLDecEle = Linedeclist[i] as ISimpleLineDecorationElement;
                                    ISimpleLineDecorationElement pnewele   = new SimpleLineDecorationElementClass();
                                    if (pSLDecEle != null)
                                    {
                                        IMarkerSymbol pMSymbol = pSLDecEle.MarkerSymbol;

                                        pMSymbol.Color = ClsGDBDataCommon.ColorToIColor(colorLine.SelectedColor);
                                        pnewele.AddPosition(pSLDecEle.get_Position(i));
                                        pnewele.MarkerSymbol = pMSymbol;
                                        pLineDec.DeleteElement(i);
                                        pLineDec.AddElement(pnewele);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            PreviewImage();
        }
コード例 #10
0
        public void RefreshLayer()
        {
            if (pGraphicsLayer != null)
            {
                IGraphicsContainer pGC = pGraphicsLayer as IGraphicsContainer;
                int nCount             = m_IMUFeatureList.Count;

                pGC.DeleteAllElements();
                for (int i = 0; i < nCount; i++)
                {
                    IPolyline ppl = new PolylineClass();
                    ppl.FromPoint = m_IMUFeatureList[i].Shape as IPoint;
                    ppl.ToPoint   = m_CenterlinePointFeatureList[i].Shape as IPoint;

                    IRgbColor pColor = new RgbColorClass();


                    ICartographicLineSymbol pCartoLineSymbol = new CartographicLineSymbolClass();
                    pCartoLineSymbol.Cap = esriLineCapStyle.esriLCSRound;

                    ILineProperties pLineProp = pCartoLineSymbol as ILineProperties;
                    pLineProp.DecorationOnTop = true;

                    ILineDecoration pLineDecoration = new LineDecorationClass();
                    ISimpleLineDecorationElement pSimpleLineDecoElem = new SimpleLineDecorationElementClass();
                    pSimpleLineDecoElem.AddPosition(1);
                    IArrowMarkerSymbol pArrowMarkerSym = new ArrowMarkerSymbolClass();
                    pArrowMarkerSym.Size             = 8;
                    pArrowMarkerSym.Color            = pColor;
                    pSimpleLineDecoElem.MarkerSymbol = pArrowMarkerSym as IMarkerSymbol;
                    pLineDecoration.AddElement(pSimpleLineDecoElem as ILineDecorationElement);
                    pLineProp.LineDecoration = pLineDecoration;

                    ILineSymbol pLineSymbol = pCartoLineSymbol as ILineSymbol;

                    pLineSymbol.Color = pColor;
                    pLineSymbol.Width = 1;

                    ILineElement pLineElem = new LineElementClass();
                    pLineElem.Symbol = pLineSymbol;
                    IElement pElem = pLineElem as IElement;
                    pElem.Geometry = ppl;

                    pGC.AddElement(pElem, 0);

                    // IGraphicsContainerSelect pGCS = pGC as IGraphicsContainerSelect;
                    // pGCS.SelectAllElements();
                    //bool bbb =   pGCS.ElementSelected(pElement);
                    //pGC.UpdateElement(pElement);

                    // IGraphicsContainerSelect pGCS = pGC as IGraphicsContainerSelect;
                    // pGCS.SelectAllElements();
                    //bool bbb =   pGCS.ElementSelected(pElement);
                    //pGC.UpdateElement(pElement);

                    //pElement = new MarkerElementClass();
                    //pElement.Geometry = m_OriginPoints.get_Point(i);
                    //ISimpleMarkerSymbol sms = new SimpleMarkerSymbolClass();
                    //sms.Style = esriSimpleMarkerStyle.esriSMSSquare;
                    //sms.Size = 9;
                    //IMarkerElement im = pElement as IMarkerElement;
                    //im.Symbol = sms ;
                    //    IGraphicsContainer pGraphicsContainer = m_pMapCtr.Map.BasicGraphicsLayer as IGraphicsContainer;
                    //  pGraphicsContainer.AddElement(pElement, 0);
                    //pGC.AddElement(pElement,0);
                    //pGC.UpdateElement(pElement);



                    //IMarkerElement pMarkerEle = new MarkerElementClass();
                    //IPictureMarkerSymbol pPictureMarkerSymbol = new PictureMarkerSymbol();
                    ////pPictureMarkerSymbol.Color = sitecolor as IColor;
                    //pPictureMarkerSymbol.Size = 10;
                    //pPictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap,
                    //    GetParentPathofExe() + @"Resource\Globe.bmp");
                    //IElement pEle = pMarkerEle as IElement;
                    //pEle.Geometry = ppl.FromPoint;
                    //pMarkerEle.Symbol = pPictureMarkerSymbol;
                    //IGraphicsContainer pGraphicsContainer = m_pMapCtr.Map.BasicGraphicsLayer as IGraphicsContainer;
                    ////site.pEle = pEle;
                    //pGraphicsContainer.AddElement(pEle, 0);
                }

                IMapControl2 pMapCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl2;
                if (pMapCtr != null)
                {
                    if (m_IMUFeatureList.Count == 0)
                    {
                        pMapCtr.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewAll, null, null);
                    }
                    else
                    {
                        pMapCtr.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
                    }
                }
            }
        }
コード例 #11
0
 public static ILineSymbol CreateLineDirectionSymbol()
 {
     ILineSymbol symbol = new CartographicLineSymbolClass();
     symbol.Color = ColorHelper.CreateColor(0, 0, 200);
     LineDecorationClass class2 = new LineDecorationClass();
     SimpleLineDecorationElementClass lineDecorationElement = new SimpleLineDecorationElementClass();
     lineDecorationElement.AddPosition(0.3);
     lineDecorationElement.AddPosition(0.7);
     lineDecorationElement.PositionAsRatio = true;
     IMarkerSymbol symbol2 = (lineDecorationElement.MarkerSymbol as IClone).Clone() as IMarkerSymbol;
     symbol2.Size = 9.0;
     symbol2.Color = ColorHelper.CreateColor(0, 200, 0);
     lineDecorationElement.MarkerSymbol = symbol2;
     class2.AddElement(lineDecorationElement);
     (symbol as ILineProperties).LineDecoration = class2;
     return symbol;
 }
コード例 #12
0
		/// <summary>
		/// Flash a line feature on the map
		/// <param name="pDisplay">The map screen</param>
		/// <param name="pGeometry">The geometry of the feature to be flashed</param>
		/// <param name="direction">The digitized direction of the barrier with respect to the underlying source feature</param>
		/// </summary>
		private void FlashLine(IScreenDisplay pDisplay, IGeometry pGeometry, esriNetworkEdgeDirection direction)
		{
			// The flash will be on a line symbol with an arrow on it
			ICartographicLineSymbol ipArrowLineSymbol = new CartographicLineSymbolClass();

			// the line color will be red
			IRgbColor ipRgbRedColor = new RgbColorClass();
			ipRgbRedColor.Red = 192;

			// the arrow will be black
			IRgbColor ipRgbBlackColor = new RgbColorClass();
			ipRgbBlackColor.RGB = 0;

			// set up the arrow that will be displayed along the line
			IArrowMarkerSymbol ipArrowMarker = new ArrowMarkerSymbolClass();
			ipArrowMarker.Style = esriArrowMarkerStyle.esriAMSPlain;
			ipArrowMarker.Length = 18;
			ipArrowMarker.Width = 12;
			ipArrowMarker.Color = ipRgbBlackColor;

			// set up the line itself
			ipArrowLineSymbol.Width = 4;
			ipArrowLineSymbol.Color = ipRgbRedColor;

			// Set up the Raster Op-Code to help the flash mechanism
			((ISymbol)ipArrowMarker).ROP2 = esriRasterOpCode.esriROPNotXOrPen;
			((ISymbol)ipArrowLineSymbol).ROP2 = esriRasterOpCode.esriROPNotXOrPen;

			// decorate the line with the arrow symbol
			ISimpleLineDecorationElement ipSimpleLineDecorationElement = new SimpleLineDecorationElementClass();
			ipSimpleLineDecorationElement.Rotate = true;
			ipSimpleLineDecorationElement.PositionAsRatio = true;
			ipSimpleLineDecorationElement.MarkerSymbol = ipArrowMarker;
			ipSimpleLineDecorationElement.AddPosition(0.5);
			ILineDecoration ipLineDecoration = new LineDecorationClass();
			ipLineDecoration.AddElement(ipSimpleLineDecorationElement);
			((ILineProperties)ipArrowLineSymbol).LineDecoration = ipLineDecoration;

			// the arrow is initially set to correspond to the digitized direction of the line
			//  if the barrier direction is against digitized, then we need to flip the arrow direction
			if (direction == esriNetworkEdgeDirection.esriNEDAgainstDigitized)
				ipSimpleLineDecorationElement.FlipAll = true;

			// Flash the line
			//  Two calls are made to Draw.  Since the ROP2 setting is NotXOrPen, the first call
			//  draws the symbol with our new symbology and the second call redraws what was originally 
			//  in the place of the symbol
			pDisplay.SetSymbol(ipArrowLineSymbol as ISymbol);
			pDisplay.DrawPolyline(pGeometry);
			System.Threading.Thread.Sleep(300);
			pDisplay.DrawPolyline(pGeometry);
		}
コード例 #13
0
        // *********************
        //      Author: Erika Kamptner
        //      Created Date: 3/10/2017
        //      Description: This method takes several parameters from the BuildMap method to connect to geodatabase, load layer,
        //      place in appropriate group layer, style, and label. Only Address points, Cadastral, Building, and Centerline layers
        //      have specified labels and symbology.
        //
        // **************************

        public static void LoadCSCLFeatureClass(bool isCSCL, string strFCName, IGroupLayer pGroupLayer, string strGeodatabase)
        {
            //Point to map document
            IMxDocument pMxDoc;

            pMxDoc = (IMxDocument)ArcMap.Application.Document;

            IMap pMap;

            pMap = pMxDoc.FocusMap;

            //Set up shapefile Workspace connection
            IWorkspaceFactory pWorkspaceFactory;

            pWorkspaceFactory = new ShapefileWorkspaceFactoryClass();

            //If connecting to SDE, set up SDE workspace connection
            //IWorkspaceFactory pWorkspaceFactory;
            //pWorkspaceFactory = new SdeWorkspaceFactoryClass();

            IWorkspace pWorkspace;

            pWorkspace = pWorkspaceFactory.OpenFromFile(strGeodatabase, 0);

            IFeatureWorkspace pFeatureWorkspace;

            pFeatureWorkspace = (IFeatureWorkspace)pWorkspace;

            IFeatureClass pFeatureClass;

            pFeatureClass = pFeatureWorkspace.OpenFeatureClass(strFCName);

            IFeatureLayer pFeatureLayer;

            pFeatureLayer = new FeatureLayer();

            pFeatureLayer.FeatureClass = pFeatureClass;
            pFeatureLayer.Name         = pFeatureClass.AliasName;

            //Add layer to group if CSCL map type. Otherwise, just add layer.
            if (isCSCL)
            {
                pGroupLayer.Add((ILayer)pFeatureLayer);
            }
            else
            {
                pMap.AddLayer((ILayer)pFeatureLayer);
            }

            //Symbolize Address points based if the address has subaddresses
            if (pFeatureLayer.Name == "AddressPoint")
            {
                ILayer pLayer;
                pLayer = (ILayer)pFeatureLayer;

                IGeoFeatureLayer pGeoFeatureLayer;
                pGeoFeatureLayer = (IGeoFeatureLayer)pLayer;

                pGeoFeatureLayer.DisplayAnnotation = true;

                //Create unique symbology based on subaddress flag using unique value renderer
                ISimpleMarkerSymbol pAddressSymbolDefault;
                pAddressSymbolDefault = new SimpleMarkerSymbolClass();

                pAddressSymbolDefault.Color = SetColor(230, 0, 0);
                pAddressSymbolDefault.Style = esriSimpleMarkerStyle.esriSMSCircle;
                pAddressSymbolDefault.Size  = 4;

                IUniqueValueRenderer pUniqueValueRenderer;
                pUniqueValueRenderer = new UniqueValueRendererClass();

                pUniqueValueRenderer.FieldCount = 1;
                pUniqueValueRenderer.set_Field(0, "SUBADDRESS");
                pUniqueValueRenderer.UseDefaultSymbol = false;

                //Create unique symbology for different values
                ISimpleMarkerSymbol pAddressSymbolYES;
                pAddressSymbolYES = new SimpleMarkerSymbolClass();

                pAddressSymbolYES.Color        = SetColor(230, 0, 0);
                pAddressSymbolYES.Style        = esriSimpleMarkerStyle.esriSMSCircle;
                pAddressSymbolYES.Size         = 8;
                pAddressSymbolYES.OutlineSize  = 2;
                pAddressSymbolYES.OutlineColor = SetColor(255, 255, 0);
                pAddressSymbolYES.Outline      = true;

                ISimpleMarkerSymbol pAddressSymbolNO;
                pAddressSymbolNO = new SimpleMarkerSymbolClass();

                pAddressSymbolNO.Color = SetColor(230, 0, 0);
                pAddressSymbolNO.Style = esriSimpleMarkerStyle.esriSMSCircle;
                pAddressSymbolNO.Size  = 4;

                pUniqueValueRenderer.AddValue("YES", "SUBADDRESS", pAddressSymbolYES as ISymbol);
                pUniqueValueRenderer.set_Label("YES", "YES");
                pUniqueValueRenderer.set_Symbol("YES", pAddressSymbolYES as ISymbol);

                pUniqueValueRenderer.AddValue("NO", "SUBADDRESS", pAddressSymbolNO as ISymbol);
                pUniqueValueRenderer.set_Label("NO", "NO");
                pUniqueValueRenderer.set_Symbol("NO", pAddressSymbolNO as ISymbol);

                //Create Label
                LabelFeatures(pGeoFeatureLayer, "\"ADDRESSID: \" + [ADDRESS_ID]");

                pGeoFeatureLayer.Renderer = (IFeatureRenderer)pUniqueValueRenderer;
            }

            else if (pFeatureLayer.Name == "Building")
            {
                ILayer pLayer;
                pLayer = (ILayer)pFeatureLayer;

                IGeoFeatureLayer pGeoFeatureLayer;
                pGeoFeatureLayer = (IGeoFeatureLayer)pLayer;

                pGeoFeatureLayer.DisplayField      = "BIN";
                pGeoFeatureLayer.DisplayAnnotation = true;

                //Create ouline element
                ISimpleLineSymbol pOutline;
                pOutline       = new SimpleLineSymbolClass();
                pOutline.Color = SetColor(0, 0, 255);
                pOutline.Width = 2;

                //Create polygon with outline element
                ISimpleFillSymbol pBuildingSymbol;
                pBuildingSymbol         = new SimpleFillSymbolClass();
                pBuildingSymbol.Style   = esriSimpleFillStyle.esriSFSHollow;
                pBuildingSymbol.Outline = pOutline;

                //Create Label
                LabelFeatures(pGeoFeatureLayer, "\"BIN : \" + [BIN]");

                //Render features
                ISimpleRenderer pSimpleRenderer;
                pSimpleRenderer        = new SimpleRenderer();
                pSimpleRenderer.Symbol = (ISymbol)pBuildingSymbol;

                pGeoFeatureLayer.Renderer = (IFeatureRenderer)pSimpleRenderer;
            }

            else if (pFeatureLayer.Name == "StreetCenterline")
            {
                ILayer pLayer;
                pLayer = (ILayer)pFeatureLayer;

                IGeoFeatureLayer pGeoFeatureLayer;
                pGeoFeatureLayer = (IGeoFeatureLayer)pLayer;

                pGeoFeatureLayer.DisplayField      = "ST_NAME";
                pGeoFeatureLayer.DisplayAnnotation = true;

                //Create arrow element to place at end of line segment
                IArrowMarkerSymbol arrowMarkerSymbol = new ArrowMarkerSymbolClass();
                arrowMarkerSymbol.Color   = SetColor(0, 0, 0);
                arrowMarkerSymbol.Size    = 6;
                arrowMarkerSymbol.Length  = 8;
                arrowMarkerSymbol.Width   = 6;
                arrowMarkerSymbol.XOffset = 0.8;

                //Create cartographic line symbol
                ICartographicLineSymbol pCartographicLineSymbol;
                pCartographicLineSymbol       = new CartographicLineSymbolClass();
                pCartographicLineSymbol.Color = SetColor(0, 0, 0);
                pCartographicLineSymbol.Width = 2;

                //Place arrow at end of line
                ISimpleLineDecorationElement pCenterlineDecoration;
                pCenterlineDecoration = new SimpleLineDecorationElementClass();
                pCenterlineDecoration.AddPosition(1);
                pCenterlineDecoration.MarkerSymbol = arrowMarkerSymbol;
                pCenterlineDecoration.Rotate       = true;

                //set line decoration
                ILineDecoration pLineDecoration;
                pLineDecoration = new LineDecorationClass();
                pLineDecoration.AddElement(pCenterlineDecoration);

                //Set line properties
                ILineProperties lineProperties = (ILineProperties)pCartographicLineSymbol;
                lineProperties.LineDecoration = pLineDecoration;
                lineProperties.Flip           = false;

                //Create Label
                LabelFeatures(pGeoFeatureLayer, "[L_LOW_HN] + \" - \" + [L_HIGH_HN]+ \"   \" +[ST_NAME] + vbCrLf + [PHYSICALID]");

                //Render features
                ISimpleRenderer pSimpleRenderer;
                pSimpleRenderer        = new SimpleRenderer();
                pSimpleRenderer.Symbol = (ISymbol)pCartographicLineSymbol;

                pGeoFeatureLayer.Renderer = (IFeatureRenderer)pSimpleRenderer;
            }
            else if (pFeatureLayer.Name == "Cadastral")
            {
                ILayer pLayer;
                pLayer = (ILayer)pFeatureLayer;

                IGeoFeatureLayer pGeoFeatureLayer;
                pGeoFeatureLayer = (IGeoFeatureLayer)pLayer;

                pGeoFeatureLayer.DisplayField      = "BBL";
                pGeoFeatureLayer.DisplayAnnotation = true;

                //Create ouline element
                ISimpleLineSymbol pOutline;
                pOutline       = new SimpleLineSymbolClass();
                pOutline.Color = SetColor(76, 230, 0);
                pOutline.Width = 2;

                //Create polygon with outline element
                ISimpleFillSymbol pTaxLotSymbol;
                pTaxLotSymbol         = new SimpleFillSymbolClass();
                pTaxLotSymbol.Style   = esriSimpleFillStyle.esriSFSHollow;
                pTaxLotSymbol.Outline = pOutline;

                //Create label
                LabelFeatures(pGeoFeatureLayer, "\"BBL: \" + [BBL]");

                //Render features
                ISimpleRenderer pSimpleRenderer;
                pSimpleRenderer        = new SimpleRenderer();
                pSimpleRenderer.Symbol = (ISymbol)pTaxLotSymbol;

                pGeoFeatureLayer.Renderer = (IFeatureRenderer)pSimpleRenderer;
            }
            else
            {
                pFeatureLayer.Visible = false;
            }
        }
コード例 #14
0
        protected override void OnClick()
        {
            // Create two points.
            IPoint fromPoint = new Point();

            fromPoint.PutCoords(1300757, 554219);
            IPoint toPoint = new Point();

            toPoint.PutCoords(1300759, 554217);
            // Note: Spatial Reference = NAD_1983_StatePlane_Washington_North_FIPS_4601_Feet

            // ****** No Need to go through IPointCollection  ****

            //// Add the points to a point collection
            //object missing = Type.Missing;
            //IPointCollection pointCollection = new Multipoint();
            //pointCollection.AddPoint(fromPoint, ref missing, ref missing);
            //pointCollection.AddPoint(toPoint, ref missing, ref missing);

            // ****** No Need to go through IPointCollection  ****


            // Get a reference to a feature class from ArcMap
            IMap          map          = ArcMap.Document.ActiveView as IMap;
            ILayer        layer        = map.get_Layer(0);
            IFeatureLayer featureLayer = layer as FeatureLayer;
            IFeatureClass featureClass = featureLayer.FeatureClass;
            IFeature      feature      = featureClass.CreateFeature();

            IPolyline polyline = new PolylineClass();

            polyline.FromPoint = fromPoint;
            polyline.ToPoint   = toPoint;

            //IPolyline polyline = pointCollection as IPolyline; // This leads to a null polyline
            feature.Shape = polyline as IGeometry;
            feature.Store();

            // ---- Symbolize the polyline with the ArrorMarker at both ends of the line -----------
            // See: http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/index.html#//0001000008w8000000

            ICartographicLineSymbol ipArrowLineSymbol = new CartographicLineSymbol();

            // the line color will be red
            IRgbColor ipRgbRedColor = new RgbColorClass();

            ipRgbRedColor.Red = 192;

            // the arrow will be black
            IRgbColor ipRgbBlackColor = new RgbColorClass();

            ipRgbBlackColor.RGB = 0;

            // set up the arrow that will be displayed along the line
            IArrowMarkerSymbol ipArrowMarker = new ArrowMarkerSymbolClass();

            ipArrowMarker.Style  = esriArrowMarkerStyle.esriAMSPlain;
            ipArrowMarker.Length = 18;
            ipArrowMarker.Width  = 12;
            ipArrowMarker.Color  = ipRgbBlackColor;

            // set up the line itself
            ipArrowLineSymbol.Width = 4;
            ipArrowLineSymbol.Color = ipRgbRedColor;

            // decorate the line with the arrow symbol
            ISimpleLineDecorationElement ipSimpleLineDecorationElement = new SimpleLineDecorationElementClass();

            ipSimpleLineDecorationElement.Rotate          = true;
            ipSimpleLineDecorationElement.PositionAsRatio = true;
            ipSimpleLineDecorationElement.MarkerSymbol    = ipArrowMarker;
            ipSimpleLineDecorationElement.AddPosition(0.0);
            ipSimpleLineDecorationElement.AddPosition(1.0);
            ipSimpleLineDecorationElement.FlipFirst = true;
            ILineDecoration ipLineDecoration = new LineDecorationClass();

            ipLineDecoration.AddElement(ipSimpleLineDecorationElement);
            ((ILineProperties)ipArrowLineSymbol).LineDecoration = ipLineDecoration;

            // Create renderer and apply it to the layer
            ISimpleRenderer simpleRenderer = new SimpleRendererClass();

            simpleRenderer.Symbol = ipArrowLineSymbol as ISymbol;
            IGeoFeatureLayer geoFeatureLayer = featureLayer as IGeoFeatureLayer;

            geoFeatureLayer.Renderer = simpleRenderer as IFeatureRenderer;

            IMxDocument mxDocument = ArcMap.Application.Document as IMxDocument;

            mxDocument.ActiveView.Refresh();
            mxDocument.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, geoFeatureLayer, mxDocument.ActiveView.Extent);
            mxDocument.UpdateContents();

            // ---- Symbolize the polyline with the ArrorMarker at both ends of the line -----------



            ArcMap.Application.CurrentTool = null;
        }