Ejemplo n.º 1
0
        public FlowSymbol()
        {
            ISimpleMarkerSymbol symbol = new SimpleMarkerSymbolClass();
            IRgbColor           color  = new RgbColorClass
            {
                Green = 0,
                Blue  = 0,
                Red   = 0
            };

            symbol.Color = color;
            symbol.Style = esriSimpleMarkerStyle.esriSMSCircle;
            symbol.Size  = 6.0;
            this.m_UninitializedFolwArrow = symbol as ISymbol;
            this.m_IndeterminateFolwArrow = (symbol as IClone).Clone() as ISymbol;
            IArrowMarkerSymbol symbol2 = new ArrowMarkerSymbolClass();
            IRgbColor          color2  = new RgbColorClass
            {
                Green = 0,
                Blue  = 0,
                Red   = 0
            };

            symbol2.Color = color2;
            symbol2.Style = esriArrowMarkerStyle.esriAMSPlain;
            symbol2.Size  = 9.0;
            this.m_DeterminateFolwArrow = symbol2 as ISymbol;
        }
Ejemplo n.º 2
0
        //MarkerLineSymbol
        private void button10_Click(object sender, EventArgs e)
        {
            IArrowMarkerSymbol arrowMarkerSymbol = new ArrowMarkerSymbolClass();
            IRgbColor          rgbColor          = getRGB(255, 0, 0);

            arrowMarkerSymbol.Color  = rgbColor as IColor;
            arrowMarkerSymbol.Length = 10;
            arrowMarkerSymbol.Width  = 10;
            arrowMarkerSymbol.Style  = esriArrowMarkerStyle.esriAMSPlain;

            IMarkerLineSymbol markerLineSymbol = new MarkerLineSymbolClass();

            markerLineSymbol.MarkerSymbol = arrowMarkerSymbol;
            rgbColor = getRGB(0, 255, 0);
            markerLineSymbol.Color = rgbColor;
            IPolyline polyline = new PolylineClass();
            IPoint    point    = new PointClass();

            point.PutCoords(1, 1);
            polyline.FromPoint = point;
            point.PutCoords(10, 10);
            polyline.ToPoint = point;
            IActiveView activeView = this.axMapControl1.ActiveView;

            activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
            activeView.ScreenDisplay.SetSymbol(markerLineSymbol as ISymbol);
            activeView.ScreenDisplay.DrawPolyline(polyline as IGeometry);
            activeView.ScreenDisplay.FinishDrawing();
            activeView.ScreenDisplay.FinishDrawing();
        }
Ejemplo n.º 3
0
 //箭头符号化
 private void ArrowMarkerSymbolToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         //获得点图层,要求当前地图文档第一个图层为点图层
         IFeatureLayer layer;
         layer = mainMapControl.get_Layer(0) as IFeatureLayer;
         //QI到IGeoFeatureLayer
         IGeoFeatureLayer   geoFeatureLayer = layer as IGeoFeatureLayer;
         SimpleRenderer     simpleRender    = new SimpleRendererClass();
         IArrowMarkerSymbol pMarkerSymbol;
         IRgbColor          pColor = new RgbColorClass();
         pColor.Red           = 255;
         pColor.Green         = 0;
         pColor.Blue          = 255;
         pMarkerSymbol        = new ArrowMarkerSymbolClass();
         pMarkerSymbol.Length = 20;
         pMarkerSymbol.Color  = pColor;
         pMarkerSymbol.Width  = 10;
         //箭头底边的宽度
         pMarkerSymbol.Angle      = 60;
         simpleRender.Symbol      = pMarkerSymbol as ISymbol;
         geoFeatureLayer.Renderer = simpleRender as IFeatureRenderer;
         mainMapControl.Refresh();
         axTOCControl1.Update();
     }
     catch
     {
         MessageBox.Show("没有可以实例化的图层");
     }
 }
        /// <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);
        }
