Пример #1
0
        public ESRI.ArcGIS.Geometry.IEnvelope DrawRectangle(ESRI.ArcGIS.Carto.IActiveView activeView)
        {
            if (activeView == null)
            {
                return(null);
            }
            else
            {
                ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = activeView.ScreenDisplay;

                // Constant
                screenDisplay.StartDrawing(screenDisplay.hDC, (System.Int16)ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache); // Explicit Cast
                //ESRI.ArcGIS.Display.IRgbColor rgbColor = new ESRI.ArcGIS.Display.RgbColorClass();
                //rgbColor.Red = 255;

                //ESRI.ArcGIS.Display.IColor color = rgbColor; // Implicit Cast
                ESRI.ArcGIS.Display.ISimpleFillSymbol simpleFillSymbol = new ESRI.ArcGIS.Display.SimpleFillSymbolClass();
                //simpleFillSymbol.Color = color;
                simpleFillSymbol.Style = esriSimpleFillStyle.esriSFSHollow;

                ESRI.ArcGIS.Display.ISymbol     symbol     = simpleFillSymbol as ESRI.ArcGIS.Display.ISymbol; // Dynamic Cast
                ESRI.ArcGIS.Display.IRubberBand rubberBand = new ESRI.ArcGIS.Display.RubberEnvelopeClass();
                ESRI.ArcGIS.Geometry.IGeometry  geometry   = rubberBand.TrackNew(screenDisplay, symbol);
                screenDisplay.SetSymbol(symbol);
                ESRI.ArcGIS.Geometry.IEnvelope pEnvelope = geometry as ESRI.ArcGIS.Geometry.IEnvelope;
                screenDisplay.DrawRectangle(pEnvelope); // Dynamic Cast
                screenDisplay.FinishDrawing();

                return(pEnvelope);
            }
        }
Пример #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 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);
        }
Пример #4
0
        public void AddGraphicToMap(IActiveView view, IGeometry geometry, IRgbColor rgbColor, IRgbColor outlineRgbColor, int width)
        {
            IGraphicsContainer graphicsContainer = (IGraphicsContainer)view; // Explicit Cast
            IElement           element           = null;

            if ((geometry.GeometryType) == esriGeometryType.esriGeometryPoint)
            {
                // Marker symbols
                ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass();
                simpleMarkerSymbol.Color        = rgbColor;
                simpleMarkerSymbol.Outline      = true;
                simpleMarkerSymbol.OutlineColor = outlineRgbColor;
                simpleMarkerSymbol.Size         = width * 3;
                simpleMarkerSymbol.Style        = ESRI.ArcGIS.Display.esriSimpleMarkerStyle.esriSMSCircle;

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

                ILineElement lineElement = new LineElementClass();
                lineElement.Symbol = simpleLineSymbol;
                element            = (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);
                view.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
            }
        }
Пример #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);
            }
        }
Пример #6
0
        public void DrawPolygon(ESRI.ArcGIS.Carto.IActiveView activeView)
        {
            if (activeView == null)
            {
                return;
            }

            ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = activeView.ScreenDisplay;
            screenDisplay.StartDrawing(screenDisplay.hDC, (System.Int16)ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache); // Explicit Cast
            ESRI.ArcGIS.Display.IRgbColor rgbColor = new ESRI.ArcGIS.Display.RgbColorClass();
            rgbColor.Red = 255;

            ESRI.ArcGIS.Display.IColor            color            = rgbColor; // Implicit Cast
            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
            ESRI.ArcGIS.Display.IRubberBand rubberBand = new ESRI.ArcGIS.Display.RubberPolygonClass();
            ESRI.ArcGIS.Geometry.IGeometry  geometry   = rubberBand.TrackNew(screenDisplay, symbol);
            screenDisplay.SetSymbol(symbol);
            screenDisplay.DrawPolygon(geometry);
            screenDisplay.FinishDrawing();
        }
Пример #7
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();
        }
