using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;

namespace XLAB
{
    public partial class PlanningWindow : Window
    {
        private readonly PlanningWindowViewModel _viewModel;

        public PlanningWindow()
        {
            InitializeComponent();
            _viewModel = new PlanningWindowViewModel(new PlanningService(), new EkzDirectoryService(), new PlanningDialogService(this));
            DataContext = _viewModel;
        }

        private void DataGridRow_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            var row = sender as DataGridRow;
            if (row != null)
            {
                row.IsSelected = true;
                row.Focus();
            }
        }

        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            await _viewModel.InitializeAsync();
        }
    }
}