Ejemplo n.º 5
0
        private IArrowMarkerSymbol creatarrowpoint(Color color, double length, double width, double angle, double xoffset, double yoffset)
        {
            IArrowMarkerSymbol arrowMarkerSymbol = new ArrowMarkerSymbolClass();

            arrowMarkerSymbol.Color   = ClsGDBDataCommon.ColorToIColor(color);
            arrowMarkerSymbol.Length  = length;
            arrowMarkerSymbol.Width   = width;
            arrowMarkerSymbol.Angle   = angle;
            arrowMarkerSymbol.XOffset = xoffset;
            arrowMarkerSymbol.YOffset = yoffset;


            return(arrowMarkerSymbol);
        }
Ejemplo n.º 6
0
        //MarkerFillSymbol
        private void button14_Click(object sender, EventArgs e)
        {
            IArrowMarkerSymbol arrowMarkerSymbol = new ArrowMarkerSymbolClass();
            IRgbColor          rgbColor          = getRGB(255, 0, 0);

            arrowMarkerSymbol.Color  = rgbColor as IColor;
            arrowMarkerSymbol.Length = 10;
            arrowMarkerSymbol.Width  = 10;
            arrowMarkerSymbol.Style  = esriArrowMarkerStyle.esriAMSPlain;


            IMarkerFillSymbol markerFillSymbol = new MarkerFillSymbolClass();

            markerFillSymbol.MarkerSymbol = arrowMarkerSymbol;
            rgbColor = getRGB(0, 255, 0);
            markerFillSymbol.Color = rgbColor;
            markerFillSymbol.Style = esriMarkerFillStyle.esriMFSGrid;

            IFillProperties fillProperties = markerFillSymbol as IFillProperties;

            fillProperties.XOffset     = 2;
            fillProperties.YOffset     = 2;
            fillProperties.XSeparation = 15;
            fillProperties.YSeparation = 20;

            object           Missing         = Type.Missing;
            IPolygon         polygon         = new PolygonClass();
            IPointCollection pointCollection = polygon as IPointCollection;
            IPoint           point           = new PointClass();

            point.PutCoords(5, 5);
            pointCollection.AddPoint(point, ref Missing, ref Missing);
            point.PutCoords(5, 10);
            pointCollection.AddPoint(point, ref Missing, ref Missing);
            point.PutCoords(10, 10);
            pointCollection.AddPoint(point, ref Missing, ref Missing);
            point.PutCoords(10, 5);
            pointCollection.AddPoint(point, ref Missing, ref Missing);
            polygon.SimplifyPreserveFromTo();
            IActiveView activeView = this.axMapControl1.ActiveView;

            activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
            activeView.ScreenDisplay.SetSymbol(markerFillSymbol as ISymbol);
            activeView.ScreenDisplay.DrawPolygon(polygon as IGeometry);
            activeView.ScreenDisplay.FinishDrawing();
        }
        private IElement AddArrow(IPoint point, double angle)
        {
            //Create a new graphic element
            IMarkerSymbol arrowSymbol = new ArrowMarkerSymbolClass();

            arrowSymbol.Angle = angle;
            arrowSymbol.Color = EsriColor(Defaults.CurrentGpsPointColor);
            arrowSymbol.Size  = Defaults.CurrentGpsPointSize;
            IElement marker = new MarkerElementClass();

            ((IMarkerElement)marker).Symbol = arrowSymbol;
            marker.Geometry = point;
            _elementId++;
            ((IElementProperties)marker).CustomProperty = _elementId;
            ((IGraphicsContainer)GraphicsLayer).AddElement(marker, 0);
            return(marker);
        }
Ejemplo n.º 8
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);
        }
Ejemplo n.º 9
0
        private void ArrowpointToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IFeatureLayer layer;

            layer = axMapControl1.get_Layer(0) as IFeatureLayer;            //QI到IGeoFeatureLayer
            IGeoFeatureLayer   geoFeatureLayer = layer as IGeoFeatureLayer; //新建SimpleRendererClass对象
            SimpleRenderer     simpleRender = new SimpleRendererClass();
            IArrowMarkerSymbol pMarkerSymbol; IRgbColor pColor = new RgbColorClass();

            pColor.Red               = 255; pColor.Green = 0;
            pColor.Blue              = 255;
            pMarkerSymbol            = new ArrowMarkerSymbolClass();
            pMarkerSymbol.Length     = 20;
            pMarkerSymbol.Color      = pColor;
            pMarkerSymbol.Width      = 10; //箭头底边的宽度
            pMarkerSymbol.Angle      = 60;
            simpleRender.Symbol      = pMarkerSymbol as ISymbol;
            geoFeatureLayer.Renderer = simpleRender as IFeatureRenderer;
            axMapControl1.Refresh();
            axTOCControl1.Update();
        }
