From 8327f8a6bfe3b0715ea3f99244b584232b0fc473 Mon Sep 17 00:00:00 2001 From: BDisp Date: Mon, 20 Jul 2020 00:54:36 +0100 Subject: [PATCH] Fixes #813. It's now possible choose the volume through the directory TextField. --- Terminal.Gui/Windows/FileDialog.cs | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/Terminal.Gui/Windows/FileDialog.cs b/Terminal.Gui/Windows/FileDialog.cs index 81747cdb6..f0d75850a 100644 --- a/Terminal.Gui/Windows/FileDialog.cs +++ b/Terminal.Gui/Windows/FileDialog.cs @@ -46,15 +46,21 @@ namespace Terminal.Gui { internal void Reload () { - dirInfo = new DirectoryInfo (directory.ToString ()); - infos = (from x in dirInfo.GetFileSystemInfos () - where IsAllowed (x) - orderby (!x.Attributes.HasFlag (FileAttributes.Directory)) + x.Name - select (x.Name, x.Attributes.HasFlag (FileAttributes.Directory), false)).ToList (); - infos.Insert (0, ("..", true, false)); - top = 0; - selected = 0; - SetNeedsDisplay (); + try { + dirInfo = new DirectoryInfo (directory.ToString ()); + infos = (from x in dirInfo.GetFileSystemInfos () + where IsAllowed (x) + orderby (!x.Attributes.HasFlag (FileAttributes.Directory)) + x.Name + select (x.Name, x.Attributes.HasFlag (FileAttributes.Directory), false)).ToList (); + infos.Insert (0, ("..", true, false)); + top = 0; + selected = 0; + } catch (Exception) { + dirInfo = null; + infos.Clear (); + } finally { + SetNeedsDisplay (); + } } ustring directory; @@ -454,7 +460,10 @@ namespace Terminal.Gui { dirEntry = new TextField ("") { X = Pos.Right (dirLabel), Y = 1 + msgLines, - Width = Dim.Fill () - 1 + Width = Dim.Fill () - 1, + TextChanged = (e) => { + DirectoryPath = dirEntry.Text; + } }; Add (dirLabel, dirEntry);