using System.Windows;
using Microsoft.Win32;

namespace NexusShell.Controls.Dialogs;

public sealed class NexusOpenFileDialog
{
    public string Title { get; set; } = "Vælg fil";
    public string Filter { get; set; } = "Alle filer|*.*";
    public string? InitialDirectory { get; set; }
    public bool Multiselect { get; set; }
    public string? FileName { get; private set; }
    public string[]? FileNames { get; private set; }

    public bool? ShowDialog(Window? owner = null)
    {
        var window = new NexusOpenFileDialogWindow
        {
            Owner = owner,
            DialogTitle = Title,
            Filter = Filter,
            InitialDirectory = InitialDirectory,
            Multiselect = Multiselect,
        };

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

        return result;
    }
}
