StockSummaryControl.xaml.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. using System.Windows;
  2. using System.Windows.Controls;
  3. using InABox.Configuration;
  4. using InABox.Core;
  5. using InABox.DynamicGrid;
  6. using InABox.WPF;
  7. namespace PRSDesktop
  8. {
  9. public partial class StockSummaryControl : UserControl
  10. {
  11. private enum Suppress
  12. {
  13. This
  14. }
  15. public StockSummaryControl()
  16. {
  17. using (new EventSuppressor(Suppress.This))
  18. InitializeComponent();
  19. }
  20. public void Setup()
  21. {
  22. using (new EventSuppressor(Suppress.This))
  23. {
  24. DoLoadSettings();
  25. SplitPanel.View = Properties.SplitPanelSettings.View;
  26. SplitPanel.AnchorWidth = Properties.SplitPanelSettings.AnchorWidth;
  27. SplitPanel.DetailHeight = Properties.SplitPanelSettings.DetailHeight;
  28. GroupSelector.Settings = Properties.GroupSettings;
  29. GroupSelector.Setup();
  30. GroupSelector.Selection = Properties.GroupSelection;
  31. SummaryGrid.GroupIDs = Properties.GroupSelection.Groups;
  32. JobSelector.Settings = Properties.JobSettings;
  33. JobSelector.Setup();
  34. JobSelector.Selection = Properties.JobSelection;
  35. SummaryGrid.JobIDs = Properties.JobSelection.Jobs;
  36. SummaryGrid.Refresh(true, false);
  37. }
  38. }
  39. public void Shutdown()
  40. {
  41. }
  42. public void Refresh()
  43. {
  44. SummaryGrid.Refresh(false,true);
  45. }
  46. public StockSummaryProperties Properties { get; set; }
  47. private void DoLoadSettings()
  48. {
  49. Properties = LoadSettings?.Invoke(this) ?? new StockSummaryProperties();
  50. }
  51. private void DoSaveSettings()
  52. {
  53. SaveSettings?.Invoke(this, Properties);
  54. }
  55. public event LoadSettings<StockSummaryProperties>? LoadSettings;
  56. public event SaveSettings<StockSummaryProperties>? SaveSettings;
  57. private void GroupSelector_OnSettingsChanged(object sender, ProductGroupSelectorSettingsChangedArgs args)
  58. {
  59. if (EventSuppressor.IsSet(Suppress.This))
  60. return;
  61. Properties.GroupSettings = args.Settings;
  62. DoSaveSettings();
  63. }
  64. private void GroupSelector_OnSelectionChanged(object sender, ProductGroupSelectorSelectionChangedArgs args)
  65. {
  66. if (EventSuppressor.IsSet(Suppress.This))
  67. return;
  68. Properties.GroupSelection = args.Selection;
  69. DoSaveSettings();
  70. SummaryGrid.GroupIDs = args.Selection.Groups;
  71. SummaryGrid.Refresh(false, true);
  72. }
  73. private void JobSelector_OnSettingsChanged(object sender, JobSelectorSettingsChangedArgs args)
  74. {
  75. if (EventSuppressor.IsSet(Suppress.This))
  76. return;
  77. Properties.JobSettings = args.Settings;
  78. DoSaveSettings();
  79. }
  80. private void JobSelector_OnSelectionChanged(object sender, JobSelectorSelectionChangedArgs args)
  81. {
  82. if (EventSuppressor.IsSet(Suppress.This))
  83. return;
  84. Properties.JobSelection = args.Selection;
  85. DoSaveSettings();
  86. SummaryGrid.JobIDs = args.Selection.Jobs;
  87. SummaryGrid.Refresh(false, true);
  88. }
  89. private void SplitPanel_OnOnChanged(object sender, DynamicSplitPanelSettings e)
  90. {
  91. if (EventSuppressor.IsSet(Suppress.This))
  92. return;
  93. Properties.SplitPanelSettings = e;
  94. DoSaveSettings();
  95. }
  96. private void SummaryGrid_OnBeforeRefresh(object sender, BeforeRefreshEventArgs args)
  97. {
  98. //Progress.Show("Loading");
  99. GroupSelector.IsEnabled = false;
  100. JobSelector.IsEnabled = false;
  101. }
  102. private void SummaryGrid_OnAfterRefresh(object sender, AfterRefreshEventArgs args)
  103. {
  104. //Progress.Close();
  105. GroupSelector.IsEnabled = true;
  106. JobSelector.IsEnabled = true;
  107. }
  108. }
  109. }