Rename FileDialog2 to FileDialog

This commit is contained in:
tznind
2023-03-17 23:27:18 +00:00
parent 62a32574f5
commit bfd596a741
10 changed files with 37 additions and 37 deletions

View File

@@ -8,7 +8,7 @@ namespace Terminal.Gui {
/// <summary>
/// Describes a requirement on what <see cref="FileInfo"/> can be selected
/// in a <see cref="FileDialog2"/>.
/// in a <see cref="FileDialog"/>.
/// </summary>
public class AllowedType {

View File

@@ -20,19 +20,19 @@ namespace Terminal.Gui {
/// Modal dialog for selecting files/directories. Has auto-complete and expandable
/// navigation pane (Recent, Root drives etc).
/// </summary>
public partial class FileDialog2 : Dialog {
public partial class FileDialog : Dialog {
/// <summary>
/// Gets settings for controlling how visual elements behave. Style changes should
/// be made before the <see cref="Dialog"/> is loaded and shown to the user for the
/// first time.
/// </summary>
public FileDialog2Style Style { get; } = new FileDialog2Style ();
public FileDialogStyle Style { get; } = new FileDialogStyle ();
/// <summary>
/// Stores style settings for <see cref="FileDialog2"/>.
/// Stores style settings for <see cref="FileDialog"/>.
/// </summary>
public class FileDialog2Style {
public class FileDialogStyle {
/// <summary>
/// Gets or sets the header text displayed in the Filename column of the files table.
@@ -190,9 +190,9 @@ namespace Terminal.Gui {
/// <summary>
/// Initializes a new instance of the <see cref="FileDialog2"/> class.
/// Initializes a new instance of the <see cref="FileDialog"/> class.
/// </summary>
public FileDialog2 ()
public FileDialog ()
{
var lblPath = new Label (">");
this.btnOk = new Button (Style.OkButtonText) {
@@ -1415,7 +1415,7 @@ namespace Terminal.Gui {
if (fsi is FileInfo fi) {
this.MachineReadableLength = fi.Length;
this.HumanReadableLength = GetHumanReadableFileSize (this.MachineReadableLength);
this.DateModified = FileDialog2.UseUtcDates ? File.GetLastWriteTimeUtc (fi.FullName) : File.GetLastWriteTime (fi.FullName);
this.DateModified = FileDialog.UseUtcDates ? File.GetLastWriteTimeUtc (fi.FullName) : File.GetLastWriteTime (fi.FullName);
this.Type = fi.Extension;
} else {
this.HumanReadableLength = string.Empty;
@@ -1461,7 +1461,7 @@ namespace Terminal.Gui {
StringComparer.InvariantCultureIgnoreCase);
}
internal object GetOrderByValue (FileDialog2 dlg, string columnName)
internal object GetOrderByValue (FileDialog dlg, string columnName)
{
if (dlg.Style.FilenameColumnName == columnName)
return this.FileSystemInfo.Name;
@@ -1520,7 +1520,7 @@ namespace Terminal.Gui {
object oLockFound = new object ();
CancellationTokenSource token = new CancellationTokenSource ();
public SearchState (DirectoryInfo dir, FileDialog2 parent, string searchTerms) : base (dir, parent)
public SearchState (DirectoryInfo dir, FileDialog parent, string searchTerms) : base (dir, parent)
{
parent.SearchMatcher.Initialize (searchTerms);
Children = new FileSystemInfoStats [0];
@@ -1596,7 +1596,7 @@ namespace Terminal.Gui {
}
lock (oLockFound) {
if (found.Count >= FileDialog2.MaxSearchResults) {
if (found.Count >= FileDialog.MaxSearchResults) {
finished = true;
return;
}
@@ -1626,8 +1626,8 @@ namespace Terminal.Gui {
internal class FileDialogState {
public FileSystemInfoStats Selected { get; set; }
protected readonly FileDialog2 Parent;
public FileDialogState (DirectoryInfo dir, FileDialog2 parent)
protected readonly FileDialog Parent;
public FileDialogState (DirectoryInfo dir, FileDialog parent)
{
this.Directory = dir;
Parent = parent;
@@ -1816,7 +1816,7 @@ namespace Terminal.Gui {
}
var path = this.Text.ToString ();
var last = path.LastIndexOfAny (FileDialog2.separators);
var last = path.LastIndexOfAny (FileDialog.separators);
if (last == -1 || suggestions.Length == 0 || last >= path.Length - 1) {
this.currentFragment = null;
@@ -1917,9 +1917,9 @@ namespace Terminal.Gui {
internal class FileDialogHistory {
private Stack<FileDialogState> back = new Stack<FileDialogState> ();
private Stack<FileDialogState> forward = new Stack<FileDialogState> ();
private FileDialog2 dlg;
private FileDialog dlg;
public FileDialogHistory (FileDialog2 dlg)
public FileDialogHistory (FileDialog dlg)
{
this.dlg = dlg;
}
@@ -2026,13 +2026,13 @@ namespace Terminal.Gui {
}
private class FileDialogSorter {
private readonly FileDialog2 dlg;
private readonly FileDialog dlg;
private TableView tableView;
private DataColumn currentSort = null;
private bool currentSortIsAsc = true;
public FileDialogSorter (FileDialog2 dlg, TableView tableView)
public FileDialogSorter (FileDialog dlg, TableView tableView)
{
this.dlg = dlg;
this.tableView = tableView;

View File

@@ -55,7 +55,7 @@ namespace Terminal.Gui {
/// To select more than one file, users can use the spacebar, or control-t.
/// </para>
/// </remarks>
public class OpenDialog : FileDialog2 {
public class OpenDialog : FileDialog {
/// <summary>
/// Initializes a new <see cref="OpenDialog"/>.

View File

@@ -27,7 +27,7 @@ namespace Terminal.Gui {
/// null if the user canceled.
/// </para>
/// </remarks>
public class SaveDialog : FileDialog2 {
public class SaveDialog : FileDialog {
/// <summary>
/// Initializes a new <see cref="SaveDialog"/>.
/// </summary>

View File

@@ -3,7 +3,7 @@
"Application.QuitKey": {
"Key": "Esc"
},
"FileDialog2.MaxSearchResults" : 10000,
"FileDialog.MaxSearchResults" : 10000,
"AppSettings": {
"UICatalog.StatusBar": true,
"ConfigurationEditor.EditorColorScheme": {

View File

@@ -393,7 +393,7 @@ namespace UICatalog.Scenarios {
private void Open ()
{
var ofd = new FileDialog2 () {
var ofd = new FileDialog () {
AllowedTypes = new List<AllowedType> { new AllowedType("Comma Separated Values (.csv)", ".csv") }
};
ofd.Style.OkButtonText = "Open";

View File

@@ -8,9 +8,9 @@ using Terminal.Gui.Graphs;
using static Terminal.Gui.OpenDialog;
namespace UICatalog.Scenarios {
[ScenarioMetadata (Name: "FileDialog2", Description: "Demonstrates how to the FileDialog2 class")]
[ScenarioMetadata (Name: "FileDialog", Description: "Demonstrates how to the FileDialog class")]
[ScenarioCategory ("Dialogs")]
public class FileDialog2Examples : Scenario {
public class FileDialogExamples : Scenario {
private CheckBox cbMustExist;
private CheckBox cbIcons;
private CheckBox cbUseColors;
@@ -104,7 +104,7 @@ namespace UICatalog.Scenarios {
private void SetupHandler (Button btn)
{
btn.Clicked += () => {
var fd = new FileDialog2() {
var fd = new FileDialog() {
OpenMode = Enum.Parse<OpenMode>(
rgOpenMode.RadioLabels[rgOpenMode.SelectedItem].ToString()),
MustExist = cbMustExist.Checked ?? false,
@@ -154,7 +154,7 @@ namespace UICatalog.Scenarios {
};
}
private class CaseSensitiveSearchMatcher : FileDialog2.ISearchMatcher {
private class CaseSensitiveSearchMatcher : FileDialog.ISearchMatcher {
private string terms;
public void Initialize (string terms)

View File

@@ -6,7 +6,7 @@ using Xunit;
namespace Terminal.Gui.Core {
public class FileDialog2Tests {
public class FileDialogTests {
[Fact, AutoInitShutdown]
public void OnLoad_TextBoxIsFocused ()
@@ -14,14 +14,14 @@ namespace Terminal.Gui.Core {
var dlg = GetInitializedFileDialog ();
// First focused is ContentView :(
Assert.NotNull (dlg.Focused.Focused);
Assert.IsType<FileDialog2.TextFieldWithAppendAutocomplete> (dlg.Focused.Focused);
Assert.IsType<FileDialog.TextFieldWithAppendAutocomplete> (dlg.Focused.Focused);
}
[Fact, AutoInitShutdown]
public void DirectTyping_Allowed ()
{
var dlg = GetInitializedFileDialog ();
var tf = dlg.Subviews [0].Subviews.OfType<FileDialog2.TextFieldWithAppendAutocomplete> ().Single ();
var tf = dlg.Subviews [0].Subviews.OfType<FileDialog.TextFieldWithAppendAutocomplete> ().Single ();
tf.ClearAllSelection ();
tf.CursorPosition = tf.Text.Length;
Assert.True (tf.HasFocus);
@@ -101,7 +101,7 @@ namespace Terminal.Gui.Core {
[Fact, AutoInitShutdown]
public void Autocomplete_NoSuggestion_WhenTextMatchesExactly ()
{
var tb = new FileDialog2.TextFieldWithAppendAutocomplete ();
var tb = new FileDialog.TextFieldWithAppendAutocomplete ();
ForceFocus (tb);
tb.Text = "/bob/fish";
@@ -117,7 +117,7 @@ namespace Terminal.Gui.Core {
[Fact, AutoInitShutdown]
public void Autocomplete_AcceptSuggstion ()
{
var tb = new FileDialog2.TextFieldWithAppendAutocomplete ();
var tb = new FileDialog.TextFieldWithAppendAutocomplete ();
ForceFocus (tb);
tb.Text = @"/bob/fi";
@@ -136,19 +136,19 @@ namespace Terminal.Gui.Core {
hasFocus.SetValue (v, true);
}
private FileDialog2.TextFieldWithAppendAutocomplete GetTextField (FileDialog2 dlg = null)
private FileDialog.TextFieldWithAppendAutocomplete GetTextField (FileDialog dlg = null)
{
if (dlg == null) {
dlg = GetInitializedFileDialog ();
}
// First view of a Dialog is ContentView
return dlg.Subviews [0].Subviews.OfType<FileDialog2.TextFieldWithAppendAutocomplete> ().Single ();
return dlg.Subviews [0].Subviews.OfType<FileDialog.TextFieldWithAppendAutocomplete> ().Single ();
}
private FileDialog2 GetInitializedFileDialog ()
private FileDialog GetInitializedFileDialog ()
{
var dlg = new FileDialog2 ();
var dlg = new FileDialog ();
dlg.BeginInit ();
dlg.EndInit ();
Application.Begin (dlg);

View File

@@ -581,7 +581,7 @@ namespace Terminal.Gui.TopLevelTests {
public void FileDialog_FileSystemWatcher ()
{
for (int i = 0; i < 8; i++) {
var fd = new FileDialog2 ();
var fd = new FileDialog ();
fd.Ready += () => Application.RequestStop ();
Application.Run (fd);
}

View File

@@ -667,7 +667,7 @@ namespace Terminal.Gui.TopLevelTests {
public void FileDialog_FileSystemWatcher ()
{
for (int i = 0; i < 8; i++) {
var fd = new FileDialog2 ();
var fd = new FileDialog ();
fd.Ready += () => Application.RequestStop ();
Application.Run (fd);
}