private void SetupActiveViewEvents(ESRI.ArcGIS.Carto.IMap map) { //parameter check if (map == null) { return; } ESRI.ArcGIS.Carto.IActiveViewEvents_Event activeViewEvents = map as ESRI.ArcGIS.Carto.IActiveViewEvents_Event; // Create an instance of the delegate, add it to AfterDraw event m_ActiveViewEventsAfterDraw = new ESRI.ArcGIS.Carto.IActiveViewEvents_AfterDrawEventHandler(OnActiveViewEventsAfterDraw); activeViewEvents.AfterDraw += m_ActiveViewEventsAfterDraw; // Create an instance of the delegate, add it to AfterItemDraw event m_ActiveViewEventsAfterItemDraw = new ESRI.ArcGIS.Carto.IActiveViewEvents_AfterItemDrawEventHandler(OnActiveViewEventsItemDraw); activeViewEvents.AfterItemDraw += m_ActiveViewEventsAfterItemDraw; // Create an instance of the delegate, add it to ContentsChanged event m_ActiveViewEventsContentsChanged = new ESRI.ArcGIS.Carto.IActiveViewEvents_ContentsChangedEventHandler(OnActiveViewEventsContentsChanged); activeViewEvents.ContentsChanged += m_ActiveViewEventsContentsChanged; // Create an instance of the delegate, add it to ContentsCleared event m_ActiveViewEventsContentsCleared = new ESRI.ArcGIS.Carto.IActiveViewEvents_ContentsClearedEventHandler(OnActiveViewEventsContentsCleared); activeViewEvents.ContentsCleared += m_ActiveViewEventsContentsCleared; // Create an instance of the delegate, add it to FocusMapChanged event m_ActiveViewEventsFocusMapChanged = new ESRI.ArcGIS.Carto.IActiveViewEvents_FocusMapChangedEventHandler(OnActiveViewEventsFocusMapChanged); activeViewEvents.FocusMapChanged += m_ActiveViewEventsFocusMapChanged; // Create an instance of the delegate, add it to ItemAdded event m_ActiveViewEventsItemAdded = new ESRI.ArcGIS.Carto.IActiveViewEvents_ItemAddedEventHandler(OnActiveViewEventsItemAdded); activeViewEvents.ItemAdded += m_ActiveViewEventsItemAdded; // Create an instance of the delegate, add it to ItemDeleted event m_ActiveViewEventsItemDeleted = new ESRI.ArcGIS.Carto.IActiveViewEvents_ItemDeletedEventHandler(OnActiveViewEventsItemDeleted); activeViewEvents.ItemDeleted += m_ActiveViewEventsItemDeleted; // Create an instance of the delegate, add it to ItemReordered event m_ActiveViewEventsItemReordered = new ESRI.ArcGIS.Carto.IActiveViewEvents_ItemReorderedEventHandler(OnActiveViewEventsItemReordered); activeViewEvents.ItemReordered += m_ActiveViewEventsItemReordered; // Create an instance of the delegate, add it to SelectionChanged event m_ActiveViewEventsSelectionChanged = new ESRI.ArcGIS.Carto.IActiveViewEvents_SelectionChangedEventHandler(OnActiveViewEventsSelectionChanged); activeViewEvents.SelectionChanged += m_ActiveViewEventsSelectionChanged; // Create an instance of the delegate, add it to SpatialReferenceChanged event m_ActiveViewEventsSpatialReferenceChanged = new ESRI.ArcGIS.Carto.IActiveViewEvents_SpatialReferenceChangedEventHandler(OnActiveViewEventsSpatialReferenceChanged); activeViewEvents.SpatialReferenceChanged += m_ActiveViewEventsSpatialReferenceChanged; // Create an instance of the delegate, add it to ViewRefreshed event m_ActiveViewEventsViewRefreshed = new ESRI.ArcGIS.Carto.IActiveViewEvents_ViewRefreshedEventHandler(OnActiveViewEventsViewRefreshed); activeViewEvents.ViewRefreshed += m_ActiveViewEventsViewRefreshed; }
private void RemoveActiveViewEvents(ESRI.ArcGIS.Carto.IMap map) { //parameter check if (map == null) { return; } ESRI.ArcGIS.Carto.IActiveViewEvents_Event activeViewEvents = map as ESRI.ArcGIS.Carto.IActiveViewEvents_Event; // Remove AfterDraw Event Handler activeViewEvents.AfterDraw -= m_ActiveViewEventsAfterDraw; // Remove AfterItemDraw Event Handler activeViewEvents.AfterItemDraw -= m_ActiveViewEventsAfterItemDraw; // Remove ContentsChanged Event Handler activeViewEvents.ContentsChanged -= m_ActiveViewEventsContentsChanged; // Remove ContentsCleared Event Handler activeViewEvents.ContentsCleared -= m_ActiveViewEventsContentsCleared; // Remove FocusMapChanged Event Handler activeViewEvents.FocusMapChanged -= m_ActiveViewEventsFocusMapChanged; // Remove ItemAdded Event Handler activeViewEvents.ItemAdded -= m_ActiveViewEventsItemAdded; // Remove ItemDeleted Event Handler activeViewEvents.ItemDeleted -= m_ActiveViewEventsItemDeleted; // Remove ItemReordered Event Handler activeViewEvents.ItemReordered -= m_ActiveViewEventsItemReordered; // Remove SelectionChanged Event Handler activeViewEvents.SelectionChanged -= m_ActiveViewEventsSelectionChanged; // Remove SpatialReferenceChanged Event Handler activeViewEvents.SpatialReferenceChanged -= m_ActiveViewEventsSpatialReferenceChanged; // Remove ViewRefreshed Event Handler activeViewEvents.ViewRefreshed -= m_ActiveViewEventsViewRefreshed; }