Example #1
0
        private void SearchFeature(ISpatialFilter pSpatialFilter, IFeatureLayer pFeatureLyr)
        {
            ISpatialFilter pFilter;

            pFilter = pSpatialFilter;
            IFeatureLayer pFeatureLayer;

            pFeatureLayer = pFeatureLyr;
            IFeatureClass  pFC = pFeatureLayer.FeatureClass;
            IFeatureCursor pFeatureCursor;

            pFeatureCursor = pFeatureLayer.Search(pFilter, true);

            IFeature pFeature;

            pFeature = pFeatureCursor.NextFeature();
            IGeometry pShape;

            switch (pFC.ShapeType)
            {
            case esriGeometryType.esriGeometryPolyline:
                while (pFeature != null)
                {
                    ISimpleLineSymbol pFillsyl;
                    pFillsyl       = new SimpleLineSymbolClass();
                    pFillsyl.Color = getRGB(220, 100, 50);
                    object oFillsyl;
                    oFillsyl = pFillsyl;
                    pShape   = pFeature.Shape as IPolyline;
                    m_mapControl.FlashShape(pShape, 15, 20, pFillsyl);
                    m_mapControl.DrawShape(pShape, ref oFillsyl);
                    pFeature = pFeatureCursor.NextFeature();
                }
                break;

            case esriGeometryType.esriGeometryPolygon:
                while (pFeature != null)
                {
                    ISimpleFillSymbol pFillsyl;
                    pFillsyl       = new SimpleFillSymbolClass();
                    pFillsyl.Color = getRGB(220, 100, 50);
                    object oFillsyl;
                    oFillsyl = pFillsyl;
                    pShape   = pFeature.Shape as IPolygon;
                    m_mapControl.FlashShape(pShape, 15, 20, pFillsyl);
                    m_mapControl.DrawShape(pShape, ref oFillsyl);
                    pFeature = pFeatureCursor.NextFeature();
                }
                break;

            case esriGeometryType.esriGeometryPoint:
                while (pFeature != null)
                {
                    ISimpleMarkerSymbol pFillsyl;
                    pFillsyl       = new SimpleMarkerSymbolClass();
                    pFillsyl.Color = getRGB(220, 100, 50);
                    object oFillsyl;
                    oFillsyl = pFillsyl;
                    pShape   = pFeature.Shape as IPoint;
                    m_mapControl.FlashShape(pShape, 15, 20, pFillsyl);
                    m_mapControl.DrawShape(pShape, ref oFillsyl);
                    pFeature = pFeatureCursor.NextFeature();
                }
                break;
            }
        }