StockSummaryControl.xaml.cs 4.3 KB

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