Hold down Ctrl to avoid using folder browse dlg

That dialog just plain sucks...you can't type in a path, for instance.
This commit is contained in:
flarn2006 2013-12-17 19:17:15 -05:00
parent 366ec3fe9e
commit 400eb1f80a

View file

@ -162,13 +162,30 @@ namespace NBTExplorer.Windows
if (!ConfirmAction("Open new folder anyway?")) if (!ConfirmAction("Open new folder anyway?"))
return; return;
using (FolderBrowserDialog ofd = new FolderBrowserDialog()) { if ((ModifierKeys & Keys.Control) == 0) {
if (_openFolderPath != null) // if the user isn't holding Control, use the standard folder browser dialog
ofd.SelectedPath = _openFolderPath; using (FolderBrowserDialog ofd = new FolderBrowserDialog()) {
if (_openFolderPath != null)
ofd.SelectedPath = _openFolderPath;
if (ofd.ShowDialog() == DialogResult.OK) { if (ofd.ShowDialog() == DialogResult.OK) {
_openFolderPath = ofd.SelectedPath; _openFolderPath = ofd.SelectedPath;
OpenPaths(new string[] { ofd.SelectedPath }); OpenPaths(new string[] { ofd.SelectedPath });
}
}
} else {
// otherwise, use a file open dialog and open whichever directory has the selected file
using (OpenFileDialog ofd = new OpenFileDialog()) {
ofd.Title = "Select any file in the directory to open";
ofd.Filter = "All files (*.*)|*.*";
if (_openFolderPath != null)
ofd.InitialDirectory = _openFolderPath;
if (ofd.ShowDialog() == DialogResult.OK) {
_openFolderPath = Path.GetDirectoryName(ofd.FileName);
OpenPaths(new string[] { _openFolderPath });
}
} }
} }
@ -749,7 +766,7 @@ namespace NBTExplorer.Windows
{ {
OpenFile(); OpenFile();
} }
private void _menuItemOpenFolder_Click (object sender, EventArgs e) private void _menuItemOpenFolder_Click (object sender, EventArgs e)
{ {
OpenFolder(); OpenFolder();