using System.Windows;

namespace NexusShell.Controls.Dialogs;

public sealed class NexusSaveFileDialog
{
    public string Title { get; set; } = "Gem fil";
    public string Filter { get; set; } = "Alle filer|*.*";
    public string? InitialDirectory { get; set; }
    public string? DefaultExt { get; set; }
    public string? FileName { get; set; }
    public string? SelectedFileName { get; private set; }

    public bool? ShowDialog(Window? owner = null)
    {
        var window = new NexusSaveFileDialogWindow
        {
            Owner = owner,
            DialogTitle = Title,
            Filter = Filter,
            InitialDirectory = InitialDirectory,
            DefaultExt = DefaultExt,
            SuggestedFileName = FileName,
        };

        var result = window.ShowDialog();
        if (result == true)
        {
            SelectedFileName = window.SelectedFileName;
            FileName = window.SelectedFileName;
        }

        return result;
    }
}
