Browse Source

Add base PickerOptions + some formatting

pull/8303/head
Max Katz 4 years ago
parent
commit
daa071e1f9
  1. 2
      src/Avalonia.Base/Platform/Storage/FilePickerFileType.cs
  2. 16
      src/Avalonia.Base/Platform/Storage/FilePickerOpenOptions.cs
  3. 12
      src/Avalonia.Base/Platform/Storage/FilePickerSaveOptions.cs
  4. 12
      src/Avalonia.Base/Platform/Storage/FolderPickerOpenOptions.cs
  5. 1
      src/Avalonia.Base/Platform/Storage/IStorageBookmarkItem.cs
  6. 6
      src/Avalonia.Base/Platform/Storage/IStorageFile.cs
  7. 3
      src/Avalonia.Base/Platform/Storage/IStorageFolder.cs
  8. 4
      src/Avalonia.Base/Platform/Storage/IStorageItem.cs
  9. 8
      src/Avalonia.Base/Platform/Storage/IStorageProvider.cs
  10. 17
      src/Avalonia.Base/Platform/Storage/PickerOptions.cs
  11. 4
      src/Avalonia.Base/Platform/Storage/StorageItemProperties.cs

2
src/Avalonia.Base/Platform/Storage/FilePickerFileType.cs

@ -5,7 +5,7 @@ namespace Avalonia.Platform.Storage;
/// <summary>
/// Represents a name mapped to the associated file types (extensions).
/// </summary>
public class FilePickerFileType
public sealed class FilePickerFileType
{
public FilePickerFileType(string name)
{

16
src/Avalonia.Base/Platform/Storage/FilePickerOpenOptions.cs

@ -5,25 +5,15 @@ namespace Avalonia.Platform.Storage;
/// <summary>
/// Options class for <see cref="IStorageProvider.OpenFilePickerAsync"/> method.
/// </summary>
public class FilePickerOpenOptions
public class FilePickerOpenOptions : PickerOptions
{
/// <summary>
/// Gets or sets the text that appears in the title bar of a file dialog.
/// </summary>
public string? Title { get; set; }
/// <summary>
/// Gets or sets the initial location where the file open picker looks for files to present to the user.
/// </summary>
public IStorageFolder? SuggestedStartLocation { get; set; }
/// <summary>
/// Gets or sets an option indicating whether open picker allows users to select multiple files.
/// </summary>
public bool AllowMultiple { get; set; }
/// <summary>
/// Gets or sets the collection of file types that the file open picker displays.
/// </summary>
public IReadOnlyList<FilePickerFileType>? FileTypeFilter { get; set; }
}
}

12
src/Avalonia.Base/Platform/Storage/FilePickerSaveOptions.cs

@ -5,13 +5,8 @@ namespace Avalonia.Platform.Storage;
/// <summary>
/// Options class for <see cref="IStorageProvider.SaveFilePickerAsync"/> method.
/// </summary>
public class FilePickerSaveOptions
public class FilePickerSaveOptions : PickerOptions
{
/// <summary>
/// Gets or sets the text that appears in the title bar of a file dialog.
/// </summary>
public string? Title { get; set; }
/// <summary>
/// Gets or sets the file name that the file save picker suggests to the user.
/// </summary>
@ -22,11 +17,6 @@ public class FilePickerSaveOptions
/// </summary>
public string? DefaultExtension { get; set; }
/// <summary>
/// Gets or sets the initial location where the file open picker looks for files to present to the user.
/// </summary>
public IStorageFolder? SuggestedStartLocation { get; set; }
/// <summary>
/// Gets or sets the collection of valid file types that the user can choose to assign to a file.
/// </summary>

12
src/Avalonia.Base/Platform/Storage/FolderPickerOpenOptions.cs

@ -3,20 +3,10 @@
/// <summary>
/// Options class for <see cref="IStorageProvider.OpenFolderPickerAsync"/> method.
/// </summary>
public class FolderPickerOpenOptions
public class FolderPickerOpenOptions : PickerOptions
{
/// <summary>
/// Gets or sets the text that appears in the title bar of a folder dialog.
/// </summary>
public string? Title { get; set; }
/// <summary>
/// Gets or sets an option indicating whether open picker allows users to select multiple folders.
/// </summary>
public bool AllowMultiple { get; set; }
/// <summary>
/// Gets or sets the initial location where the file open picker looks for files to present to the user.
/// </summary>
public IStorageFolder? SuggestedStartLocation { get; set; }
}

1
src/Avalonia.Base/Platform/Storage/IStorageBookmarkItem.cs

@ -17,5 +17,4 @@ public interface IStorageBookmarkFile : IStorageFile, IStorageBookmarkItem
[NotClientImplementable]
public interface IStorageBookmarkFolder : IStorageFolder, IStorageBookmarkItem
{
}

6
src/Avalonia.Base/Platform/Storage/IStorageFile.cs

@ -14,7 +14,7 @@ public interface IStorageFile : IStorageItem
/// Returns true, if file is readable.
/// </summary>
bool CanOpenRead { get; }
/// <summary>
/// Opens a stream for read access.
/// </summary>
@ -24,9 +24,9 @@ public interface IStorageFile : IStorageItem
/// Returns true, if file is writeable.
/// </summary>
bool CanOpenWrite { get; }
/// <summary>
/// Opens stream for writing to the file.
/// </summary>
Task<Stream> OpenWrite();
}
}

