Exemplo n.º 1
0
        public static void FlashGeometry(ESRI.ArcGIS.Geometry.IGeometry geometry,
                                         System.Int32 delay)
        {
            var mxdoc = ArcMap.Application.Document as IMxDocument;

            if (mxdoc == null)
            {
                return;
            }

            var av       = (IActiveView)mxdoc.FocusMap;
            var display  = av.ScreenDisplay;
            var envelope = av.Extent.Envelope;

            IRgbColor color = new RgbColorClass();

            color.Green = 255;
            color.Red   = 0;
            color.Blue  = 0;

            if ((geometry == null) || (color == null) || (display == null) || (envelope == null) || (delay < 0))
            {
                return;
            }

            display.StartDrawing(display.hDC, (System.Int16)ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache); // Explicit Cast

            if (geometry.GeometryType != ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint)
            {
                return;
            }

            //Set the flash geometry's symbol.
            ESRI.ArcGIS.Display.ISimpleMarkerSymbol simpleMarkerSymbol = new ESRI.ArcGIS.Display.SimpleMarkerSymbolClass();
            simpleMarkerSymbol.Style = ESRI.ArcGIS.Display.esriSimpleMarkerStyle.esriSMSCircle;
            simpleMarkerSymbol.Size  = 12;
            simpleMarkerSymbol.Color = color;
            ESRI.ArcGIS.Display.ISymbol markerSymbol = (ESRI.ArcGIS.Display.ISymbol)simpleMarkerSymbol;
            markerSymbol.ROP2 = ESRI.ArcGIS.Display.esriRasterOpCode.esriROPNotXOrPen;

            ESRI.ArcGIS.Display.ISimpleLineSymbol simpleLineSymbol = new ESRI.ArcGIS.Display.SimpleLineSymbolClass();
            simpleLineSymbol.Width = 1;
            simpleLineSymbol.Color = color;
            ESRI.ArcGIS.Display.ISymbol lineSymbol = (ESRI.ArcGIS.Display.ISymbol)simpleLineSymbol;
            lineSymbol.ROP2 = ESRI.ArcGIS.Display.esriRasterOpCode.esriROPNotXOrPen;

            DrawCrossHair(geometry, display, envelope, markerSymbol, lineSymbol);

            //Flash the input point geometry.
            display.SetSymbol(markerSymbol);
            display.DrawPoint(geometry);
            System.Threading.Thread.Sleep(delay);
            display.DrawPoint(geometry);
            display.FinishDrawing();
        }
