示例#1
0
        /// <summary>Gets the context menu.</summary>
        /// <param name="requestEventArgs">Request parameters.</param>
        /// <returns>Context menu for specified location.</returns>
        public override ContextMenuStrip GetContextMenu(ItemContextMenuRequestEventArgs requestEventArgs)
        {
            ContextMenuStrip menu = null;

            if (Repository != null)
            {
                menu = new ContextMenuStrip();
                menu.Items.Add(GuiItemFactory.GetRefreshReferencesItem <ToolStripMenuItem>(Repository, DataContext, Resources.StrRefresh));
                switch (DataContext)
                {
                case ReferenceType.LocalBranch:
                    menu.Items.Add(GuiItemFactory.GetCreateBranchItem <ToolStripMenuItem>(Repository));
                    break;

                case ReferenceType.RemoteBranch:
                    menu.Items.Add(GuiItemFactory.GetAddRemoteItem <ToolStripMenuItem>(Repository));
                    break;

                case ReferenceType.Tag:
                    menu.Items.Add(GuiItemFactory.GetCreateTagItem <ToolStripMenuItem>(Repository));
                    break;
                }
            }
            if (menu != null)
            {
                Utility.MarkDropDownForAutoDispose(menu);
            }
            return(menu);
        }
示例#2
0
文件: TagMenu.cs 项目: oqewok/gitter
        public TagMenu(Tag tag)
        {
            Verify.Argument.IsValidGitObject(tag, "tag");

            _tag = tag;

            Items.Add(GuiItemFactory.GetViewTreeItem <ToolStripMenuItem>(_tag));
            Items.Add(GuiItemFactory.GetArchiveItem <ToolStripMenuItem>(_tag));

            Items.Add(new ToolStripSeparator());             // interactive section

            Items.Add(GuiItemFactory.GetCheckoutRevisionItem <ToolStripMenuItem>(_tag, "{0} '{1}'"));
            Items.Add(GuiItemFactory.GetResetHeadHereItem <ToolStripMenuItem>(_tag));
            Items.Add(GuiItemFactory.GetRemoveTagItem <ToolStripMenuItem>(_tag, Resources.StrDelete));

            Items.Add(new ToolStripSeparator());             // copy to clipboard section

            var item = new ToolStripMenuItem(Resources.StrCopyToClipboard);

            item.DropDownItems.Add(GuiItemFactory.GetCopyToClipboardItem <ToolStripMenuItem>(Resources.StrName, tag.Name));
            item.DropDownItems.Add(GuiItemFactory.GetCopyToClipboardItem <ToolStripMenuItem>(Resources.StrFullName, tag.FullName));
            item.DropDownItems.Add(GuiItemFactory.GetCopyHashToClipboardItem <ToolStripMenuItem>(Resources.StrPosition, tag.Revision.Hash.ToString()));

            Items.Add(item);

            Items.Add(new ToolStripSeparator());

            Items.Add(GuiItemFactory.GetCreateBranchItem <ToolStripMenuItem>(_tag));
            Items.Add(GuiItemFactory.GetCreateTagItem <ToolStripMenuItem>(_tag));
        }
示例#3
0
        public BranchMenu(BranchBase branch)
        {
            Verify.Argument.IsValidGitObject(branch, "branch");

            _branch = branch;

            Items.Add(GuiItemFactory.GetViewReflogItem <ToolStripMenuItem>(_branch));
            Items.Add(GuiItemFactory.GetViewTreeItem <ToolStripMenuItem>(_branch));

            Items.Add(new ToolStripSeparator());             // interactive section

            Items.Add(GuiItemFactory.GetCheckoutRevisionItem <ToolStripMenuItem>(_branch, "{0} '{1}'"));
            Items.Add(GuiItemFactory.GetResetHeadHereItem <ToolStripMenuItem>(_branch));
            Items.Add(GuiItemFactory.GetRebaseHeadHereItem <ToolStripMenuItem>(_branch));
            Items.Add(GuiItemFactory.GetMergeItem <ToolStripMenuItem>(_branch));
            if (!branch.IsRemote)
            {
                Items.Add(GuiItemFactory.GetRenameBranchItem <ToolStripMenuItem>((Branch)_branch, "{0}"));
            }
            Items.Add(GuiItemFactory.GetRemoveBranchItem <ToolStripMenuItem>(_branch));
            if (!branch.IsRemote)
            {
                lock (branch.Repository.Remotes.SyncRoot)
                {
                    if (branch.Repository.Remotes.Count != 0)
                    {
                        Items.Add(new ToolStripSeparator());
                        var pushTo = new ToolStripMenuItem(Resources.StrPushTo, CachedResources.Bitmaps["ImgPush"]);
                        foreach (var remote in branch.Repository.Remotes)
                        {
                            pushTo.DropDownItems.Add(GuiItemFactory.GetPushBranchToRemoteItem <ToolStripMenuItem>((Branch)branch, remote));
                        }
                        Items.Add(pushTo);
                    }
                }
            }
            else
            {
            }
            Items.Add(new ToolStripSeparator());             // copy to clipboard section

            var item = new ToolStripMenuItem(Resources.StrCopyToClipboard);

            item.DropDownItems.Add(GuiItemFactory.GetCopyToClipboardItem <ToolStripMenuItem>(Resources.StrName, _branch.Name));
            item.DropDownItems.Add(GuiItemFactory.GetCopyToClipboardItem <ToolStripMenuItem>(Resources.StrFullName, _branch.FullName));
            item.DropDownItems.Add(GuiItemFactory.GetCopyHashToClipboardItem <ToolStripMenuItem>(Resources.StrPosition, _branch.Revision.HashString));

            Items.Add(item);

            Items.Add(new ToolStripSeparator());

            Items.Add(GuiItemFactory.GetCreateBranchItem <ToolStripMenuItem>(_branch));
            Items.Add(GuiItemFactory.GetCreateTagItem <ToolStripMenuItem>(_branch));
        }
