JobDesignList.xaml.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 Job Job { 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.Job = Job;
  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 design = e.Rows?.FirstOrDefault()?.ToObject<Setout>() ?? new Setout();
  58. Documents.Design = design;
  59. Documents.Refresh(true, true);
  60. Packets.Job = Job;
  61. Packets.Design = design;
  62. Packets.Refresh(true, true);
  63. }
  64. }
  65. }