JobDesignList.xaml.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Windows.Controls;
  5. using Comal.Classes;
  6. using InABox.Core;
  7. using InABox.DynamicGrid;
  8. namespace PRSDesktop
  9. {
  10. /// <summary>
  11. /// Interaction logic for JobDesigns.xaml
  12. /// </summary>
  13. public partial class JobDesignList : UserControl, IPanel<Setout>, IJobControl
  14. {
  15. public JobDesignList()
  16. {
  17. InitializeComponent();
  18. Designs.OnSelectItem += Designs_OnSelectItem;
  19. }
  20. public Guid ParentID { get; set; }
  21. public JobPanelSettings Settings { get; set; }
  22. public bool IsReady { get; set; }
  23. public event DataModelUpdateEvent OnUpdateDataModel;
  24. public void CreateToolbarButtons(IPanelHost host)
  25. {
  26. }
  27. public string SectionName => "Job Designs";
  28. public DataModel DataModel(Selection selection)
  29. {
  30. var ids = Designs.ExtractValues(c => c.ID, selection).ToArray();
  31. return new BaseDataModel<Setout>(new Filter<Setout>(x => x.ID).InList(ids));
  32. }
  33. public void Refresh()
  34. {
  35. Designs.ParentID = ParentID;
  36. Designs.Refresh(false, true);
  37. }
  38. public Dictionary<string, object[]> Selected()
  39. {
  40. return new Dictionary<string, object[]>();
  41. }
  42. public void Setup()
  43. {
  44. Designs.Refresh(true, false);
  45. Documents.Refresh(true, false);
  46. Packets.Refresh(true, false);
  47. }
  48. public void Shutdown()
  49. {
  50. }
  51. public void Heartbeat(TimeSpan time)
  52. {
  53. }
  54. private void Designs_OnSelectItem(object sender, DynamicGridSelectionEventArgs e)
  55. {
  56. var row = e.Rows?.FirstOrDefault();
  57. var id = row != null ? row.Get<Setout, Guid>(x => x.ID) : CoreUtils.FullGuid;
  58. Documents.SetoutID = id;
  59. Documents.Refresh(true, true);
  60. Packets.ParentID = ParentID;
  61. Packets.SetoutID = id;
  62. Packets.Refresh(true, true);
  63. }
  64. }
  65. }