PriorityChanger.xaml.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Shapes;
  14. using PracticaDemoexam.Model;
  15. using PracticaDemoexam.Model.ItemModels;
  16. using PracticaDemoexam.Windows;
  17. namespace PracticaDemoexam.Windows
  18. {
  19. /// <summary>
  20. /// Логика взаимодействия для PriorityChanger.xaml
  21. /// </summary>
  22. public partial class PriorityChanger : Window
  23. {
  24. public List<AgentModel> SelectedAgents;
  25. private void SetPriority()
  26. {
  27. int ret = 0;
  28. foreach (AgentModel am in SelectedAgents)
  29. {
  30. if(am.Agent.Priority > ret)
  31. {
  32. ret = am.Agent.Priority;
  33. }
  34. }
  35. tbPrior.Text = ret.ToString();
  36. }
  37. public PriorityChanger(List<AgentModel> ls)
  38. {
  39. InitializeComponent();
  40. SelectedAgents = ls;
  41. this.Loaded += PriorityChanger_Loaded;
  42. }
  43. private void PriorityChanger_Loaded(object sender, RoutedEventArgs e)
  44. {
  45. SetPriority();
  46. }
  47. public Action<List<AgentModel>, int> Button_click;
  48. private void Button_Click(object sender, RoutedEventArgs e)
  49. {
  50. Button_click.Invoke(SelectedAgents, Convert.ToInt32(tbPrior.Text));
  51. }
  52. }
  53. }