JobSummaryPanel.xaml.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. namespace PRSDesktop
  9. {
  10. public partial class JobSummaryPanel : UserControl, IJobControl, IPanel<JobMaterial>
  11. {
  12. public JobSummaryPanel()
  13. {
  14. InitializeComponent();
  15. }
  16. public Guid ParentID
  17. {
  18. get => Summary.ParentID;
  19. set => Summary.ParentID = value;
  20. }
  21. public JobPanelSettings Settings { get; set; }
  22. public bool IsReady { get; set; }
  23. public event DataModelUpdateEvent OnUpdateDataModel;
  24. public void CreateToolbarButtons(IPanelHost host)
  25. {
  26. }
  27. public string SectionName => "Job Summary";
  28. public DataModel DataModel(Selection selection)
  29. {
  30. // This won't work - it needs to incldue all the fields, because AutoTables like this don't have an ID :-(
  31. var ids = Summary.ExtractValues(x => x.ID, selection).ToArray();
  32. return new AutoDataModel<JobMaterial>(new Filter<JobMaterial>(x => x.ID).InList(ids));
  33. }
  34. public void Heartbeat(TimeSpan time)
  35. {
  36. }
  37. public void Refresh()
  38. {
  39. Summary.Refresh(false, true);
  40. }
  41. public Dictionary<string, object[]> Selected()
  42. {
  43. return new Dictionary<string, object[]>();
  44. }
  45. public void Setup()
  46. {
  47. Summary.Refresh(true, false);
  48. }
  49. public void Shutdown()
  50. {
  51. }
  52. private void ReservedStock_OnChecked(object sender, RoutedEventArgs e)
  53. {
  54. Summary.IncludeReserves = ReservedStock.IsChecked == true;
  55. Summary.Refresh(false, true);
  56. }
  57. }
  58. }