namespace ProximaAnalizer.ViewModels.Dialog;

internal partial class DialogPickerViewModel(LineCollection lineCollection) : ObservableObject, IDialogAware
{

    [ObservableProperty]
    private LineCollection _LineCollection = lineCollection;

    public DialogCloseListener RequestClose { get; set; }

    [ObservableProperty]
    private string _Title = "Line Picker";

    private string? Line;

    [RelayCommand]
    private void SelectLeftLine(LineType lineType)
    {
        IDialogResult result = new DialogResult();
        lineType.IsEnable = false;
        result.Parameters.Add("Line", lineType);
        result.Parameters.Add("Name", Line!);
        result.Parameters.Add("Axis", "L");
        this.RequestClose.Invoke(result);
    }

    [RelayCommand]
    private void SelectRightLine(LineType lineType)
    {
        IDialogResult result = new DialogResult();
        lineType.IsEnable = false;
        result.Parameters.Add("Line", lineType);
        result.Parameters.Add("Name", Line!);
        result.Parameters.Add("Axis", "R");
        this.RequestClose.Invoke(result);
    }

    public bool CanCloseDialog()
    {
        return true;
    }

    public void OnDialogClosed()
    {
    }

    public void OnDialogOpened(IDialogParameters parameters)
    {
        parameters.TryGetValue<string>("Line", out Line);
    }
}
