示例#1
0
        public SubmoduleMenu(Submodule submodule)
        {
            Verify.Argument.IsValidGitObject(submodule, nameof(submodule));

            Submodule = submodule;

            Items.Add(GuiItemFactory.GetOpenAppItem <ToolStripMenuItem>(
                          Resources.StrOpenWithGitter, null, Application.ExecutablePath, Submodule.FullPath.SurroundWithDoubleQuotes()));
            Items.Add(GuiItemFactory.GetOpenUrlItem <ToolStripMenuItem>(
                          Resources.StrOpenInWindowsExplorer, null, Submodule.FullPath));
            Items.Add(GuiItemFactory.GetOpenCmdAtItem <ToolStripMenuItem>(
                          Resources.StrOpenCommandLine, null, Submodule.FullPath));

            Items.Add(new ToolStripSeparator());

            Items.Add(GuiItemFactory.GetUpdateSubmoduleItem <ToolStripMenuItem>(submodule));
            Items.Add(GuiItemFactory.GetSyncSubmoduleItem <ToolStripMenuItem>(submodule));

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

            var item = new ToolStripMenuItem(Resources.StrCopyToClipboard);

            item.DropDownItems.Add(GuiItemFactory.GetCopyToClipboardItem <ToolStripMenuItem>(Resources.StrName, Submodule.Name));
            item.DropDownItems.Add(GuiItemFactory.GetCopyToClipboardItem <ToolStripMenuItem>(Resources.StrPath, Submodule.Path));
            item.DropDownItems.Add(GuiItemFactory.GetCopyHashToClipboardItem <ToolStripMenuItem>(Resources.StrUrl, Submodule.Url));

            Items.Add(item);
        }
示例#2
0
        public StashedStateMenu(StashedState stashedState)
        {
            Verify.Argument.IsValidGitObject(stashedState, nameof(stashedState));

            StashedState = stashedState;

            Items.AddRange(
                new ToolStripItem[]
            {
                GuiItemFactory.GetViewDiffItem <ToolStripMenuItem>(StashedState.GetDiffSource()),
                GuiItemFactory.GetViewTreeItem <ToolStripMenuItem>(StashedState),
                GuiItemFactory.GetSavePatchItem <ToolStripMenuItem>(StashedState),
                new ToolStripSeparator(),
                GuiItemFactory.GetStashPopItem <ToolStripMenuItem>(StashedState),
                GuiItemFactory.GetStashApplyItem <ToolStripMenuItem>(StashedState),
                GuiItemFactory.GetStashDropItem <ToolStripMenuItem>(StashedState),
                new ToolStripSeparator(),
                GuiItemFactory.GetStashToBranchItem <ToolStripMenuItem>(StashedState),
                new ToolStripSeparator(),
                new ToolStripMenuItem(Resources.StrCopyToClipboard, null,
                                      new ToolStripItem[]
                {
                    GuiItemFactory.GetCopyToClipboardItem <ToolStripMenuItem>(Resources.StrName, ((IRevisionPointer)StashedState).Pointer),
                    GuiItemFactory.GetCopyHashToClipboardItem <ToolStripMenuItem>(Resources.StrHash, StashedState.Revision.Hash.ToString()),
                    GuiItemFactory.GetCopyToClipboardItem <ToolStripMenuItem>(Resources.StrSubject, StashedState.Revision.Subject),
                }),
            });
        }
示例#3
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));
        }
示例#4
0
            public override ContextMenuStrip CreateContextMenu(Revision revision)
            {
                var menu = new ContextMenuStrip();

                menu.Items.Add(GuiItemFactory.GetCopyHashToClipboardItem <ToolStripMenuItem>(Resources.StrCopyToClipboard, revision.TreeHashString));
                Utility.MarkDropDownForAutoDispose(menu);
                return(menu);
            }
示例#5
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));
        }
示例#6
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));
        }