Ejemplo n.º 10
0
 //组合点符号化
 private void MultiLayerMarkerSymbolToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         //获得点图层,要求当前地图文档第一个图层为点图层
         IFeatureLayer layer;
         layer = mainMapControl.get_Layer(0) as IFeatureLayer;
         //QI到IGeoFeatureLayer
         IGeoFeatureLayer geoFeatureLayer = layer as IGeoFeatureLayer;
         SimpleRenderer   simpleRender    = new SimpleRendererClass();
         //创建第一组成成分点符号的颜色
         IColor pColor = new RgbColorClass();
         pColor.RGB = 2256;
         //创建第二组成成分点符号的颜色
         IColor pColor1 = new RgbColorClass();
         pColor1.RGB = 0;
         //创建简单点符号
         ISimpleMarkerSymbol pMarkerSymbol = new SimpleMarkerSymbolClass();
         pMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCross;
         pMarkerSymbol.Color = pColor;
         pMarkerSymbol.Angle = 60;
         //创建箭头点符号
         IArrowMarkerSymbol pArrowMarkerSymbol = new ArrowMarkerSymbolClass();
         pArrowMarkerSymbol.Length = 5;
         pArrowMarkerSymbol.Width  = 10;
         pArrowMarkerSymbol.Color  = pColor1;
         //创建以上两种符号的组合符号
         IMultiLayerMarkerSymbol pMultiLayerMarkerSymbol = new MultiLayerMarkerSymbolClass();
         pMultiLayerMarkerSymbol.AddLayer(pArrowMarkerSymbol);
         pMultiLayerMarkerSymbol.AddLayer(pMarkerSymbol);
         simpleRender.Symbol      = pMultiLayerMarkerSymbol as ISymbol;
         geoFeatureLayer.Renderer = simpleRender as IFeatureRenderer;
         mainMapControl.Refresh();
         axTOCControl1.Update();
     }
     catch
     {
         MessageBox.Show("没有可以实例化的图层");
     }
 }
Ejemplo n.º 11
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);
        }
Ejemplo n.º 12
0
        //ArrowMarkerSymbol
        private void button2_Click(object sender, EventArgs e)
        {
            IArrowMarkerSymbol arrowMarkerSymbol = new ArrowMarkerSymbolClass();
            IRgbColor          iRgbColor;

            iRgbColor = new RgbColor();
            iRgbColor = getRGB(100, 100, 100);
            arrowMarkerSymbol.Angle   = 90;
            arrowMarkerSymbol.Color   = iRgbColor;
            arrowMarkerSymbol.Length  = 30;
            arrowMarkerSymbol.Width   = 20;
            arrowMarkerSymbol.XOffset = 0;
            arrowMarkerSymbol.YOffset = 0;
            arrowMarkerSymbol.Style   = esriArrowMarkerStyle.esriAMSPlain;
            IPoint point1 = new PointClass();
            IPoint point2 = new PointClass();

            point1.PutCoords(5, 5);
            point2.PutCoords(5, 10);
            this.axMapControl1.FlashShape(point1 as IGeometry, 3, 500, arrowMarkerSymbol);
            this.axMapControl1.FlashShape(point2 as IGeometry);
        }
