JobSummaryPanel.xaml.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Windows;
  5. using System.Windows.Controls;
  6. using Comal.Classes;
  7. using InABox.Core;
  8. using System.ComponentModel;
  9. namespace PRSDesktop
  10. {
  11. public partial class JobSummaryPanel : UserControl, IJobControl, IPanel<JobMaterial>
  12. {
  13. public JobSummaryPanel()
  14. {
  15. InitializeComponent();
  16. }
  17. public Job Job
  18. {
  19. get => Summary.Job;
  20. set => Summary.Job = value;
  21. }
  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 Summary";
  29. public DataModel DataModel(Selection selection)
  30. {
  31. // This won't work - it needs to incldue all the fields, because AutoTables like this don't have an ID :-(
  32. var ids = Summary.ExtractValues(x => x.ID, selection).ToArray();
  33. return new AutoDataModel<JobMaterial>(new Filter<JobMaterial>(x => x.ID).InList(ids));
  34. }
  35. public void Heartbeat(TimeSpan time)
  36. {
  37. }
  38. public void Refresh()
  39. {
  40. Summary.Refresh(false, true);
  41. }
  42. public Dictionary<string, object[]> Selected()
  43. {
  44. return new Dictionary<string, object[]>();
  45. }
  46. public void Setup()
  47. {
  48. Summary.Refresh(true, false);
  49. }
  50. public void Shutdown(CancelEventArgs? cancel)
  51. {
  52. }
  53. private void ReservedStock_OnChecked(object sender, RoutedEventArgs e)
  54. {
  55. Summary.IncludeReserves = ReservedStock.IsChecked == true;
  56. Summary.Refresh(false, true);
  57. }
  58. }
  59. }