/// <summary> /// Raises the <see cref="Selecting" /> event. /// </summary> /// <param name="e">The <see cref="TabListCancelEventArgs" /> instance containing the event data.</param> protected virtual void OnSelecting(TabListCancelEventArgs e) { EventHandler <TabListCancelEventArgs> handler; handler = (EventHandler <TabListCancelEventArgs>) this.Events[_eventSelecting]; handler?.Invoke(this, e); }
private void ProcessTabChange(int index) { if (index != _selectedIndex) { TabListCancelEventArgs cancelEventArgs; TabListPage newPage; newPage = _pages[index]; // first raise the Selecting event to allow the UI choice to be cancelled cancelEventArgs = new TabListCancelEventArgs(newPage, index, TabListAction.Selecting); this.OnSelecting(cancelEventArgs); if (!cancelEventArgs.Cancel) { TabListPage currentPage; currentPage = this.SelectedPage; // next, raise the Deselect event (if appropriate), and again check for cancellation if (currentPage != null) { cancelEventArgs = new TabListCancelEventArgs(currentPage, _selectedIndex, TabListAction.Deselecting); this.OnDeselecting(cancelEventArgs); } if (!cancelEventArgs.Cancel) { this.SelectedIndex = index; this.OnSelected(new TabListEventArgs(newPage, index, TabListAction.Selected)); if (currentPage != null) { this.OnDeselected(new TabListEventArgs(currentPage, _selectedIndex, TabListAction.Deselected)); } } } } }