Flash Geometry

Discussion created by crdnlpwr on Oct 17, 2011

I've created some code that'll zoom to a feature queried from an ArcGIS Server Map Service, however now I want to flash the feature's geometry on the screen.  I've grabbed the FlashGeometry snippet,

however nothing happens when I get to that portion of my code.  I'm not sure what I'm missing, any suggestions would be appreciated.

            IGISServerConnection pGISServCon = new GISServerConnection();
            IServerObjectManager pSOM = pGISServCon.ServerObjectManager;
            IServerContext pServerContext = pSOM.CreateServerContext("MyMapService", "MapServer");
            IMapServer pMapServer = pServerContext.ServerObject as IMapServer;

            IMapServerObjects pMapServerObjs = pMapServer as IMapServerObjects;
            IMap pMap = pMapServerObjs.get_Map(pMapServer.DefaultMapName);

            ILayer pFLayer = pMap.get_Layer(zoomMapServID) as ILayer;

            IFeatureLayer pFeatlayer = pFLayer as IFeatureLayer;
            IFeatureClass pFeatureClass = pFeatlayer.FeatureClass;

            IQueryFilter pQfilt = new QueryFilterClass();
            pQfilt.WhereClause = zoomColumn + " = '" + textBox1.Text + "'";

            IFeatureCursor pFC = pFeatureClass.Search(pQfilt, false);
            IFeature pFeat = pFC.NextFeature(); // all queries will return only 1 feature           

            IGeometry pGeom = pFeat.ShapeCopy as IGeometry;  

            IApplication pApp = ArcMap.Application;

            IMxDocument pMxd = ArcMap.Document;

            // Get the focus map
            IMap map = pMxd.FocusMap;

            // Cast from IMap to IActiveView
            IActiveView pActiveview = (IActiveView)map;

            IEnvelope pEnv = new EnvelopeClass();
            //Set envelope to the geometry collection from the property below
            pEnv = pGeom.Envelope;           

            //Create a new envelope to pass the values to from the geometry 
            IEnvelope envelope = new EnvelopeClass();
            envelope.XMax = pEnv.Envelope.XMax;
            envelope.YMax = pEnv.Envelope.YMax;
            envelope.XMin = pEnv.Envelope.XMin;
            envelope.YMin = pEnv.Envelope.YMin;

            envelope.Expand(150, 150, false);  

            pActiveview.Extent = envelope;


            //Setup parameters for FlashGeometry method

            IRgbColor rgbColor = new RgbColorClass();
            //Color Properties
            rgbColor.Red = 133;
            rgbColor.Green = 135;
            rgbColor.Blue = 43;            
            IDisplay pDisplay = pActiveview.ScreenDisplay;

            FlashGeometry(pGeom, rgbColor, pDisplay, 300);         

Flash Geometry Code, I removed the case statements for all other geometries other than polygon to shorten the code block.

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)

  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.