Add Open in Explorer to context menu

This commit is contained in:
Justin Aquadro 2013-12-18 23:12:42 -05:00
parent 2d70d2af10
commit a03537bb99
3 changed files with 28 additions and 5 deletions

View file

@ -729,8 +729,8 @@ namespace NBTExplorer.Controllers
ToolStripMenuItem itemExpandTree = new ToolStripMenuItem("Expand &Tree", null, _contextExpandTree_Click);
menu.Items.AddRange(new ToolStripItem[] {
itemCollapse, new ToolStripSeparator(), itemExpandChildren, itemExpandTree,
});
itemCollapse, new ToolStripSeparator(), itemExpandChildren, itemExpandTree,
});
}
else {
ToolStripMenuItem itemExpand = new ToolStripMenuItem("&Expand", null, _contextExpand_Click);
@ -751,6 +751,14 @@ namespace NBTExplorer.Controllers
menu.Items.Add(itemDn);
}
if (node is DirectoryDataNode) {
if (menu.Items.Count > 0)
menu.Items.Add(new ToolStripSeparator());
ToolStripMenuItem itemOpenExplorer = new ToolStripMenuItem("Open in E&xplorer", null, _contextOpenInExplorer_Click);
menu.Items.Add(itemOpenExplorer);
}
return (menu.Items.Count > 0) ? menu : null;
}
@ -791,6 +799,20 @@ namespace NBTExplorer.Controllers
MoveSelectionDown();
}
private void _contextOpenInExplorer_Click (object sender, EventArgs e)
{
if (_multiTree.SelectedNode != null && _multiTree.SelectedNode.Tag is DirectoryDataNode) {
DirectoryDataNode ddNode = _multiTree.SelectedNode.Tag as DirectoryDataNode;
try {
string path = (!Interop.IsWindows ? "file://" : "") + ddNode.NodeDirPath;
System.Diagnostics.Process.Start(path);
}
catch (Exception ex) {
MessageBox.Show(ex.Message, "Can't open directory", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
#region Capability Checking
#region Capability Predicates

View file

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.6.1.0")]
[assembly: AssemblyFileVersion("2.6.1.0")]
[assembly: AssemblyVersion("2.6.2.0")]
[assembly: AssemblyFileVersion("2.6.2.0")]

View file

@ -121,7 +121,8 @@ namespace NBTExplorer.Windows
if (_nodeTree.SelectedNode.Tag is DirectoryDataNode) {
DirectoryDataNode ddNode = _nodeTree.SelectedNode.Tag as DirectoryDataNode;
try {
System.Diagnostics.Process.Start(ddNode.NodeDirPath);
string path = (!Interop.IsWindows ? "file://" : "") + ddNode.NodeDirPath;
System.Diagnostics.Process.Start(path);
} catch (Win32Exception ex) {
MessageBox.Show(ex.Message, "Can't open directory", MessageBoxButtons.OK, MessageBoxIcon.Error);
}