| | | 1 | | // ----------------------------------------------------------------------- |
| | | 2 | | // <copyright file="SaveFileDialogBuilder.cs" company="Stéphane ANDRE"> |
| | | 3 | | // Copyright (c) Stéphane ANDRE. All rights reserved. |
| | | 4 | | // </copyright> |
| | | 5 | | // ----------------------------------------------------------------------- |
| | | 6 | | |
| | | 7 | | using System.Threading; |
| | | 8 | | using System.Threading.Tasks; |
| | | 9 | | |
| | | 10 | | namespace MyNet.UI.Dialogs.FileDialogs; |
| | | 11 | | |
| | | 12 | | /// <summary> |
| | | 13 | | /// Fluent builder for save file dialogs. |
| | | 14 | | /// </summary> |
| | 6 | 15 | | public sealed class SaveFileDialogBuilder(IDialogService dialogService) |
| | | 16 | | : FileDialogBuilderBase<SaveFileDialogBuilder, SaveFileDialogSettings> |
| | | 17 | | { |
| | | 18 | | /// <summary> |
| | | 19 | | /// Sets whether the dialog prompts before overwriting an existing file. |
| | | 20 | | /// </summary> |
| | | 21 | | public SaveFileDialogBuilder WithOverwritePrompt(bool overwritePrompt = true) |
| | | 22 | | { |
| | 3 | 23 | | Settings.OverwritePrompt = overwritePrompt; |
| | 3 | 24 | | return this; |
| | | 25 | | } |
| | | 26 | | |
| | | 27 | | /// <summary> |
| | | 28 | | /// Sets whether the dialog prompts to create a file when it does not exist. |
| | | 29 | | /// </summary> |
| | | 30 | | public SaveFileDialogBuilder WithCreatePrompt(bool createPrompt = true) |
| | | 31 | | { |
| | 0 | 32 | | Settings.CreatePrompt = createPrompt; |
| | 0 | 33 | | return this; |
| | | 34 | | } |
| | | 35 | | |
| | | 36 | | /// <inheritdoc /> |
| | | 37 | | public override Task<FileDialogResult> PickAsync(CancellationToken cancellationToken = default) => |
| | 3 | 38 | | dialogService.ShowSaveFileDialogAsync(Settings, cancellationToken); |
| | | 39 | | } |
| | | 40 | | |