3
src/Avalonia.Base/Platform/Storage/IStorageFolder.cs

@ -8,5 +8,4 @@ namespace Avalonia.Platform.Storage;
[NotClientImplementable]
public interface IStorageFolder : IStorageItem
{
}
}

4
src/Avalonia.Base/Platform/Storage/IStorageItem.cs

@ -27,7 +27,7 @@ public interface IStorageItem : IDisposable
/// Browser and iOS backends might return relative uris.
/// </remarks>
bool TryGetUri([NotNullWhen(true)] out Uri? uri);
/// <summary>
/// Gets the basic properties of the current item.
/// </summary>
@ -37,7 +37,7 @@ public interface IStorageItem : IDisposable
/// Returns true is item can be bookmarked and reused later.
/// </summary>
bool CanBookmark { get; }
/// <summary>
/// Saves items to a bookmark.
/// </summary>

8
src/Avalonia.Base/Platform/Storage/IStorageProvider.cs

@ -11,7 +11,7 @@ public interface IStorageProvider
/// Returns true if it's possible to open file picker on the current platform.
/// </summary>
bool CanOpen { get; }
/// <summary>
/// Opens file picker dialog.
/// </summary>
@ -22,7 +22,7 @@ public interface IStorageProvider
/// Returns true if it's possible to open save file picker on the current platform.
/// </summary>
bool CanSave { get; }
/// <summary>
/// Opens save file picker dialog.
/// </summary>
@ -33,13 +33,13 @@ public interface IStorageProvider
/// Returns true if it's possible to open folder picker on the current platform.
/// </summary>
bool CanPickFolder { get; }
/// <summary>
/// Opens folder picker dialog.
/// </summary>
/// <returns>Array of selected <see cref="IStorageFolder"/> or empty collection if user canceled the dialog.</returns>
Task<IReadOnlyList<IStorageFolder>> OpenFolderPickerAsync(FolderPickerOpenOptions options);
/// <summary>
/// Open <see cref="IStorageBookmarkFile"/> from the bookmark ID.
/// </summary>

17
src/Avalonia.Base/Platform/Storage/PickerOptions.cs

@ -0,0 +1,17 @@
namespace Avalonia.Platform.Storage;
/// <summary>
/// Common options for <see cref="IStorageProvider.OpenFolderPickerAsync"/>, <see cref="IStorageProvider.OpenFilePickerAsync"/> and <see cref="IStorageProvider.SaveFilePickerAsync"/> methods.
/// </summary>
public class PickerOptions
{
/// <summary>
/// Gets or sets the text that appears in the title bar of a folder dialog.
/// </summary>
public string? Title { get; set; }
/// <summary>
/// Gets or sets the initial location where the file open picker looks for files to present to the user.
/// </summary>
public IStorageFolder? SuggestedStartLocation { get; set; }
}

4
src/Avalonia.Base/Platform/Storage/StorageItemProperties.cs

@ -16,7 +16,7 @@ public class StorageItemProperties
DateCreated = dateCreated;
DateModified = dateModified;
}
/// <summary>
/// Gets the size of the file in bytes.
/// </summary>
@ -40,4 +40,4 @@ public class StorageItemProperties
/// Can be null if property is not available.
/// </remarks>
public DateTimeOffset? DateModified { get; }
}
}

Loading…
Cancel
Save