Exemplo n.º 2
0
        public void AddGraphic(IMap map, IGeometry geometry, IRgbColor rgbColor, IRgbColor outlineRgbColor)
        {
            if (geometry == null)
            {
                return;
            }
            IGraphicsContainer graphicsContainer = (IGraphicsContainer)map;

            ESRI.ArcGIS.Carto.IElement element = null;
            if ((geometry.GeometryType) == esriGeometryType.esriGeometryPoint)
            {
                // Marker symbols
                ESRI.ArcGIS.Display.ISimpleMarkerSymbol simpleMarkerSymbol = new ESRI.ArcGIS.Display.SimpleMarkerSymbolClass();
                simpleMarkerSymbol.Color        = rgbColor;
                simpleMarkerSymbol.Outline      = true;
                simpleMarkerSymbol.OutlineColor = outlineRgbColor;
                simpleMarkerSymbol.Size         = 15;
                simpleMarkerSymbol.Style        = ESRI.ArcGIS.Display.esriSimpleMarkerStyle.esriSMSCircle;

                ESRI.ArcGIS.Carto.IMarkerElement markerElement = new ESRI.ArcGIS.Carto.MarkerElementClass();
                markerElement.Symbol = simpleMarkerSymbol;
                element = (ESRI.ArcGIS.Carto.IElement)markerElement;
            }
            else if ((geometry.GeometryType) == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline)
            {
                //  Line elements
                ESRI.ArcGIS.Display.ISimpleLineSymbol simpleLineSymbol = new ESRI.ArcGIS.Display.SimpleLineSymbolClass();
                simpleLineSymbol.Color = rgbColor;
                simpleLineSymbol.Style = ESRI.ArcGIS.Display.esriSimpleLineStyle.esriSLSSolid;
                simpleLineSymbol.Width = 5;

                ESRI.ArcGIS.Carto.ILineElement lineElement = new ESRI.ArcGIS.Carto.LineElementClass();
                lineElement.Symbol = simpleLineSymbol;
                element            = (ESRI.ArcGIS.Carto.IElement)lineElement;
            }
            else if ((geometry.GeometryType) == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon)
            {
                // Polygon elements
                ESRI.ArcGIS.Display.ISimpleFillSymbol simpleFillSymbol = new ESRI.ArcGIS.Display.SimpleFillSymbolClass();
                simpleFillSymbol.Color = rgbColor;
                simpleFillSymbol.Style = ESRI.ArcGIS.Display.esriSimpleFillStyle.esriSFSForwardDiagonal;
                ESRI.ArcGIS.Carto.IFillShapeElement fillShapeElement = new ESRI.ArcGIS.Carto.PolygonElementClass();
                fillShapeElement.Symbol = simpleFillSymbol;
                element = (ESRI.ArcGIS.Carto.IElement)fillShapeElement;
            }
            if (!(element == null))
            {
                element.Geometry = geometry;
                graphicsContainer.AddElement(element, 0);
            }
        }
        // ArcGIS Snippet Title:
        // Create Simple Line Symbol
        //
        // Long Description:
        // Create a simple line symbol by specifying a color, width and line style.
        //
        // Add the following references to the project:
        // ESRI.ArcGIS.Display
        // ESRI.ArcGIS.System
        //
        // Intended ArcGIS Products for this snippet:
        // ArcGIS Desktop (Standard, Advanced, Basic)
        // ArcGIS Engine
        // ArcGIS Server
        //
        // Applicable ArcGIS Product Versions:
        // 9.2
        // 9.3
        // 9.3.1
        // 10.0
        //
        // Required ArcGIS Extensions:
        // (NONE)
        //
        // Notes:
        // This snippet is intended to be inserted at the base level of a Class.
        // It is not intended to be nested within an existing Method.
        //

        ///<summary>Create a simple line symbol by specifying a color, width and line style.</summary>
        ///
        ///<param name="rgbColor">An IRGBColor interface.</param>
        ///<param name="inWidth">A System.Double that is the width of the line symbol in points. Example: 2</param>
        ///<param name="inStyle">An esriSimpleLineStyle enumeration. Example: esriSLSSolid.</param>
        ///
        ///<returns>An ISimpleLineSymbol interface.</returns>
        ///
        ///<remarks></remarks>
        public ESRI.ArcGIS.Display.ISimpleLineSymbol CreateSimpleLineSymbol(ESRI.ArcGIS.Display.IRgbColor rgbColor, System.Double inWidth, ESRI.ArcGIS.Display.esriSimpleLineStyle inStyle)
        {
            if (rgbColor == null)
            {
                return(null);
            }

            ESRI.ArcGIS.Display.ISimpleLineSymbol simpleLineSymbol = new ESRI.ArcGIS.Display.SimpleLineSymbolClass();
            simpleLineSymbol.Style = inStyle;
            simpleLineSymbol.Color = rgbColor;
            simpleLineSymbol.Width = inWidth;

            return(simpleLineSymbol);
        }
        // ArcGIS Snippet Title:
        // Create Simple Fill Symbol
        //
        // Long Description:
        // Create a simple fill symbol by specifying a color, outline color and fill style.
        //
        // Add the following references to the project:
        // ESRI.ArcGIS.Display
        // ESRI.ArcGIS.System
        //
        // Intended ArcGIS Products for this snippet:
        // ArcGIS Desktop (Standard, Advanced, Basic)
        // ArcGIS Engine
        // ArcGIS Server
        //
        // Applicable ArcGIS Product Versions:
        // 9.2
        // 9.3
        // 9.3.1
        // 10.0
        //
        // Required ArcGIS Extensions:
        // (NONE)
        //
        // Notes:
        // This snippet is intended to be inserted at the base level of a Class.
        // It is not intended to be nested within an existing Method.
        //

        ///<summary>Create a simple fill symbol by specifying a color, outline color and fill style.</summary>
        ///
        ///<param name="fillColor">An IRGBColor interface. The color for the inside of the fill symbol.</param>
        ///<param name="fillStyle">An esriSimpleLineStyle enumeration for the inside fill symbol. Example: esriSFSSolid.</param>
        ///<param name="borderColor">An IRGBColor interface. The color for the outside line border of the fill symbol.</param>
        ///<param name="borderStyle">An esriSimpleLineStyle enumeration for the outside line border. Example: esriSLSSolid.</param>
        ///<param name="borderWidth">A System.Double that is the width of the outside line border in points. Example: 2</param>
        ///
        ///<returns>An ISimpleFillSymbol interface.</returns>
        ///
        ///<remarks></remarks>
        public ESRI.ArcGIS.Display.ISimpleFillSymbol CreateSimpleFillSymbol(ESRI.ArcGIS.Display.IRgbColor fillColor, ESRI.ArcGIS.Display.esriSimpleFillStyle fillStyle, ESRI.ArcGIS.Display.IRgbColor borderColor, ESRI.ArcGIS.Display.esriSimpleLineStyle borderStyle, System.Double borderWidth)
        {
            ESRI.ArcGIS.Display.ISimpleLineSymbol simpleLineSymbol = new ESRI.ArcGIS.Display.SimpleLineSymbolClass();
            simpleLineSymbol.Width = borderWidth;
            simpleLineSymbol.Color = borderColor;
            simpleLineSymbol.Style = borderStyle;

            ESRI.ArcGIS.Display.ISimpleFillSymbol simpleFillSymbol = new ESRI.ArcGIS.Display.SimpleFillSymbolClass();
            simpleFillSymbol.Outline = simpleLineSymbol;
            simpleFillSymbol.Style   = fillStyle;
            simpleFillSymbol.Color   = fillColor;

            return(simpleFillSymbol);
        }
