|
@@ -1,6 +1,10 @@
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
using System.ComponentModel;
|
|
|
+using System.Linq;
|
|
|
using System.Windows;
|
|
|
using System.Windows.Controls;
|
|
|
+using Comal.Classes;
|
|
|
using InABox.Configuration;
|
|
|
using InABox.Core;
|
|
|
using InABox.DynamicGrid;
|
|
@@ -10,6 +14,8 @@ namespace PRSDesktop;
|
|
|
|
|
|
public partial class StockSummaryControl : UserControl
|
|
|
{
|
|
|
+ private bool _loadedGroups = false;
|
|
|
+ private bool _refresh = false;
|
|
|
|
|
|
private enum Suppress
|
|
|
{
|
|
@@ -31,23 +37,48 @@ public partial class StockSummaryControl : UserControl
|
|
|
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;
|
|
|
|
|
|
+ InitialiseSelectors();
|
|
|
+
|
|
|
SummaryGrid.Refresh(true, false);
|
|
|
-
|
|
|
- ProductGroups.Refresh(true, false);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void InitialiseSelectors()
|
|
|
+ {
|
|
|
+ ProductGroups.SelectedIDs = Properties.ProductGroups.ToHashSet();
|
|
|
+ SupplierGrid.SelectedIDs = Properties.Suppliers.ToHashSet();
|
|
|
+ JobGrid.SelectedIDs = Properties.Jobs.ToHashSet();
|
|
|
+
|
|
|
+ ProductGroups.FilterComponent.SetSettings(Properties.ProductGroupFilter, false);
|
|
|
+ ProductGroups.FilterComponent.OnFiltersSelected += (filters) =>
|
|
|
+ {
|
|
|
+ Properties.ProductGroupFilter = filters;
|
|
|
+ DoSaveSettings();
|
|
|
+ };
|
|
|
+
|
|
|
+ SupplierGrid.FilterComponent.SetSettings(Properties.SupplierFilter, false);
|
|
|
+ SupplierGrid.FilterComponent.OnFiltersSelected += (filters) =>
|
|
|
+ {
|
|
|
+ Properties.SupplierFilter = filters;
|
|
|
+ DoSaveSettings();
|
|
|
+ };
|
|
|
+
|
|
|
+ JobGrid.FilterComponent.SetSettings(Properties.JobFilter, false);
|
|
|
+ JobGrid.FilterComponent.OnFiltersSelected += (filters) =>
|
|
|
+ {
|
|
|
+ Properties.JobFilter = filters;
|
|
|
+ DoSaveSettings();
|
|
|
+ };
|
|
|
+
|
|
|
+ ProductGroups.Refresh(true, true);
|
|
|
+ SupplierGrid.Refresh(true, true);
|
|
|
+ JobGrid.Refresh(true, true);
|
|
|
+
|
|
|
+ SummaryGrid.JobIDs = Properties.Jobs;
|
|
|
+ SummaryGrid.SupplierIDs = Properties.Suppliers;
|
|
|
+ }
|
|
|
+
|
|
|
public void Shutdown(CancelEventArgs? cancel)
|
|
|
{
|
|
|
|
|
@@ -55,8 +86,11 @@ public partial class StockSummaryControl : UserControl
|
|
|
|
|
|
public void Refresh()
|
|
|
{
|
|
|
- SummaryGrid.Refresh(false,true);
|
|
|
- ProductGroups.Refresh(false, true);
|
|
|
+ _refresh = true;
|
|
|
+ if (_loadedGroups)
|
|
|
+ {
|
|
|
+ SummaryGrid.Refresh(false,true);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public StockSummaryProperties Properties { get; set; }
|
|
@@ -74,75 +108,80 @@ public partial class StockSummaryControl : UserControl
|
|
|
public event LoadSettings<StockSummaryProperties>? LoadSettings;
|
|
|
|
|
|
public event SaveSettings<StockSummaryProperties>? SaveSettings;
|
|
|
-
|
|
|
- private void GroupSelector_OnSettingsChanged(object sender, ProductGroupSelectorSettingsChangedArgs args)
|
|
|
+
|
|
|
+ private void SplitPanel_OnOnChanged(object sender, DynamicSplitPanelSettings e)
|
|
|
{
|
|
|
if (EventSuppressor.IsSet(Suppress.This))
|
|
|
return;
|
|
|
-
|
|
|
- Properties.GroupSettings = args.Settings;
|
|
|
+
|
|
|
+ Properties.SplitPanelSettings = e;
|
|
|
DoSaveSettings();
|
|
|
}
|
|
|
+
|
|
|
+ private void SummaryGrid_OnBeforeRefresh(object sender, BeforeRefreshEventArgs args)
|
|
|
+ {
|
|
|
+ //Progress.Show("Loading");
|
|
|
+ ProductGroups.IsEnabled = false;
|
|
|
+ JobGrid.IsEnabled = false;
|
|
|
+ SupplierGrid.IsEnabled = false;
|
|
|
+ }
|
|
|
|
|
|
- private void GroupSelector_OnSelectionChanged(object sender, ProductGroupSelectorSelectionChangedArgs args)
|
|
|
+ private void SummaryGrid_OnAfterRefresh(object sender, AfterRefreshEventArgs args)
|
|
|
{
|
|
|
- if (EventSuppressor.IsSet(Suppress.This))
|
|
|
- return;
|
|
|
-
|
|
|
- Properties.GroupSelection = args.Selection;
|
|
|
- DoSaveSettings();
|
|
|
-
|
|
|
- SummaryGrid.GroupIDs = args.Selection.Groups;
|
|
|
- SummaryGrid.Refresh(false, true);
|
|
|
+ //Progress.Close();
|
|
|
+ ProductGroups.IsEnabled = true;
|
|
|
+ JobGrid.IsEnabled = true;
|
|
|
+ SupplierGrid.IsEnabled = true;
|
|
|
}
|
|
|
|
|
|
- private void JobSelector_OnSettingsChanged(object sender, JobSelectorSettingsChangedArgs args)
|
|
|
+ private void DetailSplitPanel_OnChanged(object sender, DynamicSplitPanelSettings e)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void ProductGroups_GroupSelectionChanged(HashSet<Guid> selected)
|
|
|
{
|
|
|
if (EventSuppressor.IsSet(Suppress.This))
|
|
|
return;
|
|
|
-
|
|
|
- Properties.JobSettings = args.Settings;
|
|
|
+
|
|
|
+ Properties.ProductGroups = ProductGroups.GetSelectedGroups(false).ToArray();
|
|
|
DoSaveSettings();
|
|
|
-
|
|
|
+
|
|
|
+ SummaryGrid.GroupIDs = ProductGroups.GetSelectedGroups(true).ToArray();
|
|
|
+ SummaryGrid.Refresh(false, true);
|
|
|
}
|
|
|
|
|
|
- private void JobSelector_OnSelectionChanged(object sender, JobSelectorSelectionChangedArgs args)
|
|
|
+ private void SupplierGrid_SelectionChanged(HashSet<Guid> selected)
|
|
|
{
|
|
|
if (EventSuppressor.IsSet(Suppress.This))
|
|
|
return;
|
|
|
|
|
|
- Properties.JobSelection = args.Selection;
|
|
|
+ Properties.Suppliers = selected.ToArray();
|
|
|
DoSaveSettings();
|
|
|
|
|
|
- SummaryGrid.JobIDs = args.Selection.Jobs;
|
|
|
+ SummaryGrid.SupplierIDs = Properties.Suppliers;
|
|
|
SummaryGrid.Refresh(false, true);
|
|
|
}
|
|
|
-
|
|
|
- private void SplitPanel_OnOnChanged(object sender, DynamicSplitPanelSettings e)
|
|
|
+
|
|
|
+ private void JobGrid_SelectionChanged(HashSet<Guid> selected)
|
|
|
{
|
|
|
if (EventSuppressor.IsSet(Suppress.This))
|
|
|
return;
|
|
|
|
|
|
- Properties.SplitPanelSettings = e;
|
|
|
+ Properties.Jobs = selected.ToArray();
|
|
|
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;
|
|
|
+
|
|
|
+ SummaryGrid.JobIDs = Properties.Jobs;
|
|
|
+ SummaryGrid.Refresh(false, true);
|
|
|
}
|
|
|
|
|
|
- private void DetailSplitPanel_OnChanged(object sender, DynamicSplitPanelSettings e)
|
|
|
+ private void ProductGroups_AfterRefresh(object sender, AfterRefreshEventArgs args)
|
|
|
{
|
|
|
-
|
|
|
+ SummaryGrid.GroupIDs = ProductGroups.GetSelectedGroups(true).ToArray();
|
|
|
+ _loadedGroups = true;
|
|
|
+ if (_refresh)
|
|
|
+ {
|
|
|
+ Refresh();
|
|
|
+ }
|
|
|
}
|
|
|
}
|