示例#4
0
        public ReferencesMenu(Repository repository)
        {
            Verify.Argument.IsNotNull(repository, nameof(repository));

            Repository = repository;

            Items.Add(GuiItemFactory.GetShowReferencesViewItem <ToolStripMenuItem>());
            Items.Add(GuiItemFactory.GetRefreshAllReferencesListItem <ToolStripMenuItem>(repository));
            Items.Add(new ToolStripSeparator());
            Items.Add(GuiItemFactory.GetCreateBranchItem <ToolStripMenuItem>(repository));
            Items.Add(GuiItemFactory.GetCreateTagItem <ToolStripMenuItem>(repository));
        }
示例#5
0
        public ReflogRecordMenu(ReflogRecord reflogRecord)
        {
            Verify.Argument.IsNotNull(reflogRecord, nameof(reflogRecord));

            var revision = reflogRecord.Revision;

            Items.Add(GuiItemFactory.GetViewDiffItem <ToolStripMenuItem>(revision.GetDiffSource()));
            Items.Add(GuiItemFactory.GetViewTreeItem <ToolStripMenuItem>(revision));
            Items.Add(GuiItemFactory.GetSavePatchItem <ToolStripMenuItem>(revision));

            Items.Add(new ToolStripSeparator());

            Items.Add(GuiItemFactory.GetCheckoutRevisionItem <ToolStripMenuItem>(revision, "{0}"));
            Items.Add(GuiItemFactory.GetResetHeadHereItem <ToolStripMenuItem>(revision));
            Items.Add(GuiItemFactory.GetCherryPickItem <ToolStripMenuItem>(revision, "{0}"));

            Items.Add(new ToolStripSeparator());             // copy to clipboard section

            var item = new ToolStripMenuItem(Resources.StrCopyToClipboard);

            item.DropDownItems.Add(GuiItemFactory.GetCopyHashToClipboardItem <ToolStripMenuItem>(Resources.StrHash, revision.Hash.ToString()));
            item.DropDownItems.Add(GuiItemFactory.GetCopyHashToClipboardItem <ToolStripMenuItem>(Resources.StrTreeHash, revision.TreeHash.ToString()));
            item.DropDownItems.Add(GuiItemFactory.GetCopyToClipboardItem <ToolStripMenuItem>(Resources.StrMessage, reflogRecord.Message));
            item.DropDownItems.Add(GuiItemFactory.GetCopyToClipboardItem <ToolStripMenuItem>(Resources.StrSubject, revision.Subject));
            if (!string.IsNullOrEmpty(revision.Body))
            {
                item.DropDownItems.Add(GuiItemFactory.GetCopyToClipboardItem <ToolStripMenuItem>(Resources.StrBody, revision.Body));
            }
            if (revision.Committer != revision.Author)
            {
                item.DropDownItems.Add(GuiItemFactory.GetCopyToClipboardItem <ToolStripMenuItem>(Resources.StrCommitter, revision.Committer.Name));
                item.DropDownItems.Add(GuiItemFactory.GetCopyToClipboardItem <ToolStripMenuItem>(Resources.StrCommitterEmail, revision.Committer.Email));
            }
            item.DropDownItems.Add(GuiItemFactory.GetCopyToClipboardItem <ToolStripMenuItem>(Resources.StrAuthor, revision.Author.Name));
            item.DropDownItems.Add(GuiItemFactory.GetCopyToClipboardItem <ToolStripMenuItem>(Resources.StrAuthorEmail, revision.Author.Email));
            Items.Add(item);

            Items.Add(new ToolStripSeparator());

            Items.Add(GuiItemFactory.GetCreateBranchItem <ToolStripMenuItem>(reflogRecord.Revision));
            Items.Add(GuiItemFactory.GetCreateTagItem <ToolStripMenuItem>(reflogRecord.Revision));
        }