Exemplo n.º 5
0
        public void AddGraphicToMap(ESRI.ArcGIS.Carto.IMap map, ESRI.ArcGIS.Geometry.IGeometry geometry, ESRI.ArcGIS.Display.IRgbColor rgbColor, ESRI.ArcGIS.Display.IRgbColor outlineRgbColor)
        {
            ESRI.ArcGIS.Carto.IGraphicsContainer graphicsContainer = (ESRI.ArcGIS.Carto.IGraphicsContainer)map; // Explicit Cast
            ESRI.ArcGIS.Carto.IElement element = null;
            if ((geometry.GeometryType) == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint)
            {
                // Marker symbols
                ESRI.ArcGIS.Display.ISimpleMarkerSymbol simpleMarkerSymbol = new ESRI.ArcGIS.Display.SimpleMarkerSymbolClass();
                simpleMarkerSymbol.Color = rgbColor;
                simpleMarkerSymbol.Outline = true;
                simpleMarkerSymbol.OutlineColor = outlineRgbColor;
                simpleMarkerSymbol.Size = 15;
                simpleMarkerSymbol.Style = ESRI.ArcGIS.Display.esriSimpleMarkerStyle.esriSMSCircle;

                ESRI.ArcGIS.Carto.IMarkerElement markerElement = new ESRI.ArcGIS.Carto.MarkerElementClass();
                markerElement.Symbol = simpleMarkerSymbol;
                element = (ESRI.ArcGIS.Carto.IElement)markerElement; // Explicit Cast
            }
            else if ((geometry.GeometryType) == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline)
            {
                //  Line elements
                ESRI.ArcGIS.Display.ISimpleLineSymbol simpleLineSymbol = new ESRI.ArcGIS.Display.SimpleLineSymbolClass();
                simpleLineSymbol.Color = rgbColor;
                simpleLineSymbol.Style = ESRI.ArcGIS.Display.esriSimpleLineStyle.esriSLSSolid;
                simpleLineSymbol.Width = 5;

                ESRI.ArcGIS.Carto.ILineElement lineElement = new ESRI.ArcGIS.Carto.LineElementClass();
                lineElement.Symbol = simpleLineSymbol;
                element = (ESRI.ArcGIS.Carto.IElement)lineElement; // Explicit Cast
            }
            else if ((geometry.GeometryType) == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon)
            {
                // Polygon elements
                ESRI.ArcGIS.Display.ISimpleFillSymbol simpleFillSymbol = new ESRI.ArcGIS.Display.SimpleFillSymbolClass();
                simpleFillSymbol.Color = rgbColor;
                simpleFillSymbol.Style = ESRI.ArcGIS.Display.esriSimpleFillStyle.esriSFSForwardDiagonal;
                ESRI.ArcGIS.Carto.IFillShapeElement fillShapeElement = new ESRI.ArcGIS.Carto.PolygonElementClass();
                fillShapeElement.Symbol = simpleFillSymbol;
                element = (ESRI.ArcGIS.Carto.IElement)fillShapeElement; // Explicit Cast
            }
            if (!(element == null))
            {
                element.Geometry = geometry;
                graphicsContainer.AddElement(element, 0);
            }
        }
