JobDesignList.xaml.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 JobID { get; set; }
  21. public bool IsReady { get; set; }
  22. public event DataModelUpdateEvent OnUpdateDataModel;
  23. public void CreateToolbarButtons(IPanelHost host)
  24. {
  25. }
  26. public string SectionName => "Job Designs";
  27. public DataModel DataModel(Selection selection)
  28. {
  29. var ids = Designs.ExtractValues(c => c.ID, selection).ToArray();
  30. return new BaseDataModel<Setout>(new Filter<Setout>(x => x.ID).InList(ids));
  31. }
  32. public void Refresh()
  33. {
  34. Designs.JobID = JobID;
  35. Designs.Refresh(false, true);
  36. }
  37. public Dictionary<string, object[]> Selected()
  38. {
  39. return new Dictionary<string, object[]>();
  40. }
  41. public void Setup()
  42. {
  43. Designs.Refresh(true, false);
  44. Documents.Refresh(true, false);
  45. Packets.Refresh(true, false);
  46. }
  47. public void Shutdown()
  48. {
  49. }
  50. public void Heartbeat(TimeSpan time)
  51. {
  52. }
  53. private void Designs_OnSelectItem(object sender, DynamicGridSelectionEventArgs e)
  54. {
  55. var row = e.Rows?.FirstOrDefault();
  56. var id = row != null ? row.Get<Setout, Guid>(x => x.ID) : CoreUtils.FullGuid;
  57. Documents.SetoutID = id;
  58. Documents.Refresh(true, true);
  59. Packets.JobID = JobID;
  60. Packets.SetoutID = id;
  61. Packets.Refresh(true, true);
  62. }
  63. }
  64. }