// wire up the events for when items are added/removed from the focus map // NOTE: this must be done after each time the active view changes so that the events are // pointing to the correct map public void UnSubscribeToItemChangeEvents() { try { //((IActiveViewEvents_Event)m_pActiveView_of_ItemEvents).ItemAdded -= m_OnItemAdded; //((IActiveViewEvents_Event)m_pActiveView_of_ItemEvents).ItemDeleted -= m_OnItemDeleted; m_OnItemAdded = null; m_OnItemDeleted = null; } catch(Exception ex) { Debug.WriteLine(ex.Message + "\n" + ex.StackTrace); /*util.Logger.Write(" Descrip : Unsubscribing to the add/remove item change events of the map. " + "\n Message : " + ex.Message + "\n StackTrc : " + ex.StackTrace,util.Logger.LogLevel.Debug); */ } }
private void SetupActiveViewEvents(IMap map) { if (map == null) return; try { IActiveViewEvents_Event activeViewEvents = map as IActiveViewEvents_Event; _activeViewEventsFocusMapChanged = new IActiveViewEvents_FocusMapChangedEventHandler(OnActiveViewEventsFocusMapChanged); activeViewEvents.FocusMapChanged += _activeViewEventsFocusMapChanged; _activeViewEventsItemAdded = new IActiveViewEvents_ItemAddedEventHandler(OnActiveViewEventsItemAdded); activeViewEvents.ItemAdded += _activeViewEventsItemAdded; _activeViewEventsItemDeleted = new IActiveViewEvents_ItemDeletedEventHandler(OnActiveViewEventsItemDeleted); activeViewEvents.ItemDeleted += _activeViewEventsItemDeleted; } catch { } }
// wire up the events for when items are added/removed from the focus map // NOTE: this must be done after each time the active view changes so that the events are // pointing to the correct map public void SubscribeToItemChangeEvents() { try { m_OnItemAdded = null; m_OnItemDeleted = null; m_OnItemAdded = new IActiveViewEvents_ItemAddedEventHandler(OnActiveViewEvent_Handler); m_OnItemDeleted = new IActiveViewEvents_ItemDeletedEventHandler(OnActiveViewEvent_Handler); ((IActiveViewEvents_Event)m_pActiveView_of_ItemEvents).ItemAdded += m_OnItemAdded; ((IActiveViewEvents_Event)m_pActiveView_of_ItemEvents).ItemDeleted += m_OnItemDeleted; } catch(Exception ex) { Debug.WriteLine(ex.Message + "\n" + ex.StackTrace); util.Logger.Write(" Descrip : Subscribing to the add/remove item change events of the map. " + "\n Message : " + ex.Message + "\n StackTrc : " + ex.StackTrace,util.Logger.LogLevel.Debug); } }