using System.Windows;
using System.Windows.Input;
using WPFBeginner.Models;
using WPFBeginner.ViewModels;

namespace WPFBeginner.Views;

public partial class RegistWindow : Window
{
    public event EventHandler<Member>? MemberAdded;

    public RegistWindow()
    {
        InitializeComponent();
        var viewModel = App.GetService<RegistViewModel>();
        viewModel.MemberAdded += OnMemberAdded;
        DataContext = viewModel;
    }

    private void OnMemberAdded(object? sender, Member member)
    {
        MemberAdded?.Invoke(this, member);
    }

    private void TitleBar_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    {
        if (e.ClickCount == 1)
        {
            DragMove();
        }
    }
}
