protected override void OnMouseClick(MouseEventArgs e)
        {
            if (!_conditionBooleanArray[6])
            {
                if (e.Button == MouseButtons.Left)
                {
                    // IsCaptionVisible?
                    if (_conditionBooleanArray[1])
                    {
                        if (conditionRectangleArray[1].Contains(e.Location))
                        {
                            var contextMenu = new ContextMenuStrip();
                            var dropDownLocation = PointToScreen(new Point(conditionRectangleArray[1].X, conditionRectangleArray[1].Bottom));

                            using (var ea = new ContextMenuShownEventArgs(contextMenu, dropDownLocation))
                            {
                                // Fire a Notification Event.
                                OnContextMenuShown(ea);
                            }

                            goto Finalize;
                        }
                        if (TabCount > 0 && conditionRectangleArray[2].Contains(e.Location))
                        {
                            var closingTabPage = (TabPageEx)SelectedTab;
                            var flag = closingTabPage.IsClosable ? closingTabPage.Enabled : false;

                            if (flag)
                            {
                                using (var sea = new SelectedIndexChangingEventArgs(closingTabPage, SelectedIndex))
                                {
                                    // Fire a Notification Event.
                                    OnTabPageClosing(sea);

                                    if (!sea.Cancel)
                                    {
                                        TabPages.Remove(closingTabPage);
                                        SelectNextAvailableTabPage();
                                    }
                                    else
                                        MessageBox.Show("The operation was canceled by the user.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);

                                    Cursor.Position = PointToScreen(e.Location);
                                }
                            }

                            goto Finalize;
                        }
                    }

                    // IsDocumentTabStyle?
                    if (!_conditionBooleanArray[4] ? TabCount > 1 : TabCount >= 1)
                    {
                        var closingTabPage = (TabPageEx)SelectedTab;
                        if (conditionRectangleArray[0].Contains(e.Location))
                        {
                            var flag = closingTabPage.IsClosable ? !closingTabPage.Enabled || closingTabPage.preventClosing : true;
                            if (!flag)
                            {
                                using (var te = new SelectedIndexChangingEventArgs(closingTabPage, SelectedIndex))
                                {
                                    // Fire a Notification Event.
                                    OnTabPageClosing(te);

                                    if (!te.Cancel)
                                    {
                                        SelectedTab.Dispose();
                                        if (DesignMode)
                                        {
                                            var selectionService = (ISelectionService)GetService(typeof(ISelectionService));
                                            selectionService.SetSelectedComponents(new IComponent[] { this }, SelectionTypes.Auto);
                                        }
                                        else
                                            SelectNextAvailableTabPage();
                                    }

                                    Cursor.Position = PointToScreen(e.Location);
                                }
                            }
                            else
                                closingTabPage.preventClosing = false;
                        }
                        else
                            closingTabPage.preventClosing = false;
                    }
                }
            }

            Finalize: ;
            base.OnMouseClick(e);
        }
        protected virtual void OnContextMenuShown(ContextMenuShownEventArgs e)
        {
            ToolStripMenuItem menuItem;
            if (TabCount > 0)
            {
                menuItem = new ToolStripMenuItem("Close", Resources.delete_12x12, null, Keys.Control | Keys.C);
                menuItem.ImageScaling = ToolStripItemImageScaling.None;
                var closingTabPage = (TabPageEx)SelectedTab;
                menuItem.Enabled = closingTabPage.IsClosable && closingTabPage.Enabled;
                if (menuItem.Enabled)
                {
                    menuItem.Click += (sender, ea) =>
                    {
                        using (var sea = new SelectedIndexChangingEventArgs(closingTabPage, SelectedIndex))
                        {
                            // Fire a Notification Event.
                            OnTabPageClosing(sea);

                            if (!sea.Cancel)
                            {
                                TabPages.Remove(closingTabPage);
                                SelectNextAvailableTabPage();
                            }
                            else
                                MessageBox.Show("The operation was canceled by the user.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    };
                }

                e.ContextMenu.Items.Add(menuItem);

                if (TabCount > 1)
                {
                    menuItem = new ToolStripMenuItem("Close All But This", Resources.PushpinHS, null, Keys.Control | Keys.A);
                    menuItem.Click += (sender, ea) =>
                    {
                        // Iterate All TabPages in the collection.
                        for (var i = TabCount - 1; i >= 0; i--)
                        {
                            var currentTabPage = TabPages[i] as TabPageEx;
                            if (currentTabPage == null || !currentTabPage.IsClosable || i == SelectedIndex)
                                continue;

                            using (var sea = new SelectedIndexChangingEventArgs(currentTabPage, i))
                            {
                                // Fire a Notification Event.
                                OnTabPageClosing(sea);

                                if (!sea.Cancel)
                                    TabPages.Remove(currentTabPage);
                            }
                        }
                    };

                    e.ContextMenu.Items.Add(menuItem);
                    e.ContextMenu.Items.Add(new ToolStripSeparator());
                }
            }

            var availableMenuItems = new List<ToolStripMenuItem>();
            foreach (TabPageEx tab in TabPages)
            {
                menuItem = new ToolStripMenuItem(tab.ToString(), ImageList != null ? (tab.ImageIndex != -1 ? ImageList.Images[tab.ImageIndex] : null) : null, null, tab.Name);
                menuItem.Checked = true;
                menuItem.Click += (sender, ea) =>
                {
                    HideTab((TabPageEx)TabPages[((ToolStripItem)sender).Name]);
                };

                availableMenuItems.Add(menuItem);
            }

            if (_tabPageExPool != null)
            {
                foreach (TabPageEx tab in _tabPageExPool)
                {
                    menuItem = new ToolStripMenuItem(tab.ToString(), ImageList != null ? (tab.ImageIndex != -1 ? ImageList.Images[tab.ImageIndex] : null) : null, null, tab.Name);
                    menuItem.Click += (sender, ea) =>
                    {
                        ShowTab(_tabPageExPool[((ToolStripItem)sender).Name]);
                    };

                    availableMenuItems.Add(menuItem);
                }
            }

            if (availableMenuItems.Count > 0)
            {
                availableMenuItems.Sort((p1, p2) => String.Compare(p1.Text, p2.Text, StringComparison.Ordinal));

                try
                {
                    var availableItem = availableMenuItems.Cast<ToolStripItem>().ToArray();

                    menuItem = new ToolStripMenuItem("Available Tab Pages", Resources.InsertTabControlHS, availableItem);
                    e.ContextMenu.Items.Add(menuItem);
                    availableMenuItems.Clear();
                }
                catch
                {
                    ;
                }
            }

            if (ContextMenuShown != null)
                ContextMenuShown(this, e);

            e.ContextMenu.Show(e.MenuLocation);
        }