Пример #8
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 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();
        }
        private void DrawLegend(IEnvelope Envelope)
        {
            // BOX DIMENSIONS AND UNIFORM SYMBOL ITEMS
            double BoxX = 0.4; //Width
            double BoxY = 0.3; //Height
            double Text2BoxY= 0.2; //Y distance between the bottom of text and the next box
            double Text2BoxX = 0.1; //X distance between a box and the text that describes it
            double ColumnX = 0.5; //Space between columns

            // Setup a black color object, black outline
            IRgbColor BlackInsides = new ESRI.ArcGIS.Display.RgbColorClass();
            BlackInsides.Blue = 0;
            BlackInsides.Red = 0;
            BlackInsides.Green = 0;

            ILineSymbol BlackOutsides = new SimpleLineSymbolClass();
            BlackOutsides.Width = 1;
            BlackOutsides.Color = BlackInsides;

            // Whole bunch of variables to use while going through the loop below...
            #region Variables Galore!!!
            IMxDocument Doc = ArcMap.Document;
            IPageLayout pageLayout = Doc.ActiveView as IPageLayout;
            IGraphicsContainer GraphicsContainer = pageLayout as IGraphicsContainer;
            double Xcoord, Ycoord;
            Xcoord = Envelope.XMin;
            Ycoord = Envelope.YMax;
            double IndentTerm = 0;
            IPoint Point = null;
            double StringLength = 0;
            string LegendText = "";
            string ItemName = "";
            string ItemDesc = "";
            IElement Ele = null;
            IEnvelope TempEnv = null;
            IRgbColor BoxColr = null;
            ISimpleFillSymbol FillSym = new ESRI.ArcGIS.Display.SimpleFillSymbolClass();
            IFillShapeElement FillEle = null;
            IEnvelope FillEnv = new EnvelopeClass();
            WKSEnvelope Patch = new WKSEnvelope();
            IGeometry Geo = null;
            string LabelText = "";
            ESRI.ArcGIS.Geometry.IPoint LabelPoint = new ESRI.ArcGIS.Geometry.PointClass();
            #endregion

            // Get a reference to the DescriptionOfMapUnits entries
            var sortedDmuEntries = GetDmuSortedByHierarchy();

            // Loop through legend records
            foreach (KeyValuePair<string, DescriptionOfMapUnitsAccess.DescriptionOfMapUnit> aDictionaryEntry in sortedDmuEntries)
            {
                // Grab the DMU entry itself
                DescriptionOfMapUnitsAccess.DescriptionOfMapUnit aDescription = aDictionaryEntry.Value;
                bool isHeading = (aDescription.ParagraphStyle.Contains("Heading"));

                // Find out how far to indent the legend item
                // Strip periods from the HierarchyKey, divide by 4, which is the length of a segment of the key
                IndentTerm = aDescription.HierarchyKey.Replace(".", "").Length / 4;

                // Get the coordinates of the text for the legend entry - upper left corner
                // Xcoord starts at Envelope.XMin, Ycoord is Envelope.YMax: Upper left corner
                Point = new PointClass();
                double xAdditions = 0;
                if (isHeading)
                {
                    // Xcoord plus (indentation), Ycoord
                    xAdditions = 0.2 * (IndentTerm - 1);
                }
                else
                {
                    //Xcoord plus (indentation) + (Box width and margin), Ycoord
                    xAdditions = 0.2 * (IndentTerm - 1) + BoxX + Text2BoxX;
                }
                Point.PutCoords(Xcoord + xAdditions, Ycoord);

                // StringLength is the width remaining in the envelope in which the text has to fit IN PIXELS.
                StringLength = 72 * (Envelope.Width - xAdditions);

                // Fix a couple of special characters in the legend string.
                // Then amalgamate item name and description
                ItemName = FixLegendTextCharacters(aDescription.Name);
                if (!isHeading)
                {
                    LegendText = ItemName + " - " + FixLegendTextCharacters(aDescription.Description);
                }
                else
                {
                    LegendText = ItemName;
                }

                // Format the legend text if it is not a heading. If it is, we're fine.
                if (!isHeading)
                {
                    LegendText = GetFormattedString(LegendText, "Arial", 8, StringLength, 8);
                }

                // Boldify the ItemName
                LegendText = LegendText.Replace(ItemName, "<bol>" + ItemName + "</bol>");

                // See if this legend item should be placed on a new column
                Ele = MakeTextElement(Point, LegendText, "Arial") as IElement;
                TempEnv = new EnvelopeClass();
                Ele.QueryBounds(Doc.ActiveView.ScreenDisplay, TempEnv);

                // If the height of the formatted text is larger than the box + space specified
                if (TempEnv.Height > BoxY + Text2BoxY)
                {
                    // If the text will spill out below the envelope drawn by the user
                    if (Ycoord - TempEnv.Height < Envelope.YMin)
                    {
                        // Move to a new column - the last number is a fudge factor, looks like it is in inches
                        Xcoord = Xcoord + BoxX + Text2BoxX + StringLength / 72 + ColumnX;
                        // Move to the top
                        Ycoord = Envelope.YMax;
                        // Recreate the text element
                        Point.PutCoords(Xcoord + 0.2 * (IndentTerm - 1) + BoxX + Text2BoxX, Ycoord);
                        Ele = MakeTextElement(Point, LegendText, "Arial") as IElement;
                    }
                }
                else // The height of the formatted text is not larfer than the box + space defined
                {
                    // If the box itself will spill out below the envelope drawn by the user
                    if (Ycoord - (BoxY + Text2BoxY) < Envelope.YMin)
                    {
                        // Move to a new column
                        Xcoord = Xcoord + BoxX + Text2BoxX + StringLength / 72 + ColumnX;
                        // Move to the top
                        Ycoord = Envelope.YMax;
                        // Recreate the text element
                        Point.PutCoords(Xcoord + 0.2 * (IndentTerm - 1) + BoxX + Text2BoxX, Ycoord);
                        Ele = MakeTextElement(Point, LegendText, "Arial") as IElement;
                    }
                }

                // Add the text to the map
                GraphicsContainer.AddElement(Ele, 0);

                if (!isHeading)
                {
                    FillEnv = new EnvelopeClass();

                    Patch.XMin = Point.X - BoxX - Text2BoxX;
                    Patch.YMax =  Point.Y;
                    Patch.XMax = Point.X - Text2BoxX;
                    Patch.YMin = Point.Y - BoxY;
                    FillEnv.PutCoords(Patch.XMin, Patch.YMin, Patch.XMax, Patch.YMax);
                    Geo = FillEnv as IGeometry;

                    // Get the color of the box
                    BoxColr = new RgbColorClass();
                    if (aDescription.AreaFillRGB == null)
                    {
                        BoxColr.Red = 255;
                        BoxColr.Green = 0;
                        BoxColr.Blue = 0;
                    }
                    else
                    {
                        BoxColr.Red = int.Parse(aDescription.AreaFillRGB.Split(';')[0]);
                        BoxColr.Green = int.Parse(aDescription.AreaFillRGB.Split(';')[1]);
                        BoxColr.Blue = int.Parse(aDescription.AreaFillRGB.Split(';')[2]);
                    }

                    // Draw the fill
                    FillSym = new SimpleFillSymbolClass();
                    FillSym.Color = BoxColr;
                    FillSym.Style = esriSimpleFillStyle.esriSFSSolid;
                    FillSym.Outline = BlackOutsides;

                    FillEle = CreateFillElement(Geo, FillSym) as IFillShapeElement;

                    // Label the box
                    LabelText = aDescription.Label;

                    // Subscripting!!

                    for (int i = 0; i < LabelText.Length; i++)
                    {
                        string thisBit = LabelText.Substring(i, 1);
                        int num;
                        if (int.TryParse(thisBit, out num)) // Checks if the character is numeric
                        {
                            LabelText = LabelText.Replace(thisBit, "<sub>" + thisBit + "</sub>");
                            i = i + 5;
                        }
                    }
                    LabelText = LabelText.Replace("ir", "i<sub>r</sub>");
                    LabelText = LabelText.Replace("yc", "y<sub>c</sub>");

                    // Center the label
                    LabelPoint = new PointClass();
                    LabelPoint.X = Point.X - BoxX / 2 - Text2BoxX;
                    LabelPoint.Y = Point.Y - BoxY / 2;

                    //LabelText = GetFormattedString(LabelText, "FGDCGeoAge", 8, StringLength, 0);
                    Ele = MakeTextElement(LabelPoint, LabelText, "FGDCGeoAge", true) as IElement;

                    // Add the box and label
                    GraphicsContainer.AddElement(FillEle as IElement, 0);
                    GraphicsContainer.AddElement(Ele, 0);
                }

                // Do a partial refresh
                //Doc.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

                // Setup the Y coordinates for the next entry
                // if the height of this item's text is bigger than the minimum distance between text and box
                if (TempEnv.Height > Text2BoxY)
                {
                    // Subtract the box height and the text height to get the new ycoord
                    Ycoord = Ycoord - (TempEnv.Height + Text2BoxY);
                }
                else
                {
                    if (isHeading)
                    {
                        Ycoord = Ycoord - (TempEnv.Height + Text2BoxY);
                    }
                    else
                    {
                        Ycoord = Ycoord - (BoxY + Text2BoxY);
                    }
                }
            }

            // Done, refresh, turn off the tool
            Doc.ActiveView.Refresh();
            ArcMap.Application.CurrentTool = null;
        }
        private static void DrawMapUnits(IEnvelope Envelope, bool showText, double ColumnX)
        {
            // BOX DIMENSIONS AND UNIFORM SYMBOL ITEMS
            double Text2BoxY = 0.2; //Y distance between the bottom of text and the next box
            double Text2BoxX = 0.1; //X distance between a box and the text that describes it
            double BoxX      = 0.4; //Width
            double BoxY      = 0.3; //Height

            // Setup a black color object, black outline
            IRgbColor BlackInsides = new ESRI.ArcGIS.Display.RgbColorClass();

            BlackInsides.Blue  = 0;
            BlackInsides.Red   = 0;
            BlackInsides.Green = 0;

            ILineSymbol BlackOutsides = new SimpleLineSymbolClass();

            BlackOutsides.Width = 1;
            BlackOutsides.Color = BlackInsides;

            // Whole bunch of variables to use while going through the loop below...
            #region Variables Galore!!!
            IMxDocument        Doc = ArcMap.Document;
            IPageLayout        pageLayout = Doc.ActiveView as IPageLayout;
            IGraphicsContainer GraphicsContainer = pageLayout as IGraphicsContainer;
            double             Xcoord, Ycoord;
            Xcoord = Envelope.XMin;
            Ycoord = Envelope.YMax;
            double                      IndentTerm   = 0;
            IPoint                      Point        = null;
            double                      StringLength = 0;
            string                      LegendText   = "";
            string                      ItemName     = "";
            string                      ItemDesc     = "";
            IElement                    Ele          = null;
            IEnvelope                   TempEnv      = null;
            IRgbColor                   BoxColr      = null;
            ISimpleFillSymbol           FillSym      = new ESRI.ArcGIS.Display.SimpleFillSymbolClass();
            IFillShapeElement           FillEle      = null;
            IEnvelope                   FillEnv      = new EnvelopeClass();
            WKSEnvelope                 Patch        = new WKSEnvelope();
            IGeometry                   Geo          = null;
            string                      LabelText    = "";
            ESRI.ArcGIS.Geometry.IPoint LabelPoint   = new ESRI.ArcGIS.Geometry.PointClass();

            // Get the transparency of the MapUnitPolys Layer
            double transparency = 100;
            try
            {
                IFeatureLayer polyLayer    = commonFunctions.FindFeatureLayer(ArcMap.Editor.EditWorkspace, "MapUnitPolys");
                ILayerEffects layerEffects = polyLayer as ILayerEffects;
                transparency = layerEffects.Transparency;
            }
            catch { }

            #endregion

            // Get a reference to the DescriptionOfMapUnits entries
            var sortedDmuEntries = GetDmuSortedByHierarchy();

            // Loop through legend records
            foreach (KeyValuePair <string, DescriptionOfMapUnitsAccess.DescriptionOfMapUnit> aDictionaryEntry in sortedDmuEntries)
            {
                // Grab the DMU entry itself
                DescriptionOfMapUnitsAccess.DescriptionOfMapUnit aDescription = aDictionaryEntry.Value;
                bool isHeading = (aDescription.ParagraphStyle.Contains("Heading"));


                // Find out how far to indent the legend item
                // Strip periods from the HierarchyKey, divide by 4, which is the length of a segment of the key
                IndentTerm = aDescription.HierarchyKey.Replace(".", "").Length / 4;

                // Get the coordinates of the text for the legend entry - upper left corner
                // Xcoord starts at Envelope.XMin, Ycoord is Envelope.YMax: Upper left corner
                Point = new PointClass();
                double xAdditions = 0;
                if (isHeading)
                {
                    // Xcoord plus (indentation), Ycoord
                    xAdditions = 0.2 * (IndentTerm - 1);
                }
                else
                {
                    //Xcoord plus (indentation) + (Box width and margin), Ycoord
                    xAdditions = 0.2 * (IndentTerm - 1) + BoxX + Text2BoxX;
                }
                Point.PutCoords(Xcoord + xAdditions, Ycoord);

                // StringLength is the width remaining in the envelope in which the text has to fit IN PIXELS.
                StringLength = 72 * (Envelope.Width - xAdditions);

                // Fix a couple of special characters in the legend string.
                // Then amalgamate item name and description
                ItemName = FixLegendTextCharacters(aDescription.Name);
                if (!isHeading)
                {
                    LegendText = ItemName + " - " + FixLegendTextCharacters(aDescription.Description);
                }
                else
                {
                    LegendText = ItemName;
                }



                // Format the legend text if it is not a heading. If it is, we're fine.
                if (!isHeading)
                {
                    LegendText = GetFormattedString(LegendText, "Arial", 8, StringLength, 8);
                }

                // Boldify the ItemName
                LegendText = LegendText.Replace(ItemName, "<bol>" + ItemName + "</bol>");

                // If the StratCorDiagram is being drawn
                if (showText == false)
                {
                    LegendText   = ".";     // placeholder
                    StringLength = 1;
                }

                // See if this legend item should be placed on a new column
                Ele = MakeTextElement(Point, LegendText, "Arial") as IElement;

                TempEnv = new EnvelopeClass();
                Ele.QueryBounds(Doc.ActiveView.ScreenDisplay, TempEnv);

                // If the height of the formatted text is larger than the box + space specified
                if (TempEnv.Height > BoxY + Text2BoxY)
                {
                    // If the text will spill out below the envelope drawn by the user
                    if (Ycoord - TempEnv.Height < Envelope.YMin)
                    {
                        // Move to a new column - the last number is a fudge factor, looks like it is in inches
                        Xcoord = Xcoord + BoxX + Text2BoxX + StringLength / 72 + ColumnX;
                        // Move to the top
                        Ycoord = Envelope.YMax;
                        // Recreate the text element
                        Point.PutCoords(Xcoord + 0.2 * (IndentTerm - 1) + BoxX + Text2BoxX, Ycoord);
                        Ele = MakeTextElement(Point, LegendText, "Arial") as IElement;
                    }
                }
                else     // The height of the formatted text is not larger than the box + space defined
                {
                    // If the box itself will spill out below the envelope drawn by the user
                    if (Ycoord - (BoxY + Text2BoxY) < Envelope.YMin)
                    {
                        // Move to a new column
                        Xcoord = Xcoord + BoxX + Text2BoxX + StringLength / 72 + ColumnX;
                        // Move to the top
                        Ycoord = Envelope.YMax;
                        // Recreate the text element
                        Point.PutCoords(Xcoord + 0.2 * (IndentTerm - 1) + BoxX + Text2BoxX, Ycoord);
                        Ele = MakeTextElement(Point, LegendText, "Arial") as IElement;
                    }
                }

                // Only write the legend text if the legend is being drawn (not the StratCorDiagram)
                if (showText == true)
                {
                    GraphicsContainer.AddElement(Ele, 0);
                }

                if (!isHeading)
                {
                    FillEnv = new EnvelopeClass();

                    Patch.XMin = Point.X - BoxX - Text2BoxX;
                    Patch.YMax = Point.Y;
                    Patch.XMax = Point.X - Text2BoxX;
                    Patch.YMin = Point.Y - BoxY;
                    FillEnv.PutCoords(Patch.XMin, Patch.YMin, Patch.XMax, Patch.YMax);
                    Geo = FillEnv as IGeometry;

                    // Get the color of the box
                    BoxColr = new RgbColorClass();
                    if (aDescription.AreaFillRGB == null)
                    {
                        BoxColr.Red   = 255;
                        BoxColr.Green = 0;
                        BoxColr.Blue  = 0;
                    }
                    else
                    {
                        BoxColr.Red   = int.Parse(aDescription.AreaFillRGB.Split(';')[0]);
                        BoxColr.Green = int.Parse(aDescription.AreaFillRGB.Split(';')[1]);
                        BoxColr.Blue  = int.Parse(aDescription.AreaFillRGB.Split(';')[2]);
                    }

                    // Set the transparency for the legend color boxes
                    BoxColr.Red   = (int)((255 - BoxColr.Red) * transparency / 100 + BoxColr.Red);
                    BoxColr.Green = (int)((255 - BoxColr.Green) * transparency / 100 + BoxColr.Green);
                    BoxColr.Blue  = (int)((255 - BoxColr.Blue) * transparency / 100 + BoxColr.Blue);

                    // Draw the fill
                    FillSym         = new SimpleFillSymbolClass();
                    FillSym.Color   = BoxColr;
                    FillSym.Style   = esriSimpleFillStyle.esriSFSSolid;
                    FillSym.Outline = BlackOutsides;

                    FillEle = CreateFillElement(Geo, FillSym) as IFillShapeElement;

                    // Label the box
                    LabelText = aDescription.Label;

                    // Subscripting!!

                    for (int i = 0; i < LabelText.Length; i++)
                    {
                        string thisBit = LabelText.Substring(i, 1);
                        int    num;
                        if (int.TryParse(thisBit, out num)) // Checks if the character is numeric
                        {
                            LabelText = LabelText.Replace(thisBit, "<sub>" + thisBit + "</sub>");
                            i         = i + 5;
                        }
                    }
                    LabelText = LabelText.Replace("ir", "i<sub>r</sub>");
                    LabelText = LabelText.Replace("yc", "y<sub>c</sub>");

                    // Center the label
                    LabelPoint   = new PointClass();
                    LabelPoint.X = Point.X - BoxX / 2 - Text2BoxX;
                    LabelPoint.Y = Point.Y - BoxY / 2;

                    //LabelText = GetFormattedString(LabelText, "FGDCGeoAge", 8, StringLength, 0);
                    Ele = MakeTextElement(LabelPoint, LabelText, "FGDCGeoAge", true) as IElement;

                    // Add the box and label
                    IGroupElement3 group = new GroupElementClass();
                    group.AddElement(FillEle as IElement);
                    group.AddElement(Ele);
                    GraphicsContainer.AddElement(group as IElement, 0);
                }

                // Do a partial refresh
                //Doc.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

                // Setup the Y coordinates for the next entry
                // if the height of this item's text is bigger than the minimum distance between text and box
                if (TempEnv.Height > Text2BoxY)
                {
                    // Subtract the box height and the text height to get the new ycoord
                    Ycoord = Ycoord - (TempEnv.Height + Text2BoxY);
                }
                else
                {
                    if (isHeading)
                    {
                        Ycoord = Ycoord - (TempEnv.Height + Text2BoxY);
                    }
                    else
                    {
                        Ycoord = Ycoord - (BoxY + Text2BoxY);
                    }
                }
            }

            // Done, refresh, turn off the tool
            Doc.ActiveView.Refresh();
            ArcMap.Application.CurrentTool = null;
        }