Ejemplo n.º 13
0
        private void GroupPointToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IFeatureLayer layer;

            layer = axMapControl1.get_Layer(0) as IFeatureLayer;          //QI到IGeoFeatureLayer
            IGeoFeatureLayer geoFeatureLayer = layer as IGeoFeatureLayer; //新建SimpleRendererClass对象
            SimpleRenderer   simpleRender    = new SimpleRendererClass();
            //创建第一组成成分点符号的颜色
            IColor pColor = new RgbColorClass();

            pColor.RGB = 2256;
            //创建第二组成成分点符号的颜色
            IColor pColor1 = new RgbColorClass();

            pColor1.RGB = 0;
            //创建简单点符号
            ISimpleMarkerSymbol pMarkerSymbol = new SimpleMarkerSymbolClass();

            pMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCross;
            pMarkerSymbol.Color = pColor;
            pMarkerSymbol.Angle = 60;
            //创建箭头点符号
            IArrowMarkerSymbol pArrowMarkerSymbol = new ArrowMarkerSymbolClass();

            pArrowMarkerSymbol.Length = 5;
            pArrowMarkerSymbol.Width  = 10;
            pArrowMarkerSymbol.Color  = pColor1;
            //创建以上两种符号的组合符号
            IMultiLayerMarkerSymbol pMultiLayerMarkerSymbol = new  MultiLayerMarkerSymbolClass();

            pMultiLayerMarkerSymbol.AddLayer(pArrowMarkerSymbol);
            pMultiLayerMarkerSymbol.AddLayer(pMarkerSymbol);
            simpleRender.Symbol      = pMultiLayerMarkerSymbol as ISymbol;
            geoFeatureLayer.Renderer = simpleRender as IFeatureRenderer;
            axMapControl1.Refresh();
            axTOCControl1.Update();
        }
