using System.Windows; using System.Windows.Controls; using InABox.Configuration; using InABox.Core; using InABox.DynamicGrid; using InABox.WPF; namespace PRSDesktop { public partial class StockSummaryControl : UserControl { private enum Suppress { This } public StockSummaryControl() { using (new EventSuppressor(Suppress.This)) InitializeComponent(); } public void Setup() { using (new EventSuppressor(Suppress.This)) { DoLoadSettings(); SplitPanel.View = Properties.SplitPanelSettings.View; SplitPanel.AnchorWidth = Properties.SplitPanelSettings.AnchorWidth; SplitPanel.DetailHeight = Properties.SplitPanelSettings.DetailHeight; GroupSelector.Settings = Properties.GroupSettings; GroupSelector.Setup(); GroupSelector.Selection = Properties.GroupSelection; SummaryGrid.GroupIDs = Properties.GroupSelection.Groups; JobSelector.Settings = Properties.JobSettings; JobSelector.Setup(); JobSelector.Selection = Properties.JobSelection; SummaryGrid.JobIDs = Properties.JobSelection.Jobs; SummaryGrid.Refresh(true, false); } } public void Shutdown() { } public void Refresh() { SummaryGrid.Refresh(false,true); } public StockSummaryProperties Properties { get; set; } private void DoLoadSettings() { Properties = LoadSettings?.Invoke(this) ?? new StockSummaryProperties(); } private void DoSaveSettings() { SaveSettings?.Invoke(this, Properties); } public event LoadSettings? LoadSettings; public event SaveSettings? SaveSettings; private void GroupSelector_OnSettingsChanged(object sender, ProductGroupSelectorSettingsChangedArgs args) { if (EventSuppressor.IsSet(Suppress.This)) return; Properties.GroupSettings = args.Settings; DoSaveSettings(); } private void GroupSelector_OnSelectionChanged(object sender, ProductGroupSelectorSelectionChangedArgs args) { if (EventSuppressor.IsSet(Suppress.This)) return; Properties.GroupSelection = args.Selection; DoSaveSettings(); SummaryGrid.GroupIDs = args.Selection.Groups; SummaryGrid.Refresh(false, true); } private void JobSelector_OnSettingsChanged(object sender, JobSelectorSettingsChangedArgs args) { if (EventSuppressor.IsSet(Suppress.This)) return; Properties.JobSettings = args.Settings; DoSaveSettings(); } private void JobSelector_OnSelectionChanged(object sender, JobSelectorSelectionChangedArgs args) { if (EventSuppressor.IsSet(Suppress.This)) return; Properties.JobSelection = args.Selection; DoSaveSettings(); SummaryGrid.JobIDs = args.Selection.Jobs; SummaryGrid.Refresh(false, true); } private void SplitPanel_OnOnChanged(object sender, DynamicSplitPanelSettings e) { if (EventSuppressor.IsSet(Suppress.This)) return; Properties.SplitPanelSettings = e; DoSaveSettings(); } private void SummaryGrid_OnBeforeRefresh(object sender, BeforeRefreshEventArgs args) { //Progress.Show("Loading"); GroupSelector.IsEnabled = false; JobSelector.IsEnabled = false; } private void SummaryGrid_OnAfterRefresh(object sender, AfterRefreshEventArgs args) { //Progress.Close(); GroupSelector.IsEnabled = true; JobSelector.IsEnabled = true; } } }