Пример #13
0
        private void _drawPolygon()
        {
            if (this._axMapCtrl.ActiveView == null)
            {
                return;
            }

            ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = this._axMapCtrl.ActiveView.ScreenDisplay;

            // Constant.
            screenDisplay.StartDrawing(screenDisplay.hDC, (System.Int16)
                ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache); // Explicit cast.
            ESRI.ArcGIS.Display.IRgbColor rgbColor = new ESRI.ArcGIS.Display.RgbColorClass();
            rgbColor.Red = 255;

            ESRI.ArcGIS.Display.IColor color = rgbColor; // Implicit cast.
            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.
            ESRI.ArcGIS.Display.IRubberBand rubberBand = new
                ESRI.ArcGIS.Display.RubberPolygonClass();
            ESRI.ArcGIS.Geometry.IGeometry geometry = rubberBand.TrackNew(screenDisplay,
                symbol);
            screenDisplay.SetSymbol(symbol);

            //screenDisplay.DrawPolygon(geometry);
            screenDisplay.FinishDrawing();
            
            PolygonElementClass element = new PolygonElementClass();
            element.Geometry = geometry;
            // Create lineSymbol
            ISimpleLineSymbol lineSymbol = new SimpleLineSymbolClass();
            // set color & style,....
            ESRI.ArcGIS.Display.IRgbColor lineColor = new ESRI.ArcGIS.Display.RgbColorClass();
            lineColor.Red = 255;
            lineSymbol.Color = lineColor;
            lineSymbol.Width = 3;

            // Create fillSymbol
            ISimpleFillSymbol fillSymbol = new SimpleFillSymbolClass();
            fillSymbol.Outline = lineSymbol;
            ESRI.ArcGIS.Display.IRgbColor fillColor = new ESRI.ArcGIS.Display.RgbColorClass();
            fillColor.Red = 255;
            fillColor.Green = 255;
            fillSymbol.Color = fillColor;
            fillSymbol.Style = esriSimpleFillStyle.esriSFSHollow;
            element.Symbol = fillSymbol;

            this._axMapCtrl.ActiveView.GraphicsContainer.AddElement(element, 0);
            
            //((IGraphicsContainerSelect)(this._axMapCtrl.ActiveView.GraphicsContainer)).SelectElement(element);
            this._axMapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

            if (this._polygonName != "")
            {
                element.Name = this._polygonName;
                this._polygonName = "";
            }
            /*
            else
            {
                int count = 0;
                IGraphicsContainer container = this._axMapCtrl.ActiveView.GraphicsContainer;
                container.Reset();
                while (container.Next() != null)
                {
                    count++;
                }
                element.Name = "Element " + count;
            }
            */
            if (PolygonDrawn != null)
            {
                PolygonDrawn(element.Name);
            }
        }
