public EditorEventsDialog(object hook) { InitializeComponent(); this.Hook = hook; e_dockWinForm = this; //get a reference to the editor UID uid = new UIDClass(); uid.Value = "esriEditor.Editor"; m_editor = ArcMap.Application.FindExtensionByCLSID(uid) as ESRI.ArcGIS.Editor.IEditor; m_TabControl = e_dockWinForm.tabControl1; System.Collections.IEnumerator e = m_TabControl.TabPages.GetEnumerator(); e.MoveNext(); m_listenTab = e.Current as TabPage; e.MoveNext(); m_selectTab = e.Current as TabPage; CheckedListBox editEventList = m_selectTab.GetNextControl(m_selectTab, true) as CheckedListBox; editEventList.ItemCheck += new ItemCheckEventHandler(editEventList_ItemCheck); ListBox listEvent = m_listenTab.GetNextControl(m_listenTab, true) as ListBox; listEvent.MouseDown += new MouseEventHandler(listEvent_MouseDown); eventListener = new EventListener(m_editor); eventListener.Changed += new ChangedEventHandler(eventListener_Changed); //populate the editor events editEventList.Items.AddRange(Enum.GetNames(typeof(EventListener.EditorEvent))); }
static void Main(string[] args) { // Create a new list. CustomEventsListWithChangedEvent list = new CustomEventsListWithChangedEvent(); // Create a class that listens to the list's change event. EventListener listener = new EventListener(list); // Add and remove items from the list. list.Add("item 1"); list.Clear(); listener.Detach(); Console.Read(); }
public static void AddListener <T>(this object context, EventListener <T> listener, Priority priority = Priority.Normal, int channel = EventManager.DefaultChannel) where T : Event, new() => EventManager.AddListener(listener, priority, context, channel);
public static void RemoveListener <T>(this object context, EventListener <T> listener, int channel = EventManager.DefaultChannel) where T : Event, new() => EventManager.RemoveListener(listener, context, channel);