From c98197cf2fb5cd4904a6b64b925c9d9e121aacb6 Mon Sep 17 00:00:00 2001 From: Justin Dearing Date: Tue, 22 Jul 2008 02:45:22 +0000 Subject: [PATCH] You can now "Open containing folder in explorer" from the Project pad. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@3242 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- AddIns/ICSharpCode.SharpDevelop.addin | 7 +++- .../Src/Commands/FileTabStripCommands.cs | 2 +- .../Commands/DefaultFileNodeCommands.cs | 41 ++++++++++++++++++- 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/AddIns/ICSharpCode.SharpDevelop.addin b/AddIns/ICSharpCode.SharpDevelop.addin index d091d48bcb..a162c8db47 100644 --- a/AddIns/ICSharpCode.SharpDevelop.addin +++ b/AddIns/ICSharpCode.SharpDevelop.addin @@ -366,6 +366,9 @@ + - + class = "ICSharpCode.SharpDevelop.Commands.TabStrip.OpenFolderContainingFile"/> diff --git a/src/Main/Base/Project/Src/Commands/FileTabStripCommands.cs b/src/Main/Base/Project/Src/Commands/FileTabStripCommands.cs index 2d6fb63e9f..2d93942114 100644 --- a/src/Main/Base/Project/Src/Commands/FileTabStripCommands.cs +++ b/src/Main/Base/Project/Src/Commands/FileTabStripCommands.cs @@ -80,7 +80,7 @@ namespace ICSharpCode.SharpDevelop.Commands.TabStrip /// /// Opens the containing folder in the clipboard. /// - public class FileContainingFolderInExplorer : AbstractMenuCommand + public class OpenFolderContainingFile : AbstractMenuCommand { public override void Run() { diff --git a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/DefaultFileNodeCommands.cs b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/DefaultFileNodeCommands.cs index eb0105f156..6ae73ac531 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/DefaultFileNodeCommands.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/DefaultFileNodeCommands.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.Windows.Forms; @@ -50,23 +51,26 @@ namespace ICSharpCode.SharpDevelop.Project.Commands SolutionItemNode solutionItemNode = ProjectBrowserPad.Instance.SelectedNode as SolutionItemNode; if (solutionItemNode != null) { OpenWith(solutionItemNode.FileName); + return; } FileNode fileNode = ProjectBrowserPad.Instance.SelectedNode as FileNode; if (fileNode != null) { OpenWith(fileNode.FileName); + return; } ProjectNode projectNode = ProjectBrowserPad.Instance.SelectedNode as ProjectNode; if (projectNode != null) { OpenWith(projectNode.Project.FileName); + return; } } /// /// Shows the OpenWith dialog for the specified file. /// - public static void OpenWith(string fileName) + static void OpenWith(string fileName) { var codons = DisplayBindingService.GetCodonsPerFileName(fileName); int defaultCodonIndex = codons.IndexOf(DisplayBindingService.GetDefaultCodonPerFileName(fileName)); @@ -78,6 +82,41 @@ namespace ICSharpCode.SharpDevelop.Project.Commands } } + /// + /// Opens the containing folder in the clipboard. + /// + public class OpenFolderContainingFile : AbstractMenuCommand + { + public override void Run() + { + SolutionItemNode solutionItemNode = ProjectBrowserPad.Instance.SelectedNode as SolutionItemNode; + if (solutionItemNode != null) { + OpenContainingFolderInExplorer(solutionItemNode.FileName); + return; + } + + FileNode fileNode = ProjectBrowserPad.Instance.SelectedNode as FileNode; + if (fileNode != null) { + OpenContainingFolderInExplorer(fileNode.FileName); + return; + } + + ProjectNode projectNode = ProjectBrowserPad.Instance.SelectedNode as ProjectNode; + if (projectNode != null) { + OpenContainingFolderInExplorer(projectNode.Project.FileName); + return; + } + } + + void OpenContainingFolderInExplorer(string fileName) + { + if (File.Exists(fileName)) { + string folder = Path.GetDirectoryName(fileName); + Process.Start(folder); + } + } + } + public class ExcludeFileFromProject : AbstractMenuCommand { public static void ExcludeFileNode(FileNode fileNode)