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.Shapes;
using PracticaDemoexam.Model;
using PracticaDemoexam.Model.ItemModels;
using PracticaDemoexam.Windows;

namespace PracticaDemoexam.Windows
{
    /// <summary>
    /// Логика взаимодействия для PriorityChanger.xaml
    /// </summary>
    public partial class PriorityChanger : Window
    {
        public List<AgentModel> SelectedAgents;
        private void SetPriority()
        {
            int ret = 0;
            foreach (AgentModel am in SelectedAgents)
            {
                if(am.Agent.Priority > ret)
                {
                    ret = am.Agent.Priority;
                }
            }
            tbPrior.Text = ret.ToString();
        }
    
        public PriorityChanger(List<AgentModel> ls)
        {
            InitializeComponent();

            SelectedAgents = ls;

            this.Loaded += PriorityChanger_Loaded;
        }

        private void PriorityChanger_Loaded(object sender, RoutedEventArgs e)
        {
            SetPriority();
        }

        public Action<List<AgentModel>, int> Button_click;

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Button_click.Invoke(SelectedAgents, Convert.ToInt32(tbPrior.Text));
        }
    }
}
