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

namespace ytLive;

public partial class MicPickerDialog : Window
{
    public MicrophoneDeviceInfo? PickedDevice { get; private set; }

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