namespace HistoryView.ViewModels.Dialogs;

internal partial class ConfigFileComparisionViewModel(TemperatureConfigs temperatureConfigs) : ObservableObject, IDialogAwareTitle
{

    public DialogCloseListener RequestClose { get; set; }
    public string Title { get; set; } = "文件对比";
    public bool CanCloseDialog()
    {

        return true;
    }

    public void OnDialogClosed()
    {
    }

    [ObservableProperty]
    private ObservableCollection<TempConfig> _ConfigFiles = [];

    [ObservableProperty]
    private TempConfig? _Source;

    [ObservableProperty]
    private TempConfig? _Target;

    public void OnDialogOpened(IDialogParameters parameters)
    {
        if (parameters.TryGetValue("Source", out TempConfig? source) && source is not null)
            this.Source = source;

        this.ConfigFiles = [];
        if (temperatureConfigs.CurrentConfigFile is not null && temperatureConfigs.CurrentConfigFile.ConfigFile is not null)
            this.ConfigFiles.Add(temperatureConfigs.CurrentConfigFile.ConfigFile);
        this.ConfigFiles.AddRange(temperatureConfigs.ConfigFiles);
    }

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