private void UpdateRecentReposFromSettings()
        {
            NewTabContextMenu.SuspendLayout();

            RecentReposMenu.DropDownItems.Clear();
            NewTabContextMenu.Items.Clear();

            foreach (String repo in Settings.Default.RecentRepos)
            {
                RecentReposMenu.DropDownItems.Add(repo).Click += RecentRepoMenuItem_Click;
                NewTabContextMenu.Items.Add(repo).Click       += RecentRepoMenuItem_Click;
            }

            RecentReposMenu.Enabled   = RecentReposMenu.HasDropDownItems;
            NewTabContextMenu.Enabled = NewTabContextMenu.Items.Count != 0;

            NewTabContextMenu.ResumeLayout();
        }
Пример #2
0
        protected override void OnMouseClick(MouseEventArgs e)
        {
            if (_painter.GetNewTabPath().HitTest(e.Location))
            {
                if (e.Button == MouseButtons.Left)
                {
                    OnNewTabClick(EventArgs.Empty);
                    return;
                }
                else if (e.Button == MouseButtons.Right &&
                         NewTabContextMenu != null)
                {
                    NewTabContextMenu.Show(this, e.Location);
                    return;
                }
            }

            if (this.OptionsMenu != null &&
                e.Button == MouseButtons.Left)
            {
                PointPath optionsPath = _painter.GetOptionsPath();
                if (optionsPath.HitTest(e.Location))
                {
                    OptionsMenu.Show(this, _painter.OptionsMenuLocation);
                    return;
                }
            }

            if (e.Button == MouseButtons.Left)
            {
                Tab closeTab = this.GetTabCloseFromPoint(e.Location);
                if (closeTab != null)
                {
                    ClosingTab = true;
                    this.Tabs.Remove(closeTab);
                    OnTabClosed(new TabClosedEventArgs(closeTab));
                    ClosingTab = false;
                    return;
                }
            }

            if (e.Button != MouseButtons.Left)
            {
                Tab t = GetTabFromPoint(e.Location);
                if (t != null)
                {
                    if (e.Button == MouseButtons.Middle &&
                        this.CloseTabOnMiddleClick)
                    {
                        ClosingTab = true;
                        this.Tabs.Remove(t);
                        OnTabClosed(new TabClosedEventArgs(t));
                        ClosingTab = false;
                        return;
                    }
                    else if (e.Button == MouseButtons.Right &&
                             TabContextMenu != null)
                    {
                        SelectedIndex = Tabs.IndexOf(t);
                        TabContextMenu.Show(this, e.Location);
                        return;
                    }
                    else
                    {
                        SelectedIndex = Tabs.IndexOf(t);
                        OnTabClick(new TabClickEventArgs(t, e));
                        return;
                    }
                }
            }

            base.OnMouseClick(e);
        }