JobDesignList.xaml.cs 2.1 KB

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