示例#6
0
        /// <summary>Create <see cref="RevisionMenu"/>.</summary>
        /// <param name="revision">Related <see cref="Revision"/>.</param>
        /// <exception cref="T:System.NullReferenceException"><paramref name="revision"/> == <c>null</c>.</exception>
        public RevisionMenu(Revision revision)
        {
            Verify.Argument.IsNotNull(revision, "revision");

            _revision = revision;

            Items.Add(GuiItemFactory.GetViewDiffItem <ToolStripMenuItem>(_revision.GetDiffSource()));
            Items.Add(GuiItemFactory.GetViewTreeItem <ToolStripMenuItem>(_revision));
            Items.Add(GuiItemFactory.GetSavePatchItem <ToolStripMenuItem>(_revision));
            Items.Add(GuiItemFactory.GetArchiveItem <ToolStripMenuItem>(_revision));

            Items.Add(new ToolStripSeparator());

            Items.Add(GuiItemFactory.GetCheckoutRevisionItem <ToolStripMenuItem>(_revision, "{0}"));
            Items.Add(GuiItemFactory.GetResetHeadHereItem <ToolStripMenuItem>(_revision));
            Items.Add(GuiItemFactory.GetRebaseHeadHereItem <ToolStripMenuItem>(_revision));
            Items.Add(GuiItemFactory.GetRevertItem <ToolStripMenuItem>(_revision));
            Items.Add(GuiItemFactory.GetCherryPickItem <ToolStripMenuItem>(_revision, "{0}"));

            Items.Add(new ToolStripSeparator());             // copy to clipboard section

            var item = new ToolStripMenuItem(Resources.StrCopyToClipboard);

            item.DropDownItems.Add(GuiItemFactory.GetCopyHashToClipboardItem <ToolStripMenuItem>(Resources.StrHash, revision.HashString));
            item.DropDownItems.Add(GuiItemFactory.GetCopyHashToClipboardItem <ToolStripMenuItem>(Resources.StrTreeHash, revision.TreeHashString));
            item.DropDownItems.Add(GuiItemFactory.GetCopyToClipboardItem <ToolStripMenuItem>(Resources.StrSubject, revision.Subject));
            if (!string.IsNullOrEmpty(revision.Body))
            {
                item.DropDownItems.Add(GuiItemFactory.GetCopyToClipboardItem <ToolStripMenuItem>(Resources.StrBody, revision.Body));
            }
            if (revision.Committer != revision.Author)
            {
                item.DropDownItems.Add(GuiItemFactory.GetCopyToClipboardItem <ToolStripMenuItem>(Resources.StrCommitter, revision.Committer.Name));
                item.DropDownItems.Add(GuiItemFactory.GetCopyToClipboardItem <ToolStripMenuItem>(Resources.StrCommitterEmail, revision.Committer.Email));
            }
            item.DropDownItems.Add(GuiItemFactory.GetCopyToClipboardItem <ToolStripMenuItem>(Resources.StrAuthor, revision.Author.Name));
            item.DropDownItems.Add(GuiItemFactory.GetCopyToClipboardItem <ToolStripMenuItem>(Resources.StrAuthorEmail, revision.Author.Email));
            item.DropDownItems.Add(GuiItemFactory.GetCopyToClipboardItem <ToolStripMenuItem>(Resources.StrPatch, () => Encoding.UTF8.GetString(revision.FormatPatch())));

            Items.Add(item);

            Items.Add(new ToolStripSeparator());

            Items.Add(GuiItemFactory.GetCreateBranchItem <ToolStripMenuItem>(_revision));

            var branches = _revision.References.GetAllBranches();

            if (branches.Count != 0)
            {
                if (branches.Count == 1)
                {
                    foreach (var branch in branches)
                    {
                        Items.Add(GuiItemFactory.GetRemoveBranchItem <ToolStripMenuItem>(branch, "{0} '{1}'"));
                    }
                }
                else
                {
                    var submenu = new ToolStripMenuItem(Resources.StrRemoveBranch);
                    foreach (var branch in branches)
                    {
                        submenu.DropDownItems.Add(GuiItemFactory.GetRemoveBranchItem <ToolStripMenuItem>(branch, "{1}"));
                    }
                    Items.Add(submenu);
                }
            }

            Items.Add(GuiItemFactory.GetCreateTagItem <ToolStripMenuItem>(_revision));

            var tags = _revision.References.GetTags();

            if (tags.Count != 0)
            {
                if (tags.Count == 1)
                {
                    foreach (var tag in tags)
                    {
                        Items.Add(GuiItemFactory.GetRemoveTagItem <ToolStripMenuItem>(tag, "{0} '{1}'"));
                    }
                }
                else
                {
                    var submenu = new ToolStripMenuItem(Resources.StrRemoveTag);
                    foreach (var tag in tags)
                    {
                        submenu.DropDownItems.Add(GuiItemFactory.GetRemoveTagItem <ToolStripMenuItem>(tag, "{1}"));
                    }
                    Items.Add(submenu);
                }
            }

            /*
             * Items.Add(new ToolStripSeparator()); // notes section
             *
             * Items.Add(GuiItemFactory.GetAddNoteItem<ToolStripMenuItem>(_revision));
             */
        }