コード例 #1
0
ファイル: TreeView.cs プロジェクト: oqewok/gitter
            public TreeMenu(ITreeSource treeSource, TreeDirectoryListItem item)
            {
                Verify.Argument.IsNotNull(item, "item");

                Items.Add(GuiItemFactory.GetExpandAllItem <ToolStripMenuItem>(item));
                Items.Add(GuiItemFactory.GetCollapseAllItem <ToolStripMenuItem>(item));

                if (treeSource != null)
                {
                    Items.Add(new ToolStripSeparator());
                    Items.Add(GuiItemFactory.GetPathHistoryItem <ToolStripMenuItem>(treeSource.Revision, item.DataContext));
                    Items.Add(new ToolStripSeparator());
                    Items.Add(GuiItemFactory.GetCheckoutPathItem <ToolStripMenuItem>(treeSource.Revision, item.DataContext));
                }
            }
コード例 #2
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)
 {
     if (Repository != null)
     {
         var menu = new ContextMenuStrip();
         menu.Items.AddRange(
             new ToolStripItem[]
         {
             GuiItemFactory.GetOpenUrlItem <ToolStripMenuItem>(Resources.StrOpenInWindowsExplorer, null, Repository.WorkingDirectory),
             GuiItemFactory.GetOpenCmdAtItem <ToolStripMenuItem>(Resources.StrOpenCommandLine, null, Repository.WorkingDirectory),
             new ToolStripSeparator(),
             GuiItemFactory.GetExpandAllItem <ToolStripMenuItem>(requestEventArgs.Item),
             GuiItemFactory.GetCollapseAllItem <ToolStripMenuItem>(requestEventArgs.Item),
         });
         Utility.MarkDropDownForAutoDispose(menu);
         return(menu);
     }
     else
     {
         return(null);
     }
 }
コード例 #3
0
        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;
                }
            }
        }