|
@@ -5,6 +5,7 @@ using System.Drawing;
|
|
|
using System.Drawing.Imaging;
|
|
|
using System.IO;
|
|
|
using System.Linq;
|
|
|
+using System.Threading.Tasks;
|
|
|
using System.Windows;
|
|
|
using System.Windows.Controls;
|
|
|
using System.Windows.Media.Imaging;
|
|
@@ -23,17 +24,30 @@ using System.Windows.Markup.Localizer;
|
|
|
|
|
|
namespace PRSDesktop
|
|
|
{
|
|
|
+
|
|
|
+ public class ProductsGlobalSettings : BaseObject, IGlobalConfigurationSettings
|
|
|
+ {
|
|
|
+ public int PageSize { get; set; } = 5000;
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// Interaction logic for ProductsPanel.xaml
|
|
|
/// </summary>
|
|
|
public partial class ProductsPanel : UserControl, IPanel<Product>
|
|
|
{
|
|
|
private Product _product;
|
|
|
- private ProductScreenSettings settings;
|
|
|
+ private ProductsGlobalSettings _globalsettings = new();
|
|
|
+ private ProductScreenSettings _settings = new();
|
|
|
|
|
|
public ProductsPanel()
|
|
|
{
|
|
|
+ Task[] setup = new Task[]
|
|
|
+ {
|
|
|
+ Task.Run(() => _settings = new UserConfiguration<ProductScreenSettings>().Load()),
|
|
|
+ Task.Run(() => _globalsettings = new GlobalConfiguration<ProductsGlobalSettings>().Load())
|
|
|
+ };
|
|
|
InitializeComponent();
|
|
|
+ Task.WaitAll(setup);
|
|
|
Pricing.Visibility = Security.CanView<ProductInstance>() ? Visibility.Visible : Visibility.Collapsed;
|
|
|
Warehousing.Visibility = Security.CanView<StockMovement>() ? Visibility.Visible : Visibility.Collapsed;
|
|
|
Orders.Visibility = Security.CanView<PurchaseOrderItem>() ? Visibility.Visible : Visibility.Collapsed;
|
|
@@ -51,19 +65,20 @@ namespace PRSDesktop
|
|
|
|
|
|
public void Setup()
|
|
|
{
|
|
|
- settings = new UserConfiguration<ProductScreenSettings>().Load();
|
|
|
- SplitPanel.View = settings.ViewType == ScreenViewType.Register ? DynamicSplitPanelView.Master :
|
|
|
- settings.ViewType == ScreenViewType.Details ? DynamicSplitPanelView.Detail : DynamicSplitPanelView.Combined;
|
|
|
- SplitPanel.AnchorWidth = settings.AnchorWidth;
|
|
|
+
|
|
|
+ SplitPanel.View = _settings.ViewType == ScreenViewType.Register ? DynamicSplitPanelView.Master :
|
|
|
+ _settings.ViewType == ScreenViewType.Details ? DynamicSplitPanelView.Detail : DynamicSplitPanelView.Combined;
|
|
|
+ SplitPanel.AnchorWidth = _settings.AnchorWidth;
|
|
|
|
|
|
- Products.ColumnsTag = settings.ViewType == ScreenViewType.Register ? settings.ViewType.ToString() : "";
|
|
|
+ Products.Options.PageSize = _globalsettings.PageSize;
|
|
|
+ Products.ColumnsTag = _settings.ViewType == ScreenViewType.Register ? _settings.ViewType.ToString() : "";
|
|
|
Products.Refresh(true, false);
|
|
|
Products.OnSelectItem += Products_OnSelectItem;
|
|
|
|
|
|
Groups.Refresh(true, false);
|
|
|
|
|
|
- if (settings.SelectedDetailsGrid >= 0 && settings.SelectedDetailsGrid < ProductDetails.Items.Count)
|
|
|
- ProductDetails.SelectedIndex = settings.SelectedDetailsGrid;
|
|
|
+ if (_settings.SelectedDetailsGrid >= 0 && _settings.SelectedDetailsGrid < ProductDetails.Items.Count)
|
|
|
+ ProductDetails.SelectedIndex = _settings.SelectedDetailsGrid;
|
|
|
}
|
|
|
|
|
|
public void Shutdown(CancelEventArgs? cancel)
|
|
@@ -75,9 +90,27 @@ namespace PRSDesktop
|
|
|
ProductSetupActions.Standard(host);
|
|
|
host.CreateSetupSeparator();
|
|
|
ProductSetupActions.ProductSpreadsheetTemplates(host);
|
|
|
+ host.CreateSetupAction(new PanelAction() { Caption = "Products Settings", Image = PRSDesktop.Resources.product, OnExecute =
|
|
|
+ (obj) =>
|
|
|
+ {
|
|
|
+ var grid = new DynamicItemsListGrid<ProductsGlobalSettings>();
|
|
|
+ if (grid.EditItems(new ProductsGlobalSettings[] { _globalsettings }))
|
|
|
+ {
|
|
|
+ new GlobalConfiguration<ProductsGlobalSettings>().Save(_globalsettings);
|
|
|
+ Products.Options.PageSize = _globalsettings.PageSize;
|
|
|
+ Refresh();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
//host.CreatePanelAction(new PanelAction() { Caption = "Import Dxf", OnExecute = ImportDxF, Image = PRSDesktop.Resources.design });
|
|
|
}
|
|
|
|
|
|
+ private void ProductSettingsClick(PanelAction obj)
|
|
|
+ {
|
|
|
+ throw new NotImplementedException();
|
|
|
+ }
|
|
|
+
|
|
|
public string SectionName => "Products";
|
|
|
|
|
|
public DataModel DataModel(Selection selected)
|
|
@@ -220,8 +253,8 @@ namespace PRSDesktop
|
|
|
var t = e.AddedItems[0] as TabItem;
|
|
|
if (t != null && t.Visibility == Visibility.Visible)
|
|
|
{
|
|
|
- settings.SelectedDetailsGrid = ProductDetails.SelectedIndex;
|
|
|
- new UserConfiguration<ProductScreenSettings>().Save(settings);
|
|
|
+ _settings.SelectedDetailsGrid = ProductDetails.SelectedIndex;
|
|
|
+ new UserConfiguration<ProductScreenSettings>().Save(_settings);
|
|
|
|
|
|
RefreshDetailsPage();
|
|
|
}
|
|
@@ -230,12 +263,12 @@ namespace PRSDesktop
|
|
|
|
|
|
private void SplitPanel_OnChanged(object sender, DynamicSplitPanelSettings e)
|
|
|
{
|
|
|
- settings.ViewType = SplitPanel.View == DynamicSplitPanelView.Master ? ScreenViewType.Register :
|
|
|
+ _settings.ViewType = SplitPanel.View == DynamicSplitPanelView.Master ? ScreenViewType.Register :
|
|
|
SplitPanel.View == DynamicSplitPanelView.Detail ? ScreenViewType.Details : ScreenViewType.Combined;
|
|
|
- settings.AnchorWidth = SplitPanel.AnchorWidth;
|
|
|
- new UserConfiguration<ProductScreenSettings>().Save(settings);
|
|
|
+ _settings.AnchorWidth = SplitPanel.AnchorWidth;
|
|
|
+ new UserConfiguration<ProductScreenSettings>().Save(_settings);
|
|
|
|
|
|
- var newTag = settings.ViewType == ScreenViewType.Register ? settings.ViewType.ToString() : "";
|
|
|
+ var newTag = _settings.ViewType == ScreenViewType.Register ? _settings.ViewType.ToString() : "";
|
|
|
if (Products.ColumnsTag != newTag)
|
|
|
{
|
|
|
Products.ColumnsTag = newTag;
|