private void axPageLayoutControl1_OnPageLayoutReplaced(object sender, IPageLayoutControlEvents_OnPageLayoutReplacedEvent e) { //Get the IActiveView of the focus map in the PageLayoutControl IActiveView activeView = axPageLayoutControl1.ActiveView.FocusMap as IActiveView; //Trap the ITranformEvents of the PageLayoutCntrol's focus map visBoundsUpdatedE = new ITransformEvents_VisibleBoundsUpdatedEventHandler(OnVisibleBoundsUpdated); IDisplayTransformation displayTransformation = activeView.ScreenDisplay.DisplayTransformation; //Start listening to the transform events interface m_transformEvents = (ITransformEvents_Event)displayTransformation; //Start listening to the VisibleBoundsUpdated method on ITransformEvents interface m_transformEvents.VisibleBoundsUpdated += visBoundsUpdatedE; //Get the extent of the focus map m_Envelope = activeView.Extent; //Load the same pre-authored map document into the MapControl axMapControl1.LoadMxFile(axPageLayoutControl1.DocumentFilename, null, null); //Set the extent of the MapControl to the full extent of the data axMapControl1.Extent = axMapControl1.FullExtent; }
public override void OnClick() { try { IMap Map; if (m_hookHelper == null) { return; } Map = m_hookHelper.FocusMap as IMap; if (Map == null) { return; } m_TransformEvents = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation as ITransformEvents_Event; m_TransformEvents.VisibleBoundsUpdated += new ITransformEvents_VisibleBoundsUpdatedEventHandler(m_TransformEvents_VisibleBoundsUpdated); } catch (Exception ex) { } }
public void Remove_EventHandler() { m_TransformEvents.VisibleBoundsUpdated -= new ITransformEvents_VisibleBoundsUpdatedEventHandler(m_TransformEvents_VisibleBoundsUpdated); m_TransformEvents = null; }