Пример #14
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);
        }
Пример #15
0
 private void btnZoomTo_Click(object sender, EventArgs e)
 {
     System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;
     lblWarning.Text = "";
     IQueryFilter pQF = new QueryFilterClass();
     var query = from Parcel parcel in arylistParcelAdd
                 where parcel.StNum == tbStNum.Text.ToUpper() && parcel.StName == tbStNa.Text.ToUpper()
                 select parcel.FID;
     string strZoomWhereClause = "";
     var enumerator = query.GetEnumerator();
     enumerator.MoveNext();
     lblWarning.Text = (query.Count()).ToString() + " parcel is found";
     if (query.Count() == 1)
     {
         strZoomWhereClause = "FID_M='" + enumerator.Current + "'";
         pQF.WhereClause = strZoomWhereClause;
         IFeatureCursor pFC = featureClassParcels.Search(pQF, true);
         IFeature pFea = pFC.NextFeature();
         IEnvelope pEnv = pFea.Shape.Envelope;
         pEnv.Expand(1.2, 1.2, true);
         m_MapControl.ActiveView.Extent = pEnv;
         IGeometry geometry = pFea.Shape as IGeometry;
         ISimpleFillSymbol pSFS = new ESRI.ArcGIS.Display.SimpleFillSymbolClass();
         IRgbColor myColor = new RgbColorClass();
         myColor.RGB = ColorTranslator.ToWin32(Color.SkyBlue);
         pSFS.Color = myColor;
         //outline width 20?
         pSFS.Outline.Width = 20;
         pSFS.Outline.Color = myColor;
         pSFS.Style = esriSimpleFillStyle.esriSFSForwardDiagonal;
         IFillShapeElement pFSE = new PolygonElementClass();
         pFSE.Symbol = pSFS;
         pEE = (IElement)pFSE;
         pEE.Geometry = geometry;
         m_MapControl.ActiveView.GraphicsContainer.DeleteAllElements();
         m_MapControlbase.ActiveView.GraphicsContainer.DeleteAllElements();
         m_MapControltop.ActiveView.GraphicsContainer.DeleteAllElements();
         m_MapControl.ActiveView.GraphicsContainer.AddElement(pEE, 0);
         m_MapControlbase.ActiveView.GraphicsContainer.AddElement(pEE, 0);
         m_MapControltop.ActiveView.GraphicsContainer.AddElement(pEE, 0);
         //IMapFrame MF1 = this.axPageLayoutControl1.FindElementByName("MapTop", 1) as IMapFrame;
         //IActiveView acttt = MF1.Map as IActiveView;
         //acttt.GraphicsContainer.AddElement(pEE, 0);
         //acttt.Refresh();
         //? try to remove refresh
         //?try partialrefresh and geometry
         m_MapControl.ActiveView.Refresh();
     }
     //multiple parcels share parcel information, Haven't test it yet???
     else if (query.Count() > 1)
     {
         foreach (string strFID in query)
         {
             strZoomWhereClause += "FID_M='" + strFID + "' OR ";
             pQF.WhereClause = strZoomWhereClause;
         }
         //absolutely wrong here 1. not eliminate the" OR " in the end. 2. why assign whereclause twice??
         pQF.WhereClause = strZoomWhereClause;
         IFeatureCursor pFC = featureClassParcels.Search(pQF, true);
         IEnvelope pEnv = new EnvelopeClass();
         IEnvelope pEnv2 = new EnvelopeClass();
         IGeometry pShp;
         IFeature pFea = pFC.NextFeature();
         //not necessary at all???
         IFeature m_Fea = pFea;
         while (!(pFea == null))
         {
             pShp = pFea.Shape;
             pEnv2 = pShp.Envelope;
             pEnv.Union(pEnv2);
             pFea = pFC.NextFeature();
         }
         pEnv.Expand(1.2, 1.2, true);
         //??add selected parcels into graphicscontainer
         m_MapControl.ActiveView.Extent = pEnv;
         m_MapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
     }
     System.Windows.Forms.Cursor.Current = Cursors.Default;
 }
