private void OnActiveViewEventsAfterDraw(ESRI.ArcGIS.Display.IDisplay display, ESRI.ArcGIS.Carto.esriViewDrawPhase phase) { ESRI.ArcGIS.Carto.esriViewDrawPhase m_phase = phase; //if the drawing pahse geography, find all feature layer and selected feature and draw them on screen if they are polygons. Please note don't call display::StartDrawing as it is already started by the system. if (m_phase == ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeography) { IMap m_Map = m_MxDoc.FocusMap; ESRI.ArcGIS.esriSystem.UID m_UID = new ESRI.ArcGIS.esriSystem.UID(); m_UID.Value = "{40A9E885-5533-11d0-98BE-00805F7CED21}"; IEnumLayer m_EnumLayer = m_Map.Layers[m_UID]; ILayer m_Layer = m_EnumLayer.Next(); //if you want to change the selection color you can change it here. ISimpleFillSymbol m_FillSymbol = new SimpleFillSymbol(); m_Rgb = new RgbColor(); m_Rgb.Red = 255; m_FillSymbol.Color = m_Rgb; display.SetSymbol(m_FillSymbol as ISymbol); do { if (m_Layer is IFeatureLayer) { if (m_Layer != null) { IFeatureSelection m_FeatureSelection = (IFeatureSelection)m_Layer; ISelectionSet m_SelSet = m_FeatureSelection.SelectionSet; IFeatureCursor m_FeatCur; ICursor m_Cursor; m_SelSet.Search(null, false, out m_Cursor); m_FeatCur = (IFeatureCursor)m_Cursor; IFeature m_Feature; m_Feature = m_FeatCur.NextFeature(); do { if (m_Feature != null) { if (m_Feature.Shape is IPolygon) { display.DrawPolygon(m_Feature.Shape); } } m_Feature = m_FeatCur.NextFeature(); } while (m_Feature != null); } } m_Layer = m_EnumLayer.Next(); } while (m_Layer != null); } #endregion }
///<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(); }