using System.IO; using System.Threading.Tasks; using Robust.Client.Graphics; namespace Robust.Client.UserInterface; /// /// Manager for opening of file dialogs. /// /// /// File dialogs are native to the OS being ran on. /// All operations are asynchronous to prevent locking up the main thread while the user makes his pick. /// [NotContentImplementable] public interface IFileDialogManager { /// /// Open a file dialog used for opening a single file and getting its filename. /// /// /// The file stream and name for the file the user opened. /// if the user canceled the action. /// /// Filters for file types that the user can select. /// What access is desired from the file operation. /// /// What sharing mode is desired from the file operation. /// If null is provided and is , /// is selected, otherwise . /// Task<(Stream?, string?)> GetFileAndName( FileDialogFilters? filters = null, FileAccess access = FileAccess.ReadWrite, FileShare? share = null); /// /// Open a file dialog used for getting the file name of the selected file. /// /// /// The file name for the file the user opened. /// if the user canceled the action. /// /// Task GetName( FileDialogFilters? filters = null, FileAccess access = FileAccess.ReadWrite, FileShare? share = null); /// /// Open a file dialog used for opening the selected file. /// /// /// The file stream for the file the user opened. /// if the user cancelled the action. /// /// Task OpenFile( FileDialogFilters? filters = null, FileAccess access = FileAccess.ReadWrite, FileShare? share = null); /// /// Open a file dialog used for saving a single file. /// /// /// The file stream the user chose to save to, and whether the file already existed. /// Null if the user canceled the action. /// /// Should we truncate an existing file to 0-size then write or append. /// Task<(Stream fileStream, bool alreadyExisted)?> SaveFile( FileDialogFilters? filters = null, bool truncate = true, FileAccess access = FileAccess.ReadWrite, FileShare share = FileShare.None); } /// /// Internal implementation interface used to connect and . /// internal interface IFileDialogManagerImplementation { Task OpenFile(FileDialogFilters? filters); Task SaveFile(FileDialogFilters? filters); }