Ejemplo n.º 14
0
        private void DrawFlowDirection(IFeature feature, IMapControlDefault mapc, esriFlowDirection flowdir)
        {
            //获取线段中点
            IPolyline polyline = feature.Shape as IPolyline;
            IPoint    midpoint = new PointClass();

            polyline.QueryPoint(esriSegmentExtension.esriNoExtension, polyline.Length / 2, false, midpoint);
            //绘制特征符号
            IArrowMarkerSymbol  arrowSymbol  = new ArrowMarkerSymbolClass();
            ISimpleMarkerSymbol markerSymbol = new SimpleMarkerSymbolClass();

            IElement element = null;

            //绘制沿顺着数字化流向
            if (flowdir == esriFlowDirection.esriFDWithFlow)
            {
                arrowSymbol.Size  = 12;
                arrowSymbol.Color = ExportMap.Getcolor(0, 0, 0);
                arrowSymbol.Angle = GetlineAngle(polyline.FromPoint, polyline.ToPoint);

                //绘制

                element          = new MarkerElementClass();
                element.Geometry = midpoint;
                ((IMarkerElement)element).Symbol = arrowSymbol;
                //设置绘制元素名称
                ((IElementProperties)element).Name = "Flow";
            }
            //方向顺着逆数字化的
            if (flowdir == esriFlowDirection.esriFDAgainstFlow)
            {
                arrowSymbol.Size  = 12;
                arrowSymbol.Color = ExportMap.Getcolor(0, 0, 0);
                arrowSymbol.Angle = GetlineAngle(polyline.FromPoint, polyline.ToPoint);

                //绘制

                element          = new MarkerElementClass();
                element.Geometry = midpoint;
                ((IMarkerElement)element).Symbol = arrowSymbol;
                //设置绘制元素名称
                ((IElementProperties)element).Name = "Flow";
            }
            //方向未初始化的
            if (flowdir == esriFlowDirection.esriFDUninitialized)
            {
                markerSymbol.Color = ExportMap.Getcolor(0, 0, 0);
                markerSymbol.Size  = 8;

                element          = new MarkerElementClass();
                element.Geometry = midpoint;
                ((IMarkerElement)element).Symbol = markerSymbol;
                //设置绘制元素名称
                ((IElementProperties)element).Name = "Flow";
            }
            //方向未定义的
            if (flowdir == esriFlowDirection.esriFDIndeterminate)
            {
                markerSymbol.Color = ExportMap.Getcolor(0, 0, 0);
                markerSymbol.Size  = 8;

                element          = new MarkerElementClass();
                element.Geometry = midpoint;
                ((IMarkerElement)element).Symbol = markerSymbol;
                //设置绘制元素名称
                ((IElementProperties)element).Name = "Flow";
            }
            mapc.ActiveView.GraphicsContainer.AddElement(element, 0);
        }
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            DF2DApplication    app = DF2DApplication.Application;
            IGraphicsContainer gc  = app.Current2DMapControl.Map as IGraphicsContainer;

            gc.DeleteAllElements();
            bool ready = true;

            if (app == null || app.Current2DMapControl == null)
            {
                return;
            }
            m_ActiveView = app.Current2DMapControl.ActiveView;
            IScreenDisplay m_Display = app.Current2DMapControl.ActiveView.ScreenDisplay;

            try
            {
                if (button == 1)
                {
                    ISimpleLineSymbol pLineSym = new SimpleLineSymbol();
                    IRgbColor         pColor   = new RgbColorClass();
                    pColor.Red     = 255;
                    pColor.Green   = 255;
                    pColor.Blue    = 0;
                    pLineSym.Color = pColor;
                    pLineSym.Style = esriSimpleLineStyle.esriSLSSolid;
                    pLineSym.Width = 2;

                    ISimpleFillSymbol pFillSym = new SimpleFillSymbol();

                    pFillSym.Color   = pColor;
                    pFillSym.Style   = esriSimpleFillStyle.esriSFSDiagonalCross;
                    pFillSym.Outline = pLineSym;

                    object      symbol = pFillSym as object;
                    IRubberBand band   = new RubberRectangularPolygonClass();
                    IGeometry   geo    = band.TrackNew(m_Display, null);
                    app.Current2DMapControl.DrawShape(geo, ref symbol);
                    WaitForm.Start("正在查询...", "请稍后");

                    if (geo.IsEmpty)
                    {
                        IPoint searchPoint = new PointClass();
                        searchPoint.PutCoords(mapX, mapY);
                        geo = PublicFunction.DoBuffer(searchPoint, PublicFunction.ConvertPixelsToMapUnits(m_ActiveView, GlobalValue.System_Selection_Option().Tolerate));
                        //m_ActiveView.FocusMap.SelectByShape(geo, s, false);
                    }
                    if (ready)
                    {
                        foreach (MajorClass mc in LogicDataStructureManage2D.Instance.GetAllMajorClass())
                        {
                            if (mc.Alias == "电力" || mc.Alias == "通信" || mc.Alias == "架空")
                            {
                                continue;
                            }
                            string[] arrFc2DId = mc.Fc2D.Split(';');
                            if (arrFc2DId == null)
                            {
                                continue;
                            }
                            foreach (SubClass sc in mc.SubClasses)
                            {
                                if (!sc.Visible2D)
                                {
                                    continue;
                                }
                                foreach (string fc2DId in arrFc2DId)
                                {
                                    DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId);
                                    if (dffc == null)
                                    {
                                        continue;
                                    }
                                    FacilityClass facc = dffc.GetFacilityClass();
                                    IFeatureClass fc   = dffc.GetFeatureClass();
                                    if (fc == null || facc == null || facc.Name != "PipeLine")
                                    {
                                        continue;
                                    }
                                    DFDataConfig.Class.FieldInfo fiDirection = facc.GetFieldInfoBySystemName("FlowDirection");
                                    if (fiDirection == null)
                                    {
                                        continue;
                                    }

                                    IFields pFields = fc.Fields;
                                    //string[] name = new string[pFields.FieldCount];
                                    //for (int i = 0; i < pFields.FieldCount; i++)
                                    //{
                                    //    name[i] = pFields.get_Field(i).Name;
                                    //}
                                    int indexDirection = pFields.FindField(fiDirection.Name);
                                    if (indexDirection < 0)
                                    {
                                        continue;
                                    }
                                    IField         pField = pFields.get_Field(indexDirection);
                                    ISpatialFilter filter = new SpatialFilter();
                                    filter.Geometry    = geo;
                                    filter.SubFields   = pField.Name;
                                    filter.WhereClause = mc.ClassifyField + " =  '" + sc.Name + "'";
                                    filter.SpatialRel  = esriSpatialRelEnum.esriSpatialRelIntersects;
                                    if (fc == null || geo == null)
                                    {
                                        return;
                                    }

                                    IFeatureCursor pFeatureCursor = null;
                                    IFeature       pFeature       = null;


                                    try
                                    {
                                        pFeatureCursor = fc.Search(filter, false);
                                        esriFlowDirection flowDirection = new esriFlowDirection();
                                        while ((pFeature = pFeatureCursor.NextFeature()) != null)
                                        {
                                            object tempobj = pFeature.get_Value(indexDirection);
                                            int    dtemp;
                                            if (tempobj != null && Int32.TryParse(tempobj.ToString(), out dtemp))
                                            {
                                                switch (dtemp)
                                                {
                                                case 0:
                                                    flowDirection = esriFlowDirection.esriFDWithFlow;
                                                    break;

                                                case 1:
                                                    flowDirection = esriFlowDirection.esriFDAgainstFlow;
                                                    break;
                                                }
                                            }
                                            else
                                            {
                                                flowDirection = esriFlowDirection.esriFDIndeterminate;
                                            }
                                            IPolyline polyline    = pFeature.Shape as IPolyline;
                                            IPoint    middlePoint = new PointClass();
                                            polyline.QueryPoint(esriSegmentExtension.esriNoExtension, polyline.Length / 2, false, middlePoint);

                                            IArrowMarkerSymbol  arrowMarkerSymbol  = new ArrowMarkerSymbolClass();
                                            ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass();
                                            IElement            element            = null;
                                            if (flowDirection == esriFlowDirection.esriFDWithFlow)
                                            {
                                                arrowMarkerSymbol.Angle = GetLineAngleFrom2Points(polyline.FromPoint, polyline.ToPoint);
                                                arrowMarkerSymbol.Color = GetColorByRGBValue(0, 0, 0);
                                                arrowMarkerSymbol.Size  = 12;
                                                element          = new MarkerElementClass();
                                                element.Geometry = middlePoint;
                                                ((IMarkerElement)element).Symbol   = arrowMarkerSymbol;
                                                ((IElementProperties)element).Name = "Flow";
                                            }
                                            else if (flowDirection == esriFlowDirection.esriFDAgainstFlow)
                                            {
                                                simpleMarkerSymbol.Angle = GetLineAngleFrom2Points(polyline.ToPoint, polyline.FromPoint);
                                                arrowMarkerSymbol.Color  = GetColorByRGBValue(0, 0, 0);
                                                arrowMarkerSymbol.Size   = 12;
                                                element          = new MarkerElementClass();
                                                element.Geometry = middlePoint;
                                                ((IMarkerElement)element).Symbol   = arrowMarkerSymbol;
                                                ((IElementProperties)element).Name = "Flow";
                                            }
                                            else if (flowDirection == esriFlowDirection.esriFDIndeterminate)
                                            {
                                                simpleMarkerSymbol.Color = GetColorByRGBValue(0, 0, 0);
                                                simpleMarkerSymbol.Size  = 8;
                                                element          = new MarkerElementClass();
                                                element.Geometry = middlePoint;
                                                ((IMarkerElement)element).Symbol   = simpleMarkerSymbol;
                                                ((IElementProperties)element).Name = "Flow";
                                            }
                                            else
                                            {
                                                simpleMarkerSymbol.Color = GetColorByRGBValue(255, 0, 0);
                                                simpleMarkerSymbol.Size  = 8;
                                                element          = new MarkerElementClass();
                                                element.Geometry = middlePoint;
                                                ((IMarkerElement)element).Symbol   = simpleMarkerSymbol;
                                                ((IElementProperties)element).Name = "Flow";
                                            }
                                            gc.AddElement(element, 0);
                                        }
                                    }
                                    catch (System.Exception ex)
                                    {
                                    }
                                }
                            }
                        }
                        WaitForm.Stop();
                        app.Current2DMapControl.ActiveView.Refresh();
                    }
                }
            }
            catch (System.Exception ex)
            {
            }
        }
Ejemplo n.º 16
0
        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);
        }
 public static IMarkerSymbol DefaultFlowSymbol(bool reverse)
 {
     IArrowMarkerSymbol arrowMarkerSymbol = new ArrowMarkerSymbolClass();
     arrowMarkerSymbol.Size = 12;
     if (reverse) arrowMarkerSymbol.Angle = 180;
     return arrowMarkerSymbol;
 }
Ejemplo n.º 18
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;
            }
        }
Ejemplo n.º 19
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
        }
        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;
        }
        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;
        }
Ejemplo n.º 22
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);
                    }
                }
            }
        }
		/// <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);
		}