فهرست منبع

Fixes #844. Now selects the correct Directory.

BDisp 5 سال پیش
والد
کامیت
d232715e62
2فایلهای تغییر یافته به همراه9 افزوده شده و 7 حذف شده
  1. 1 1
      Example/demo.cs
  2. 8 6
      Terminal.Gui/Windows/FileDialog.cs

+ 1 - 1
Example/demo.cs

@@ -305,7 +305,7 @@ static class Demo {
 		Application.Run (d);
 
 		if (!d.Canceled)
-			MessageBox.Query (50, 7, "Selected File", string.Join (", ", d.FilePaths), "Ok");
+			MessageBox.Query (50, 7, "Selected File", d.FilePaths.Count > 0 ? string.Join (", ", d.FilePaths) : d.FilePath, "Ok");
 	}
 
 	public static void ShowHex (Toplevel top)

+ 8 - 6
Terminal.Gui/Windows/FileDialog.cs

@@ -347,13 +347,15 @@ namespace Terminal.Gui {
 			}
 		}
 
-		internal bool ExecuteSelection ()
+		internal bool ExecuteSelection (bool isPrompt = false)
 		{
 			var isDir = infos [selected].Item2;
 
 			if (isDir) {
-				Directory = Path.GetFullPath (Path.Combine (Path.GetFullPath (Directory.ToString ()), infos [selected].Item1));
-				DirectoryChanged?.Invoke (Directory);
+				if (!isPrompt) {
+					Directory = Path.GetFullPath (Path.Combine (Path.GetFullPath (Directory.ToString ()), infos [selected].Item1));
+					DirectoryChanged?.Invoke (Directory);
+				}
 			} else {
 				FileChanged?.Invoke (infos [selected].Item1);
 				if (canChooseFiles) {
@@ -467,8 +469,8 @@ namespace Terminal.Gui {
 			};
 			Add (dirLabel, dirEntry);
 
-			this.nameFieldLabel = new Label ("Open: ") {
-				X = 6,
+			this.nameFieldLabel = new Label ("File(s): ") {
+				X = 3,
 				Y = 3 + msgLines,
 			};
 			nameEntry = new TextField ("") {
@@ -500,7 +502,7 @@ namespace Terminal.Gui {
 				IsDefault = true,
 			};
 			this.prompt.Clicked += () => {
-				dirListView.ExecuteSelection ();
+				dirListView.ExecuteSelection (true);
 				canceled = false;
 				Application.RequestStop ();
 			};