Yaircc.MainForm.ChannelsTabControl_MouseDown C# (CSharp) Method

ChannelsTabControl_MouseDown() private method

Handles the MouseDown event of System.Windows.Forms.TabControl.
private ChannelsTabControl_MouseDown ( object sender, MouseEventArgs e ) : void
sender object The source of the event.
e MouseEventArgs The event arguments.
return void
        private void ChannelsTabControl_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                IRCTabPage tab = null;
                for (int i = 0; i < this.channelsTabControl.TabPages.Count; i++)
                {
                    if (this.channelsTabControl.GetTabRect(i).Contains(e.Location))
                    {
                        tab = this.channelsTabControl.TabPages[i] as IRCTabPage;
                    }
                }

                if (tab != null)
                {
                    if (tab.TabType == IRCTabType.Channel)
                    {
                        this.leaveChannelTabMenuItem.Visible = true;
                        this.leaveChannelTabMenuItem.Text = string.Format("Leave {0}", tab.Text);
                        this.tabSeparatorItem.Visible = true;
                        this.disconnectTabMenuItem.Visible = true;
                        this.disconnectTabMenuItem.Text = string.Format("Disconnect from {0}", tab.Marshal.Connection.ToString());
                        this.closeChannelTabMenuItem.Visible = false;
                    }
                    else if (tab.TabType == IRCTabType.Server)
                    {
                        this.leaveChannelTabMenuItem.Visible = false;
                        this.tabSeparatorItem.Visible = false;
                        this.disconnectTabMenuItem.Visible = true;
                        this.disconnectTabMenuItem.Text = string.Format("Disconnect from {0}", tab.Marshal.Connection.ToString());
                        this.closeChannelTabMenuItem.Visible = false;
                    }
                    else if (tab.TabType == IRCTabType.PM)
                    {
                        this.closeChannelTabMenuItem.Visible = true;
                        this.leaveChannelTabMenuItem.Visible = false;
                        this.tabSeparatorItem.Visible = true;
                        this.disconnectTabMenuItem.Visible = true;
                        this.disconnectTabMenuItem.Text = string.Format("Disconnect from {0}", tab.Marshal.Connection.ToString());
                    }

                    if (tab.TabType != IRCTabType.Console)
                    {
                        this.channelsTabControl.SelectedTab = tab;
                        this.tabContextMenu.Show(this.channelsTabControl, e.Location, ToolStripDropDownDirection.Default);
                    }
                }
            }
        }
MainForm