mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-27 00:07:58 +01:00
* Add class for detecting information about console in extensible way
* WIP - Create test for reordering
* Change Dictionary to List and preserve TreeBuilder order
* Add test to ensure branch expansion/status remains consistent despite reorder
* Cleanup code
* Fix regression when removed child was the selected one
* Revert "Add class for detecting information about console in extensible way"
This reverts commit 7e4253cf28.
* Code cleanup and enable nullable on Branch
* Remove color scheme and driver from Branch draw
* Add xunit context extensions
* Investigate codegen for xunit
* Getting closer to something that works
* Fix code generation
* Further explore code gen
* Generate all methods in single class for easier extensibility
* Simplify code gen by moving parameter creation to its own method
* Implement asserts A-I
* Add remaining assert calls that are not obsolete
* Fix unit test
* Roll back versions to be compatible with CI version of csharp
* Handle params and ref etc
* Fix null warning
* WIP - start to add integration tests for FileDialog
* Add ability to tab focus to specific control with simple one line delegate
* Clarify test criteria
* Add unit tests for Ok and other ways of canceling dialog
* Fix other buttons also triggering save
* Fix for linux environment tests
* Fix for linux again
* Fix application null race condition - add better way of knowing if stuff is finished
* Better fix for shutdown detection
* Add test that shows #4026 is not an issue
* Switch to `_fileSystem.Directory.GetLogicalDrives ()`
* Don't show duplicate MyDocuments etc
71 lines
2.2 KiB
C#
71 lines
2.2 KiB
C#
//
|
|
// 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.IO.Abstractions;
|
|
using Terminal.Gui.Resources;
|
|
|
|
namespace Terminal.Gui;
|
|
|
|
/// <summary>The <see cref="SaveDialog"/> provides an interactive dialog box for users to pick a file to save.</summary>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// To use, create an instance of <see cref="SaveDialog"/>, and pass it to
|
|
/// <see cref="Application.Run(Toplevel, Func{Exception, bool})"/>. This will run the dialog modally, and when this returns,
|
|
/// the <see cref="FileName"/>property will contain the selected file name or null if the user canceled.
|
|
/// </para>
|
|
/// </remarks>
|
|
public class SaveDialog : FileDialog
|
|
{
|
|
/// <summary>Initializes a new <see cref="SaveDialog"/>.</summary>
|
|
public SaveDialog ()
|
|
{
|
|
Style.OkButtonText = Strings.btnSave;
|
|
}
|
|
|
|
internal SaveDialog (IFileSystem fileSystem) : base (fileSystem)
|
|
{
|
|
Style.OkButtonText = Strings.btnSave;
|
|
}
|
|
/// <summary>
|
|
/// Gets the name of the file the user selected for saving, or null if the user canceled the
|
|
/// <see cref="SaveDialog"/>.
|
|
/// </summary>
|
|
/// <value>The name of the file.</value>
|
|
public string FileName => Canceled ? null : Path;
|
|
|
|
/// <summary>Gets the default title for the <see cref="SaveDialog"/>.</summary>
|
|
/// <returns></returns>
|
|
protected override string GetDefaultTitle ()
|
|
{
|
|
List<string> titleParts = [Strings.fdSave]
|
|
;
|
|
|
|
if (MustExist)
|
|
{
|
|
titleParts.Add (Strings.fdExisting);
|
|
}
|
|
|
|
switch (OpenMode)
|
|
{
|
|
case OpenMode.File:
|
|
titleParts.Add (Strings.fdFile);
|
|
|
|
break;
|
|
case OpenMode.Directory:
|
|
titleParts.Add (Strings.fdDirectory);
|
|
|
|
break;
|
|
}
|
|
|
|
return string.Join (' ', titleParts);
|
|
}
|
|
}
|