JobDesignPanel.xaml.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. using InABox.Wpf;
  10. namespace PRSDesktop
  11. {
  12. /// <summary>
  13. /// Interaction logic for JobDesigns.xaml
  14. /// </summary>
  15. public partial class JobDesignPanel : UserControl, IPanel<Setout>, IMasterDetailControl<Job>
  16. {
  17. public JobDesignPanel()
  18. {
  19. InitializeComponent();
  20. Designs.OnSelectItem += Designs_OnSelectItem;
  21. }
  22. public Job? Master
  23. {
  24. get => Designs.Master;
  25. set => Designs.Master = value;
  26. }
  27. public bool IsReady { get; set; }
  28. public event DataModelUpdateEvent? OnUpdateDataModel;
  29. public void CreateToolbarButtons(IPanelHost host)
  30. {
  31. }
  32. public string SectionName => "Job Designs";
  33. public DataModel DataModel(Selection selection)
  34. {
  35. var ids = Designs.ExtractValues(c => c.ID, selection).ToArray();
  36. return new BaseDataModel<Setout>(new Filter<Setout>(x => x.ID).InList(ids));
  37. }
  38. public void Refresh()
  39. {
  40. Designs.Refresh(false, true);
  41. }
  42. public Dictionary<string, object[]> Selected()
  43. {
  44. return new Dictionary<string, object[]>();
  45. }
  46. public void Setup()
  47. {
  48. Designs.Refresh(true, false);
  49. Documents.Refresh(true, false);
  50. Packets.Refresh(true, false);
  51. }
  52. public void Shutdown(CancelEventArgs? cancel)
  53. {
  54. }
  55. public void Heartbeat(TimeSpan time)
  56. {
  57. }
  58. private void Designs_OnSelectItem(object sender, DynamicGridSelectionEventArgs e)
  59. {
  60. var design = e.Rows?.FirstOrDefault()?.ToObject<Setout>();
  61. Documents.Design = design;
  62. Documents.Refresh(true, true);
  63. Packets.Master = Master;
  64. Packets.Design = design;
  65. Packets.Refresh(true, true);
  66. }
  67. }
  68. }