Exemplo n.º 6
0
        ///<summary>Flash geometry on the display. The geometry type could be polygon, polyline, point, or multipoint.</summary>
        ///
        ///<param name="geometry"> An IGeometry interface</param>
        ///<param name="color">An IRgbColor interface</param>
        ///<param name="display">An IDisplay interface</param>
        ///<param name="delay">A System.Int32 that is the time im milliseconds to wait.</param>
        ///
        ///<remarks></remarks>
        public static void FlashGeometry(ESRI.ArcGIS.Geometry.IGeometry geometry, ESRI.ArcGIS.Display.IRgbColor color, ESRI.ArcGIS.Display.IDisplay display, System.Int32 delay, IEnvelope envelope)
        {
            if (geometry == null || color == null || display == null)
            {
                return;
            }

            display.StartDrawing(display.hDC, (System.Int16)ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache); // Explicit Cast

            switch (geometry.GeometryType)
            {
            case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon:
            {
                //Set the flash geometry's symbol.
                ESRI.ArcGIS.Display.ISimpleFillSymbol simpleFillSymbol = new ESRI.ArcGIS.Display.SimpleFillSymbolClass();
                simpleFillSymbol.Color = color;
                ESRI.ArcGIS.Display.ISymbol symbol = simpleFillSymbol as ESRI.ArcGIS.Display.ISymbol;         // Dynamic Cast
                symbol.ROP2 = ESRI.ArcGIS.Display.esriRasterOpCode.esriROPNotXOrPen;

                //Flash the input polygon geometry.
                display.SetSymbol(symbol);
                display.DrawPolygon(geometry);
                System.Threading.Thread.Sleep(delay);
                display.DrawPolygon(geometry);
                break;
            }

            case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline:
            {
                //Set the flash geometry's symbol.
                ESRI.ArcGIS.Display.ISimpleLineSymbol simpleLineSymbol = new ESRI.ArcGIS.Display.SimpleLineSymbolClass();
                simpleLineSymbol.Width = 4;
                simpleLineSymbol.Color = color;
                ESRI.ArcGIS.Display.ISymbol symbol = simpleLineSymbol as ESRI.ArcGIS.Display.ISymbol;         // Dynamic Cast
                symbol.ROP2 = ESRI.ArcGIS.Display.esriRasterOpCode.esriROPNotXOrPen;

                //Flash the input polyline geometry.
                display.SetSymbol(symbol);
                display.DrawPolyline(geometry);
                System.Threading.Thread.Sleep(delay);
                display.DrawPolyline(geometry);
                break;
            }

            case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint:
            {
                //Set the flash geometry's symbol.
                ESRI.ArcGIS.Display.ISimpleMarkerSymbol simpleMarkerSymbol = new ESRI.ArcGIS.Display.SimpleMarkerSymbolClass();
                simpleMarkerSymbol.Style = ESRI.ArcGIS.Display.esriSimpleMarkerStyle.esriSMSCircle;
                simpleMarkerSymbol.Size  = 12;
                simpleMarkerSymbol.Color = color;
                ESRI.ArcGIS.Display.ISymbol markerSymbol = simpleMarkerSymbol as ESRI.ArcGIS.Display.ISymbol;         // Dynamic Cast
                markerSymbol.ROP2 = ESRI.ArcGIS.Display.esriRasterOpCode.esriROPNotXOrPen;

                ESRI.ArcGIS.Display.ISimpleLineSymbol simpleLineSymbol = new ESRI.ArcGIS.Display.SimpleLineSymbolClass();
                simpleLineSymbol.Width = 1;
                simpleLineSymbol.Color = color;
                ESRI.ArcGIS.Display.ISymbol lineSymbol = simpleLineSymbol as ESRI.ArcGIS.Display.ISymbol;         // Dynamic Cast
                lineSymbol.ROP2 = ESRI.ArcGIS.Display.esriRasterOpCode.esriROPNotXOrPen;

                //Flash the input polygon geometry.
                display.SetSymbol(markerSymbol);
                display.SetSymbol(lineSymbol);

                ArcMapHelpers.DrawCrossHair(geometry, display, envelope, markerSymbol, lineSymbol);

                //Flash the input point geometry.
                display.SetSymbol(markerSymbol);
                display.DrawPoint(geometry);
                System.Threading.Thread.Sleep(delay);
                display.DrawPoint(geometry);
                break;
            }

            case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryMultipoint:
            {
                //Set the flash geometry's symbol.
                ESRI.ArcGIS.Display.ISimpleMarkerSymbol simpleMarkerSymbol = new ESRI.ArcGIS.Display.SimpleMarkerSymbolClass();
                simpleMarkerSymbol.Style = ESRI.ArcGIS.Display.esriSimpleMarkerStyle.esriSMSCircle;
                simpleMarkerSymbol.Size  = 12;
                simpleMarkerSymbol.Color = color;
                ESRI.ArcGIS.Display.ISymbol symbol = simpleMarkerSymbol as ESRI.ArcGIS.Display.ISymbol;         // Dynamic Cast
                symbol.ROP2 = ESRI.ArcGIS.Display.esriRasterOpCode.esriROPNotXOrPen;

                //Flash the input multipoint geometry.
                display.SetSymbol(symbol);
                display.DrawMultipoint(geometry);
                System.Threading.Thread.Sleep(delay);
                display.DrawMultipoint(geometry);
                break;
            }
            }

            display.FinishDrawing();
        }
