#nullable disable
//
// FileDialog.cs: File system dialogs for open and save
//
// TODO:
// * Add directory selector
// * Implement subclasses
// * Figure out why message text does not show
// * Remove the extra space when message does not show
// * Use a line separator to show the file listing, so we can use same colors as the rest
// * DirListView: Add mouse support
using System.Collections.ObjectModel;
namespace Terminal.Gui.Views;
/// Provides an interactive for selecting files or directories for opening
///
///
/// The open dialog can be used to select files for opening, it can be configured to allow multiple items to be
/// selected (based on the AllowsMultipleSelection) variable, and you can control whether this should allow files or
/// directories to be selected.
///
///
/// To use, create an instance of , and pass it to
/// . This will run the dialog modally, and when this returns,
/// the list of files will be available on the property.
///
/// To select more than one file, users can use the space key, or CTRL-T.
///
public class OpenDialog : FileDialog
{
/// Initializes a new .
public OpenDialog () { }
/// Returns the selected files, or an empty list if nothing has been selected
/// The file paths.
public IReadOnlyList FilePaths =>
Canceled ? Enumerable.Empty ().ToList ().AsReadOnly () :
AllowsMultipleSelection ? MultiSelected : new ReadOnlyCollection (new [] { Path });
///
public override OpenMode OpenMode
{
get => base.OpenMode;
set
{
base.OpenMode = value;
Style.OkButtonText = value == OpenMode.File ? Strings.btnOpen :
value == OpenMode.Directory ? Strings.fdSelectFolder : Strings.fdSelectMixed;
}
}
}