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

namespace ytLive;

public partial class CameraPickerDialog : Window
{
    public CameraDeviceInfo? PickedDevice { get; private set; }

    public CameraPickerDialog(CameraPickerViewModel viewModel)
    {
        AppLog.Write("CameraPickerDialog ctor: before InitializeComponent");
        InitializeComponent();
        AppLog.Write("CameraPickerDialog ctor: after InitializeComponent");
        DataContext = viewModel;
        viewModel.UseRequested += device =>
        {
            PickedDevice = device;
            DialogResult = true;
        };
        viewModel.CancelRequested += () => DialogResult = false;
    }
}
