using System.Windows;
using ytLive.Helpers;
using ytLive.ViewModels;

namespace ytLive;

public partial class ReuseImageDialog : Window
{
    public string? PickedAssetId { get; private set; }
    public bool WantsNew { get; private set; }

    public ReuseImageDialog(ReuseImageViewModel viewModel)
    {
        AppLog.Write("ReuseImageDialog ctor: before InitializeComponent");
        InitializeComponent();
        AppLog.Write("ReuseImageDialog ctor: after InitializeComponent");
        DataContext = viewModel;
        viewModel.ReuseRequested += () =>
        {
            PickedAssetId = viewModel.SelectedCandidate?.AssetId;
            if (PickedAssetId != null) DialogResult = true;
        };
        viewModel.NewImageRequested += () =>
        {
            WantsNew = true;
            DialogResult = true;
        };
        viewModel.CancelRequested += () => DialogResult = false;
    }
}
