
using DryIoc;
using System.IO;

namespace HistoryView.ViewModels.Dialogs;

public partial class FileLoaderViewModel : ObservableObject, IDialogAwareTitle
{
    public DialogCloseListener RequestClose { get; set; }
    public string Title { get; set; } = "文件选择";
    public bool CanCloseDialog()
    {

        return true;
    }

    [ObservableProperty]
    private FileInfo? _SelectedFile;




    [RelayCommand]
    private void Confirm()
    {
        IDialogResult result = new DialogResult();
        if (this.SelectedFile is not null)
            result.Parameters.Add("File", this.SelectedFile);

        this.RequestClose.Invoke(result);

    }

    [RelayCommand]
    private void Cancel()
    {
        this.RequestClose.Invoke();
    }


    public void OnDialogClosed()
    {


    }

    public void OnDialogOpened(IDialogParameters parameters)
    {
    }


    [RelayCommand]
    private void Exit()
    {
        this.RequestClose.Invoke();
    }
}