Exemplo n.º 7
0
        public void FlashGeometry(ESRI.ArcGIS.Geometry.IGeometry geometry)
        {
            try
            {
                IRgbColor color = Globals.FlashFeatureColor;

                IDisplay display = (IDisplay)mDoc.ActiveView.ScreenDisplay;

                Int32 delay = Globals.FlashFeatureDelay;

                if (geometry == null || color == null || display == null)
                {
                    return;
                }
                display.StartDrawing(display.hDC, (System.Int16)ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache); // Explicit Cast

                switch (geometry.GeometryType)
                {
                case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon:
                {
                    //Set the flash geometry's symbol.
                    ESRI.ArcGIS.Display.ISimpleFillSymbol simpleFillSymbol = new ESRI.ArcGIS.Display.SimpleFillSymbolClass();
                    simpleFillSymbol.Color = color;
                    ESRI.ArcGIS.Display.ISymbol symbol = simpleFillSymbol as ESRI.ArcGIS.Display.ISymbol;         // Dynamic Cast
                    symbol.ROP2 = ESRI.ArcGIS.Display.esriRasterOpCode.esriROPNotXOrPen;
                    //Flash the input polygon geometry.
                    display.SetSymbol(symbol);
                    display.DrawPolygon(geometry);
                    System.Threading.Thread.Sleep(delay);
                    display.DrawPolygon(geometry);
                    break;
                }

                case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline:
                {
                    //Set the flash geometry's symbol.
                    ESRI.ArcGIS.Display.ISimpleLineSymbol simpleLineSymbol = new ESRI.ArcGIS.Display.SimpleLineSymbolClass();
                    simpleLineSymbol.Width = 4;
                    simpleLineSymbol.Color = color;
                    ESRI.ArcGIS.Display.ISymbol symbol = simpleLineSymbol as ESRI.ArcGIS.Display.ISymbol;         // Dynamic Cast
                    symbol.ROP2 = ESRI.ArcGIS.Display.esriRasterOpCode.esriROPNotXOrPen;
                    //Flash the input polyline geometry.
                    display.SetSymbol(symbol);
                    display.DrawPolyline(geometry);
                    System.Threading.Thread.Sleep(delay);
                    display.DrawPolyline(geometry);
                    break;
                }

                case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint:
                {
                    //Set the flash geometry's symbol.
                    ESRI.ArcGIS.Display.ISimpleMarkerSymbol simpleMarkerSymbol = new ESRI.ArcGIS.Display.SimpleMarkerSymbolClass();
                    simpleMarkerSymbol.Style = ESRI.ArcGIS.Display.esriSimpleMarkerStyle.esriSMSCircle;
                    simpleMarkerSymbol.Size  = 12;
                    simpleMarkerSymbol.Color = color;
                    ESRI.ArcGIS.Display.ISymbol symbol = simpleMarkerSymbol as ESRI.ArcGIS.Display.ISymbol;         // Dynamic Cast
                    symbol.ROP2 = ESRI.ArcGIS.Display.esriRasterOpCode.esriROPNotXOrPen;
                    //Flash the input point geometry.
                    display.SetSymbol(symbol);
                    display.DrawPoint(geometry);
                    System.Threading.Thread.Sleep(delay);
                    display.DrawPoint(geometry);
                    break;
                }

                case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryMultipoint:
                {
                    //Set the flash geometry's symbol.
                    ESRI.ArcGIS.Display.ISimpleMarkerSymbol simpleMarkerSymbol = new ESRI.ArcGIS.Display.SimpleMarkerSymbolClass();
                    simpleMarkerSymbol.Style = ESRI.ArcGIS.Display.esriSimpleMarkerStyle.esriSMSCircle;
                    simpleMarkerSymbol.Size  = 12;
                    simpleMarkerSymbol.Color = color;
                    ESRI.ArcGIS.Display.ISymbol symbol = simpleMarkerSymbol as ESRI.ArcGIS.Display.ISymbol;         // Dynamic Cast
                    symbol.ROP2 = ESRI.ArcGIS.Display.esriRasterOpCode.esriROPNotXOrPen;
                    //Flash the input multipoint geometry.
                    display.SetSymbol(symbol);
                    display.DrawMultipoint(geometry);
                    System.Threading.Thread.Sleep(delay);
                    display.DrawMultipoint(geometry);
                    break;
                }
                }
                display.FinishDrawing();
            }
            catch (Exception ex) { log.WriteError(ex, TAG, System.Security.Principal.WindowsIdentity.GetCurrent().Name, null); }
        }
    // ArcGIS Snippet Title:
    // Create Simple Line Symbol
    // 
    // Long Description:
    // Create a simple line symbol by specifying a color, width and line style.
    // 
    // Add the following references to the project:
    // ESRI.ArcGIS.Display
    // ESRI.ArcGIS.System
    // 
    // Intended ArcGIS Products for this snippet:
    // ArcGIS Desktop (Standard, Advanced, Basic)
    // ArcGIS Engine
    // ArcGIS Server
    // 
    // Applicable ArcGIS Product Versions:
    // 9.2
    // 9.3
    // 9.3.1
    // 10.0
    // 
    // Required ArcGIS Extensions:
    // (NONE)
    // 
    // Notes:
    // This snippet is intended to be inserted at the base level of a Class.
    // It is not intended to be nested within an existing Method.
    // 

    ///<summary>Create a simple line symbol by specifying a color, width and line style.</summary>
    ///  
    ///<param name="rgbColor">An IRGBColor interface.</param>
    ///<param name="inWidth">A System.Double that is the width of the line symbol in points. Example: 2</param>
    ///<param name="inStyle">An esriSimpleLineStyle enumeration. Example: esriSLSSolid.</param>
    ///   
    ///<returns>An ISimpleLineSymbol interface.</returns>
    ///  
    ///<remarks></remarks>
    public ESRI.ArcGIS.Display.ISimpleLineSymbol CreateSimpleLineSymbol(ESRI.ArcGIS.Display.IRgbColor rgbColor, System.Double inWidth, ESRI.ArcGIS.Display.esriSimpleLineStyle inStyle)
    {
      if (rgbColor == null)
      {
        return null;
      }

      ESRI.ArcGIS.Display.ISimpleLineSymbol simpleLineSymbol = new ESRI.ArcGIS.Display.SimpleLineSymbolClass();
      simpleLineSymbol.Style = inStyle;
      simpleLineSymbol.Color = rgbColor;
      simpleLineSymbol.Width = inWidth;

      return simpleLineSymbol;
    }
    // ArcGIS Snippet Title:
    // Create Simple Fill Symbol
    // 
    // Long Description:
    // Create a simple fill symbol by specifying a color, outline color and fill style.
    // 
    // Add the following references to the project:
    // ESRI.ArcGIS.Display
    // ESRI.ArcGIS.System
    // 
    // Intended ArcGIS Products for this snippet:
    // ArcGIS Desktop (Standard, Advanced, Basic)
    // ArcGIS Engine
    // ArcGIS Server
    // 
    // Applicable ArcGIS Product Versions:
    // 9.2
    // 9.3
    // 9.3.1
    // 10.0
    // 
    // Required ArcGIS Extensions:
    // (NONE)
    // 
    // Notes:
    // This snippet is intended to be inserted at the base level of a Class.
    // It is not intended to be nested within an existing Method.
    // 

    ///<summary>Create a simple fill symbol by specifying a color, outline color and fill style.</summary>
    ///  
    ///<param name="fillColor">An IRGBColor interface. The color for the inside of the fill symbol.</param>
    ///<param name="fillStyle">An esriSimpleLineStyle enumeration for the inside fill symbol. Example: esriSFSSolid.</param>
    ///<param name="borderColor">An IRGBColor interface. The color for the outside line border of the fill symbol.</param>
    ///<param name="borderStyle">An esriSimpleLineStyle enumeration for the outside line border. Example: esriSLSSolid.</param>
    ///<param name="borderWidth">A System.Double that is the width of the outside line border in points. Example: 2</param>
    ///   
    ///<returns>An ISimpleFillSymbol interface.</returns>
    ///  
    ///<remarks></remarks>
    public ESRI.ArcGIS.Display.ISimpleFillSymbol CreateSimpleFillSymbol(ESRI.ArcGIS.Display.IRgbColor fillColor, ESRI.ArcGIS.Display.esriSimpleFillStyle fillStyle, ESRI.ArcGIS.Display.IRgbColor borderColor, ESRI.ArcGIS.Display.esriSimpleLineStyle borderStyle, System.Double borderWidth)
    {

      ESRI.ArcGIS.Display.ISimpleLineSymbol simpleLineSymbol = new ESRI.ArcGIS.Display.SimpleLineSymbolClass();
      simpleLineSymbol.Width = borderWidth;
      simpleLineSymbol.Color = borderColor;
      simpleLineSymbol.Style = borderStyle;

      ESRI.ArcGIS.Display.ISimpleFillSymbol simpleFillSymbol = new ESRI.ArcGIS.Display.SimpleFillSymbolClass();
      simpleFillSymbol.Outline = simpleLineSymbol;
      simpleFillSymbol.Style = fillStyle;
      simpleFillSymbol.Color = fillColor;

      return simpleFillSymbol;
    }
        ///<summary>Flash geometry on the display. The geometry type could be polygon, polyline, point, or multipoint.</summary>
        ///
        ///<param name="geometry"> An IGeometry interface</param>
        ///<param name="color">An IRgbColor interface</param>
        ///<param name="display">An IDisplay interface</param>
        ///<param name="delay">A System.Int32 that is the time im milliseconds to wait.</param>
        /// 
        ///<remarks></remarks>
        private void FlashGeometry(ESRI.ArcGIS.Geometry.IGeometry geometry, ESRI.ArcGIS.Display.IRgbColor color, ESRI.ArcGIS.Display.IDisplay display, System.Int32 delay)
        {
            if (geometry == null || color == null || display == null)
            {
                return;
            }

            display.StartDrawing(display.hDC, (System.Int16)ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache); // Explicit Cast


            switch (geometry.GeometryType)
            {
                case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon:
                    {
                        //Set the flash geometry's symbol.
                        ESRI.ArcGIS.Display.ISimpleFillSymbol simpleFillSymbol = new ESRI.ArcGIS.Display.SimpleFillSymbolClass();
                        simpleFillSymbol.Color = color;
                        ESRI.ArcGIS.Display.ISymbol symbol = simpleFillSymbol as ESRI.ArcGIS.Display.ISymbol; // Dynamic Cast
                        symbol.ROP2 = ESRI.ArcGIS.Display.esriRasterOpCode.esriROPNotXOrPen;

                        //Flash the input polygon geometry.
                        display.SetSymbol(symbol);
                        display.DrawPolygon(geometry);
                        System.Threading.Thread.Sleep(delay);
                        display.DrawPolygon(geometry);
                        break;
                    }

                case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline:
                    {
                        //Set the flash geometry's symbol.
                        ESRI.ArcGIS.Display.ISimpleLineSymbol simpleLineSymbol = new ESRI.ArcGIS.Display.SimpleLineSymbolClass();
                        simpleLineSymbol.Width = 4;
                        simpleLineSymbol.Color = color;
                        ESRI.ArcGIS.Display.ISymbol symbol = simpleLineSymbol as ESRI.ArcGIS.Display.ISymbol; // Dynamic Cast
                        symbol.ROP2 = ESRI.ArcGIS.Display.esriRasterOpCode.esriROPNotXOrPen;

                        //Flash the input polyline geometry.
                        display.SetSymbol(symbol);
                        display.DrawPolyline(geometry);
                        System.Threading.Thread.Sleep(delay);
                        display.DrawPolyline(geometry);
                        break;
                    }

                case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint:
                    {
                        //Set the flash geometry's symbol.
                        ESRI.ArcGIS.Display.ISimpleMarkerSymbol simpleMarkerSymbol = new ESRI.ArcGIS.Display.SimpleMarkerSymbolClass();
                        simpleMarkerSymbol.Style = ESRI.ArcGIS.Display.esriSimpleMarkerStyle.esriSMSDiamond;
                        simpleMarkerSymbol.Size = 12;
                        simpleMarkerSymbol.Color = color;
                        ESRI.ArcGIS.Display.ISymbol symbol = simpleMarkerSymbol as ESRI.ArcGIS.Display.ISymbol; // Dynamic Cast
                        symbol.ROP2 = ESRI.ArcGIS.Display.esriRasterOpCode.esriROPNotXOrPen;

                        //Flash the input point geometry.
                        display.SetSymbol(symbol);
                        display.DrawPoint(geometry);
                        System.Threading.Thread.Sleep(delay);
                        display.DrawPoint(geometry);
                        break;
                    }

                case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryMultipoint:
                    {
                        //Set the flash geometry's symbol.
                        ESRI.ArcGIS.Display.ISimpleMarkerSymbol simpleMarkerSymbol = new ESRI.ArcGIS.Display.SimpleMarkerSymbolClass();
                        simpleMarkerSymbol.Style = ESRI.ArcGIS.Display.esriSimpleMarkerStyle.esriSMSCircle;
                        simpleMarkerSymbol.Size = 12;
                        simpleMarkerSymbol.Color = color;
                        ESRI.ArcGIS.Display.ISymbol symbol = simpleMarkerSymbol as ESRI.ArcGIS.Display.ISymbol; // Dynamic Cast
                        symbol.ROP2 = ESRI.ArcGIS.Display.esriRasterOpCode.esriROPNotXOrPen;

                        //Flash the input multipoint geometry.
                        display.SetSymbol(symbol);
                        display.DrawMultipoint(geometry);
                        System.Threading.Thread.Sleep(delay);
                        display.DrawMultipoint(geometry);
                        break;
                    }
            }
            display.FinishDrawing();
        }
