protected override void OnMouseClick(MouseEventArgs e)
{
int index = this.ActiveIndex;
// If we are clicking on an image then raise the ImageClicked event before raising the standard mouse click event
// if there if a handler.
if (index > -1 && this.TabImageClick != null
&& (this.TabPages[index].ImageIndex > -1 || !string.IsNullOrEmpty(this.TabPages[index].ImageKey))
&& this.GetTabImageRect(index).Contains(this.MousePosition)){
this.OnTabImageClick(new TabControlEventArgs(this.TabPages[index], index, TabControlAction.Selected));
// Fire the base event
base.OnMouseClick(e);
} else if (!this.DesignMode && index > -1 && this._StyleProvider.ShowTabCloser && this.GetTabCloserRect(index).Contains(this.MousePosition)){
// If we are clicking on a closer then remove the tab instead of raising the standard mouse click event
// But raise the tab closing event first
TabPage tab = this.ActiveTab;
TabControlCancelEventArgs args = new TabControlCancelEventArgs(tab, index, false, TabControlAction.Deselecting);
this.OnTabClosing(args);
if (!args.Cancel){
this.TabPages.Remove(tab);
tab.Dispose();
}
} else {
// Fire the base event
base.OnMouseClick(e);
}
}