private IFeature m_feature;
public override void OnClick()
{
if (m_feature == null) return;
IMxDocument pMxDoc = m_application.Document as IMxDocument;
IActiveView activeView = pMxDoc.ActiveView;
double midX = (m_feature.Extent.XMax + m_feature.Extent.XMin) / 2;
double midY = (m_feature.Extent.YMax + m_feature.Extent.YMin) / 2;
IPoint pPoint = new PointClass();
pPoint.SpatialReference = m_feature.Extent.SpatialReference;
pPoint.PutCoords(midX, midY);
pPoint.Project(activeView.Extent.SpatialReference);
IEnvelope pCurrentEnvelope = activeView.Extent;
pCurrentEnvelope.CenterAt(pPoint);
activeView.Extent = pCurrentEnvelope;
activeView.Refresh();
}Solved! Go to Solution.
public override void OnClick()
{
if (m_feature == null) return;
IMxDocument pMxDoc = m_application.Document as IMxDocument;
IActiveView activeView = pMxDoc.ActiveView;
double midX = (m_feature.Extent.XMax + m_feature.Extent.XMin) / 2;
double midY = (m_feature.Extent.YMax + m_feature.Extent.YMin) / 2;
IPoint pPoint = new PointClass();
pPoint.SpatialReference = m_feature.Extent.SpatialReference;
pPoint.PutCoords(midX, midY);
pPoint.Project(activeView.Extent.SpatialReference);
IEnvelope pCurrentEnvelope = activeView.Extent;
pCurrentEnvelope.CenterAt(pPoint);
activeView.Extent = pCurrentEnvelope;
activeView.Refresh();
activeView.ScreenDisplay.UpdateWindow();
IFeatureIdentifyObj featIdentify = new FeatureIdentifyObject();
featIdentify.Feature = m_feature;
IIdentifyObj identify = featIdentify as IIdentifyObj;
identify.Flash(activeView.ScreenDisplay);
}
public override void OnClick()
{
if (m_feature == null) return;
IMxDocument pMxDoc = m_application.Document as IMxDocument;
IActiveView activeView = pMxDoc.ActiveView;
double midX = (m_feature.Extent.XMax + m_feature.Extent.XMin) / 2;
double midY = (m_feature.Extent.YMax + m_feature.Extent.YMin) / 2;
IPoint pPoint = new PointClass();
pPoint.SpatialReference = m_feature.Extent.SpatialReference;
pPoint.PutCoords(midX, midY);
pPoint.Project(activeView.Extent.SpatialReference);
IEnvelope pCurrentEnvelope = activeView.Extent;
pCurrentEnvelope.CenterAt(pPoint);
activeView.Extent = pCurrentEnvelope;
activeView.Refresh();
activeView.ScreenDisplay.UpdateWindow();
IFeatureIdentifyObj featIdentify = new FeatureIdentifyObject();
featIdentify.Feature = m_feature;
IIdentifyObj identify = featIdentify as IIdentifyObj;
identify.Flash(activeView.ScreenDisplay);
}
Worked for me! Thanks!