示例#1
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));
        }
示例#2
0
            public override ContextMenuStrip CreateContextMenu(Revision revision)
            {
                var menu = new ContextMenuStrip();

                menu.Items.Add(GuiItemFactory.GetViewTreeItem <ToolStripMenuItem>(revision));
                menu.Items.Add(GuiItemFactory.GetSavePatchItem <ToolStripMenuItem>(revision));
                menu.Items.Add(GuiItemFactory.GetArchiveItem <ToolStripMenuItem>(revision));
                menu.Items.Add(new ToolStripSeparator());
                menu.Items.Add(GuiItemFactory.GetCopyHashToClipboardItem <ToolStripMenuItem>(Resources.StrCopyToClipboard, revision.HashString));
                Utility.MarkDropDownForAutoDispose(menu);
                return(menu);
            }
示例#3
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));
             */
        }