ArcObjects Library Reference

Flash Geometry Snippet

Flash geometry on the display. The geometry type could be polygon, polyline, point, or multipoint.

[C#]

///<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 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.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();
}
[Visual Basic .NET]

'''<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 Sub FlashGeometry(ByVal geometry As ESRI.ArcGIS.Geometry.IGeometry, ByVal color As ESRI.ArcGIS.Display.IRgbColor, ByVal display As ESRI.ArcGIS.Display.IDisplay, ByVal delay As System.Int32)

  If geometry Is Nothing OrElse color Is Nothing OrElse display Is Nothing Then
    Return
  End If

  display.StartDrawing(display.hDC, CShort(ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache))

  Select Case geometry.GeometryType
  Case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon

    'Set the flash geometry's symbol.
    Dim simpleFillSymbol As ESRI.ArcGIS.Display.ISimpleFillSymbol = New ESRI.ArcGIS.Display.SimpleFillSymbolClass
    simpleFillSymbol.Color = color
    Dim symbol As ESRI.ArcGIS.Display.ISymbol = TryCast(simpleFillSymbol, 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)
    Exit Select

  Case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline

    'Set the flash geometry's symbol.
    Dim simpleLineSymbol As ESRI.ArcGIS.Display.ISimpleLineSymbol = New ESRI.ArcGIS.Display.SimpleLineSymbolClass
    simpleLineSymbol.Width = 4
    simpleLineSymbol.Color = color
    Dim symbol As ESRI.ArcGIS.Display.ISymbol = TryCast(simpleLineSymbol, 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)
    Exit Select

  Case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint

    'Set the flash geometry's symbol.
    Dim simpleMarkerSymbol As ESRI.ArcGIS.Display.ISimpleMarkerSymbol = New ESRI.ArcGIS.Display.SimpleMarkerSymbolClass
    simpleMarkerSymbol.Style = ESRI.ArcGIS.Display.esriSimpleMarkerStyle.esriSMSCircle
    simpleMarkerSymbol.Size = 12
    simpleMarkerSymbol.Color = color
    Dim symbol As ESRI.ArcGIS.Display.ISymbol = TryCast(simpleMarkerSymbol, 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)
    Exit Select

  Case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryMultipoint

    'Set the flash geometry's symbol.
    Dim simpleMarkerSymbol As ESRI.ArcGIS.Display.ISimpleMarkerSymbol = New ESRI.ArcGIS.Display.SimpleMarkerSymbolClass
    simpleMarkerSymbol.Style = ESRI.ArcGIS.Display.esriSimpleMarkerStyle.esriSMSCircle
    simpleMarkerSymbol.Size = 12
    simpleMarkerSymbol.Color = color
    Dim symbol As ESRI.ArcGIS.Display.ISymbol = TryCast(simpleMarkerSymbol, 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)
    Exit Select

  End Select

  display.FinishDrawing()

End Sub


Additional Requirements
  • The code in this document requires the following References added to the Visual Studio project:
  • ESRI.ArcGIS.Display
  • ESRI.ArcGIS.Geometry
  • ESRI.ArcGIS.System