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); }
private void OnItemContextMenuRequested(object sender, ItemContextMenuRequestEventArgs e) { var item = e.Item as ITreeItemListItem; if (item != null) { var file = item.TreeItem as TreeFile; if (file != null) { var menu = new ContextMenuStrip(); menu.Items.AddRange( new ToolStripItem[] { GuiItemFactory.GetOpenUrlItem <ToolStripMenuItem>(Resources.StrOpen, null, file.FullPath), GuiItemFactory.GetOpenUrlWithItem <ToolStripMenuItem>(Resources.StrOpenWith.AddEllipsis(), null, file.FullPath), GuiItemFactory.GetOpenUrlItem <ToolStripMenuItem>(Resources.StrOpenContainingFolder, null, Path.GetDirectoryName(file.FullPath)), new ToolStripSeparator(), new ToolStripMenuItem(Resources.StrCopyToClipboard, null, new ToolStripItem[] { GuiItemFactory.GetCopyToClipboardItem <ToolStripMenuItem>(Resources.StrFileName, file.Name), GuiItemFactory.GetCopyToClipboardItem <ToolStripMenuItem>(Resources.StrRelativePath, file.RelativePath), GuiItemFactory.GetCopyToClipboardItem <ToolStripMenuItem>(Resources.StrFullPath, file.FullPath), }), new ToolStripSeparator(), GuiItemFactory.GetBlameItem <ToolStripMenuItem>(Repository.Head, file.RelativePath), GuiItemFactory.GetPathHistoryItem <ToolStripMenuItem>(Repository.Head, file.RelativePath), }); Utility.MarkDropDownForAutoDispose(menu); e.ContextMenu = menu; return; } var directory = item.TreeItem as TreeDirectory; if (directory != null) { var menu = new ContextMenuStrip(); menu.Items.AddRange( new ToolStripItem[] { GuiItemFactory.GetOpenUrlItem <ToolStripMenuItem>(Resources.StrOpenInWindowsExplorer, null, directory.FullPath), GuiItemFactory.GetOpenCmdAtItem <ToolStripMenuItem>(Resources.StrOpenCommandLine, null, directory.FullPath), }); if (e.Item.Items.Count != 0) { menu.Items.AddRange( new ToolStripItem[] { new ToolStripSeparator(), GuiItemFactory.GetExpandAllItem <ToolStripMenuItem>(e.Item), GuiItemFactory.GetCollapseAllItem <ToolStripMenuItem>(e.Item), }); } menu.Items.AddRange( new ToolStripItem[] { new ToolStripSeparator(), GuiItemFactory.GetPathHistoryItem <ToolStripMenuItem>(Repository.Head, directory.RelativePath + "/"), }); Utility.MarkDropDownForAutoDispose(menu); e.ContextMenu = menu; return; } var commit = item.TreeItem as TreeCommit; if (commit != null) { var menu = new ContextMenuStrip(); menu.Items.AddRange( new ToolStripItem[] { GuiItemFactory.GetOpenAppItem <ToolStripMenuItem>( Resources.StrOpenWithGitter, null, Application.ExecutablePath, commit.FullPath.SurroundWithDoubleQuotes()), GuiItemFactory.GetOpenUrlItem <ToolStripMenuItem>(Resources.StrOpenInWindowsExplorer, null, commit.FullPath), GuiItemFactory.GetOpenCmdAtItem <ToolStripMenuItem>(Resources.StrOpenCommandLine, null, commit.FullPath), new ToolStripSeparator(), GuiItemFactory.GetPathHistoryItem <ToolStripMenuItem>(Repository.Head, commit.RelativePath), }); Utility.MarkDropDownForAutoDispose(menu); e.ContextMenu = menu; return; } } }