示例#7
0
        /// <summary>Create <see cref="RemoteBranchMenu"/>.</summary>
        /// <param name="remoteTag">Remote branch, for which menu is generated.</param>
        public RemoteTagMenu(RemoteRepositoryTag remoteTag)
        {
            Verify.Argument.IsNotNull(remoteTag, nameof(remoteTag));
            Verify.Argument.IsFalse(remoteTag.IsDeleted, nameof(remoteTag),
                                    Resources.ExcObjectIsDeleted.UseAsFormat("RemoteTag"));

            RemoteTag = remoteTag;

            Items.Add(GuiItemFactory.GetRemoveRemoteTagItem <ToolStripMenuItem>(RemoteTag, "{0}"));

            var copyToClipboardItem = new ToolStripMenuItem(Resources.StrCopyToClipboard);

            copyToClipboardItem.DropDownItems.Add(GuiItemFactory.GetCopyToClipboardItem <ToolStripMenuItem>(
                                                      Resources.StrName, RemoteTag.Name));
            copyToClipboardItem.DropDownItems.Add(GuiItemFactory.GetCopyToClipboardItem <ToolStripMenuItem>(
                                                      Resources.StrFullName, RemoteTag.FullName));
            copyToClipboardItem.DropDownItems.Add(GuiItemFactory.GetCopyHashToClipboardItem <ToolStripMenuItem>(
                                                      Resources.StrPosition, RemoteTag.Hash.ToString()));
            Items.Add(copyToClipboardItem);
        }
示例#8
0
        /// <summary>Create <see cref="RemoteBranchMenu"/>.</summary>
        /// <param name="remoteBranch">Remote branch, for which menu is generated.</param>
        public RemoteBranchMenu(RemoteRepositoryBranch remoteBranch)
        {
            Verify.Argument.IsNotNull(remoteBranch, "remoteBranch");
            Verify.Argument.IsFalse(remoteBranch.IsDeleted, "remoteBranch",
                                    Resources.ExcObjectIsDeleted.UseAsFormat("RemoteBranch"));

            _remoteBranch = remoteBranch;

            Items.Add(GuiItemFactory.GetRemoveRemoteBranchItem <ToolStripMenuItem>(_remoteBranch, "{0}"));

            var copyToClipboardItem = new ToolStripMenuItem(Resources.StrCopyToClipboard);

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

            Items.Add(copyToClipboardItem);
        }
示例#9
0
        protected override void OnMouseDown(int x, int y, MouseButtons button)
        {
            switch (button)
            {
            case MouseButtons.Left:
            {
                var htr = HitTest(x, y);
                if (htr.Line != -1)
                {
                    if (_selOrigin == -1 || Control.ModifierKeys != Keys.Shift)
                    {
                        _selOrigin = htr.Line;
                        SetSelection(htr.Line);
                    }
                    else
                    {
                        SetSelection(_selOrigin, htr.Line);
                    }
                    _selecting = true;
                }
                else
                {
                    DropSelection();
                }
            }
            break;

            case MouseButtons.Right:
            {
                var htr = HitTest(x, y);
                if (htr.Line != -1)
                {
                    if (htr.Line < _selStart || htr.Line > _selEnd)
                    {
                        _selOrigin = htr.Line;
                        SetSelection(htr.Line);
                    }

                    var menu  = new ContextMenuStrip();
                    var lines = GetSelectedLines();
                    menu.Items.Add(GuiItemFactory.GetCopyToClipboardItem <ToolStripMenuItem>(
                                       Resources.StrCopyToClipboard,
                                       () => LinesToString(lines)));
                    bool sameCommit = true;
                    for (int i = 1; i < lines.Length; ++i)
                    {
                        if (lines[i].Commit != lines[0].Commit)
                        {
                            sameCommit = false;
                            break;
                        }
                    }
                    if (sameCommit)
                    {
                        var commit = lines[0].Commit;
                        menu.Items.Add(new ToolStripSeparator());
                        menu.Items.Add(GuiItemFactory.GetCopyHashToClipboardItem <ToolStripMenuItem>(Resources.StrHash, commit.Hash.ToString()));
                        menu.Items.Add(GuiItemFactory.GetCopyToClipboardItem <ToolStripMenuItem>(Resources.StrSummary, commit.Summary));
                        menu.Items.Add(GuiItemFactory.GetCopyToClipboardItem <ToolStripMenuItem>(Resources.StrAuthor, commit.Author));
                        if (commit.Author != commit.Committer)
                        {
                            menu.Items.Add(GuiItemFactory.GetCopyToClipboardItem <ToolStripMenuItem>(Resources.StrCommitter, commit.Committer));
                        }
                    }
                    Utility.MarkDropDownForAutoDispose(menu);
                    ShowContextMenu(menu, x, y);
                }
                else
                {
                    DropSelection();
                }
            }
            break;
            }
            base.OnMouseDown(x, y, button);
        }
示例#10
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));
             */
        }