Пример #16
0
        private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            if(pFlag==1)//缓冲区空间查询
               {
               IActiveView pActView = axMapControl1.Map as IActiveView;

               IPoint pPoint = pActView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);

               ITopologicalOperator pTopo = pPoint as ITopologicalOperator;

               IGeometry pGeo = pTopo.Buffer(500);

               ESRI.ArcGIS.Display.IRgbColor rgbColor = new ESRI.ArcGIS.Display.RgbColorClass();
               rgbColor.Red = 255;

               ESRI.ArcGIS.Display.IColor color = rgbColor; // Implicit Cast
               ESRI.ArcGIS.Display.ISimpleFillSymbol simpleFillSymbol = new ESRI.ArcGIS.Display.SimpleFillSymbolClass();
               simpleFillSymbol.Color = color;

               ESRI.ArcGIS.Display.ISymbol symbol = simpleFillSymbol as ESRI.ArcGIS.Display.ISymbol;

               pActView.ScreenDisplay.SetSymbol(symbol);

               pActView.ScreenDisplay.DrawPolygon(pGeo);

               axMapControl1.Map.SelectByShape(pGeo, null, false);

               axMapControl1.FlashShape(pGeo, 1000, 2, symbol);

               axMapControl1.ActiveView.Refresh();
               }
               if (pFlag == 2)
               {
               pNetMap = axMapControl1.Map;

               pGC = pNetMap as IGraphicsContainer;

               IActiveView pActView = pNetMap as IActiveView;

               IPoint pPoint = pActView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);

               object o = Type.Missing;
               object o1 = Type.Missing;

               pPointC.AddPoint(pPoint, ref o, ref o1);

               IElement Element;

               ITextElement Textelement = new TextElementClass();

               Element = Textelement as IElement;

               pClickedCount++;

               Textelement.Text = pClickedCount.ToString();

               Element.Geometry = pActView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);

               pGC.AddElement(Element, 0);

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

               IFeatureClass pFeatureClass = pNaContext.NAClasses.get_ItemByName("Stops") as IFeatureClass;

               NASolve(pNaContext, pFeatureClass, pPointC, 5000);

               IGPMessages gpMessages = new GPMessagesClass();

               bool pBool = pNASolveClass.Solve(pNaContext, gpMessages, null);

               }

               if (pFlag == 3)//有向网络
               {
               IWorkspace pWs = GetMDBWorkspace(@".\data\Geometric.mdb");

               IFeatureWorkspace pFtWs = pWs as IFeatureWorkspace;

               IFeatureDataset pFtDataset = pFtWs.OpenFeatureDataset("work");

               double s = 0;

               IPolyline pPolyline = new PolylineClass();

               SolvePath(axMapControl1.Map, GetGeometricNetwork(pFtDataset, "TestGeometric"), "Weight", pPointC, 1000, ref pPolyline, ref s);

               IRgbColor pColor = new RgbColorClass();
               pColor.Red = 255;
               IElement pElement = new LineElementClass();
               ILineSymbol linesymbol = new SimpleLineSymbolClass();
               linesymbol.Color = pColor as IColor;
               linesymbol.Width = 100;

               pElement.Geometry = pPolyline;

               pGC.AddElement(pElement, 2);

               axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
               }
               if (pFlag == 4)
               {
               if(axMapControl1.Map.get_Layer(0)!=null)
               {
                   IRasterLayer pRasterLayer = axMapControl1.Map.get_Layer(0) as IRasterLayer;

                   IRasterSurface pRasterSurface = new RasterSurfaceClass();

                   pRasterSurface.PutRaster(pRasterLayer.Raster, 0);

                   ISurface pSurface = pRasterSurface as ISurface;

                  IPolyline pPolyline = axMapControl1.TrackLine() as  IPolyline;

                   IPoint pPoint =null ;

                    IPolyline pVPolyline =null;

                   IPolyline pInPolyline= null;

                   object pRef=0.13;

                   bool pBool =true;

                   double pZ1 = pSurface.GetElevation(pPolyline.FromPoint);

                   double pZ2= pSurface.GetElevation(pPolyline.ToPoint);

                   IPoint pPoint1 = new PointClass();

                   pPoint1.Z = pZ1;

                   pPoint1.X = pPolyline.FromPoint.X;

                   pPoint1.Y = pPolyline.FromPoint.Y;

                   IPoint pPoint2 = new PointClass();

                   pPoint2.Z = pZ2;

                   pPoint2.X = pPolyline.ToPoint.X;

                   pPoint2.Y = pPolyline.ToPoint.Y;

                   pSurface.GetLineOfSight(pPoint1, pPoint2, out pPoint, out pVPolyline,
                       out pInPolyline, out pBool, false, false, ref pRef);//大爷的,设置为true居然通不过bApplyCurvature和bApplyRefraction两项设置为true,surface必须定义成具有ZUnits的投影坐标

                   //This member should not be used in .NET. As a substitute, .NET developers must use IGeoDatabaseBridge2.GetLineOfSight.

                         //楼主,用IGeoDatabaseBridge2.GetLineOfSight.方法试试
                   if (pVPolyline != null)
                   {

                       IElement pLineElementV = new LineElementClass();

                       pLineElementV.Geometry = pVPolyline;

                       ILineSymbol pLinesymbolV = new SimpleLineSymbolClass();

                       pLinesymbolV.Width = 2;

                       IRgbColor pColorV = new RgbColorClass();

                       pColorV.Green =255;

                       pLinesymbolV.Color = pColorV;

                       ILineElement pLineV = pLineElementV as ILineElement;

                       pLineV.Symbol = pLinesymbolV;

                       axMapControl1.ActiveView.GraphicsContainer.AddElement(pLineElementV, 0);
                   }

                   if (pInPolyline != null)
                   {

                       IElement pLineElementIn = new LineElementClass();

                       pLineElementIn.Geometry = pInPolyline;

                       ILineSymbol pLinesymbolIn = new SimpleLineSymbolClass();

                       pLinesymbolIn.Width = 2;

                       IRgbColor pColorIn = new RgbColorClass();
                       pColorIn.Red = 255;

                       pLinesymbolIn.Color = pColorIn;
                       ILineElement pLineIn = pLineElementIn as ILineElement;

                       pLineIn.Symbol = pLinesymbolIn;

                       axMapControl1.ActiveView.GraphicsContainer.AddElement(pLineElementIn, 1);

                   }

                   axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

                   axMapControl1.TrackCancel.Cancel();

               }
               }
        }