DDW

Not Zooming to the new extent\envelope when refreshing

Discussion created by DDW on Oct 6, 2011
Latest reply on Oct 7, 2011 by DDW
I am new to ArcObjects and C# programming and need some assistance.

I am creating an add-in button that zooms to an extent in an ArcMap document. When I run the add-in - the first time the button is activated it will go to the proper extent. However, if I change extents and wish to go back the button will not take me back to the proper extent unless I push the button twice.

Here is the code....

        public void ZoomBuenaBookmark(IMxDocument mxDocument)
        {
            if (mxDocument == null)
            {
                return;
            }

            Double xMax = 01692779.75;
            Double xMin = 01681191.02;
            Double yMax = 00401956.16;
            Double yMin = 00395058.46;
            IActiveView activeView = mxDocument.ActivatedView;
            if (activeView == null)
            {
                return;
            }
            IEnvelope envelope = activeView.Extent;
            envelope.XMax = xMax;
            envelope.XMin = xMin;
            envelope.YMax = yMax;
            envelope.YMin = yMin;
            activeView.Extent = envelope;
            activeView.Refresh();
        }

Any feedback would be greatly appreciated.

Thanks

Outcomes