Exemplo n.º 11
0
        ///<summary>在地图上绘制指定颜色的图形</summary>
        ///<param name="scene">地图</param>
        ///<param name="geometry">feature 的shape</param>
        ///<param name="rgbColor">颜色</param>
        ///<param name="outlineRgbColor">边框颜色</param>
        ///<param name="OffsetZs">Z偏值</param>
        ///
        ///<remarks>Calling this function will not automatically make the graphics appear in the map area. Refresh the map area after after calling this function with Methods like IActiveView.Refresh or IActiveView.PartialRefresh.</remarks>
        internal static IElement AddGraphicToScene(IScene scene, ESRI.ArcGIS.Geometry.IGeometry geometry, ESRI.ArcGIS.Display.IRgbColor rgbColor, ESRI.ArcGIS.Display.IRgbColor outlineRgbColor, double OffsetZs)
        {
            //ESRI.ArcGIS.Carto.IGraphicsContainer graphicsContainer = (ESRI.ArcGIS.Carto.IGraphicsContainer)map; //IGraphicsContainer接口能删除
            IGraphicsContainer3D graphicsContainer3D = (IGraphicsContainer3D)scene.BasicGraphicsLayer;

            ESRI.ArcGIS.Carto.IElement element = null;
            if ((geometry.GeometryType) == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint)
            {
                IPoint point = (Point)geometry;

                try
                {
                    double X = point.X;
                    double Y = point.Y;
                }
                catch
                {
                    return(null);
                }
                point = GeometryUtilities.ConstructPoint3D(point, OffsetZs);
                // Marker symbols
                ESRI.ArcGIS.Display.ISimpleMarkerSymbol simpleMarkerSymbol = new ESRI.ArcGIS.Display.SimpleMarkerSymbolClass();
                simpleMarkerSymbol.Color        = rgbColor;
                simpleMarkerSymbol.Outline      = true;
                simpleMarkerSymbol.OutlineColor = rgbColor;
                simpleMarkerSymbol.Size         = 12;
                simpleMarkerSymbol.Style        = ESRI.ArcGIS.Display.esriSimpleMarkerStyle.esriSMSCircle;

                ESRI.ArcGIS.Carto.IMarkerElement markerElement = new ESRI.ArcGIS.Carto.MarkerElementClass();
                markerElement.Symbol = simpleMarkerSymbol;
                element = (ESRI.ArcGIS.Carto.IElement)markerElement; // Explicit Cast

                if (!(element == null))
                {
                    element.Geometry = point;

                    graphicsContainer3D.AddElement(element);
                }
            }
            else if ((geometry.GeometryType) == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline)
            {
                // Marker symbols
                ESRI.ArcGIS.Display.ISimpleLineSymbol simpleLineSymbol = new ESRI.ArcGIS.Display.SimpleLineSymbolClass();
                simpleLineSymbol.Color = rgbColor;
                simpleLineSymbol.Style = ESRI.ArcGIS.Display.esriSimpleLineStyle.esriSLSSolid;
                simpleLineSymbol.Width = 1;

                ESRI.ArcGIS.Carto.ILineElement lineElement = new ESRI.ArcGIS.Carto.LineElementClass();
                lineElement.Symbol = simpleLineSymbol;
                element            = (ESRI.ArcGIS.Carto.IElement)lineElement; // Explicit Cast

                if (!(element == null))
                {
                    element.Geometry = geometry;
                    graphicsContainer3D.AddElement(element);
                }
            }
            else if ((geometry.GeometryType) == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon)
            {
                IZ iz = (IZ)geometry;
                iz.OffsetZs(OffsetZs);//z值向上偏移

                // Polygon elements
                ESRI.ArcGIS.Display.ISimpleFillSymbol simpleFillSymbol = new ESRI.ArcGIS.Display.SimpleFillSymbolClass();
                simpleFillSymbol.Color = rgbColor;
                simpleFillSymbol.Style = ESRI.ArcGIS.Display.esriSimpleFillStyle.esriSFSForwardDiagonal;
                ESRI.ArcGIS.Carto.IFillShapeElement fillShapeElement = new ESRI.ArcGIS.Carto.PolygonElementClass();
                fillShapeElement.Symbol = simpleFillSymbol;
                element = (ESRI.ArcGIS.Carto.IElement)fillShapeElement; // Explicit Cast

                if (!(element == null))
                {
                    element.Geometry = geometry;
                    graphicsContainer3D.AddElement(element);
                }
            }



            return(element);
        }