if (pGPValue is IGPFeatureLayer)
{
IFeatureLayer pFeatureLayer = pGPUtilities.DecodeLayer(pGPValue) as IFeatureLayer;
ISelectionSet pSelectionSet = (pFeatureLayer as IFeatureSelection).SelectionSet;
if (pSelectionSet != null && pSelectionSet.Count > 0)
{
IEnumIDs pEnumIDs = pSelectionSet.IDs;
for (int j = 0; j < pSelectionSet.Count; ++j)
{
IEnvelope pCurrentExtent = pFeatureLayer.FeatureClass.GetFeature(pEnumIDs.Next()).Extent;
if (pCurrentExtent != null)
{
pCurrentExtent.Project(pGeographicCoordinateSystem);
pInputExtent.Union(pCurrentExtent);
}
}
}
else
{
IQueryFilter pQueryFilter = null;
int iFeatureCount = pFeatureLayer.FeatureClass.FeatureCount(pQueryFilter);
for (int j = 0; j < iFeatureCount; ++j)
{
IEnvelope pCurrentExtent = pFeatureLayer.FeatureClass.GetFeature(j).Extent;
if (pCurrentExtent != null)
{
pCurrentExtent.Project(pGeographicCoordinateSystem);
pInputExtent.Union(pCurrentExtent);
}
}
}
}