JobAssignmentPanel.xaml.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Windows.Controls;
  5. using Comal.Classes;
  6. using System.ComponentModel;
  7. using InABox.Core;
  8. using InABox.Wpf;
  9. namespace PRSDesktop;
  10. public partial class JobAssignmentPanel : UserControl, IBasePanel, IMasterDetailControl<Job>, IDataModelSource
  11. {
  12. public JobAssignmentPanel()
  13. {
  14. InitializeComponent();
  15. }
  16. #region IJobPanel
  17. public Job? Master
  18. {
  19. get => Activities.Master;
  20. set
  21. {
  22. Activities.Master = value;
  23. Assignments.Master = value;
  24. }
  25. }
  26. #endregion
  27. #region IDataModelSource
  28. public event DataModelUpdateEvent? OnUpdateDataModel;
  29. public string SectionName => "Job Assignments";
  30. public DataModel DataModel(Selection selection)
  31. {
  32. var ids = Assignments.ExtractValues(x => x.ID, selection).ToArray();
  33. return new AssignmentDataModel(new Filter<Assignment>(x => x.ID).InList(ids));
  34. }
  35. #endregion
  36. #region IBasePanel
  37. public void Setup()
  38. {
  39. Activities.Refresh(true, false);
  40. Assignments.Refresh(true, false);
  41. }
  42. public void Shutdown(CancelEventArgs? cancel)
  43. {
  44. }
  45. public void Refresh()
  46. {
  47. Activities.Refresh(false, true);
  48. Assignments.Refresh(false, true);
  49. }
  50. public bool IsReady { get; set; }
  51. public void CreateToolbarButtons(IPanelHost host)
  52. {
  53. }
  54. public Dictionary<string, object[]> Selected()
  55. {
  56. return new Dictionary<string, object[]>
  57. {
  58. { typeof(Assignment).EntityName(), Assignments.SelectedRows }
  59. };
  60. }
  61. public void Heartbeat(TimeSpan time)
  62. {
  63. }
  64. #endregion
  65. }