﻿using BNEBotCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace BNEBotManager
{
  /// <summary>
  /// Interaction logic for MainWindow.xaml
  /// </summary>
  public partial class MainWindow : Window
  {
    public MainWindow()
    {
      DataContext = new ApplicationContext();

      InitializeComponent();
    }

    private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
    {
      (DataContext as ApplicationContext).Exit();
    }

    private void RunningBots_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
      LauncherConnection connection = ((sender as FrameworkElement).DataContext) as LauncherConnection;
      
      foreach (BotInfo bot in e.RemovedItems)
      {
        connection.SelectedBots.Remove(bot);
      }

      foreach (BotInfo bot in e.AddedItems)
      {
        connection.SelectedBots.Add(bot);
      }
    }
  }
}
