From e7b3004c2e28336d14c5ea2ec3203a51e0653d26 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Sun, 28 Jul 2019 11:07:43 +0300 Subject: Fixed group indices on excel import (catalogs module). Fixed catalogs reloading after save. Fixed catalogs grid 'display' 'company' columns. --- .../ViewModels/MainViewVM.cs | 32 ++++++++++++++++++---- .../Views/CatalogView.xaml | 8 +++--- .../Views/CatalogsView.xaml | 4 +-- 3 files changed, 32 insertions(+), 12 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/ViewModels/MainViewVM.cs index 6494b9d2c..652ad3093 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/ViewModels/MainViewVM.cs @@ -137,7 +137,6 @@ namespace Tango.MachineStudio.Catalogs.ViewModels public MainViewVM() { Catalogs = new ObservableCollection(); - _catalogsContext = ObservablesContext.CreateDefault(); EditCatalogCommand = new RelayCommand(EditSelectedCatalog, () => SelectedCatalog != null); NewCatalogCommand = new RelayCommand(CreateNewCatalog); @@ -166,8 +165,17 @@ namespace Tango.MachineStudio.Catalogs.ViewModels using (_notification.PushTaskItem("Loading color catalogs...")) { IsFree = false; + + if (_catalogsContext != null) + { + _catalogsContext.Dispose(); + } + + _catalogsContext = ObservablesContext.CreateDefault(); + Catalogs = (await _catalogsContext.ColorCatalogs.Include(x => x.ColorCatalogsGroups.Select(g => g.ColorCatalogsItems)).ToListAsync()).ToSynchronizedObservableCollection(); SelectedCatalog = null; + IsFree = true; } } @@ -468,12 +476,24 @@ namespace Tango.MachineStudio.Catalogs.ViewModels var recipes = reader.GetData("Recipes"); reader.Dispose(); - foreach (var group in groups.Where(x => !ActiveCatalog.ColorCatalogsGroups.ToList().Exists(y => y.Name == x.GroupName))) + foreach (var group in groups) { - ColorCatalogsGroup newGroup = new ColorCatalogsGroup(); - newGroup.Name = group.GroupName; - newGroup.GroupIndex = group.GroupIndex; - ActiveCatalog.ColorCatalogsGroups.Add(newGroup); + ColorCatalogsGroup existinGroup = ActiveCatalog.ColorCatalogsGroups.SingleOrDefault(x => x.Name == group.GroupName); + + bool inserting = false; + if (existinGroup == null) + { + existinGroup = new ColorCatalogsGroup(); + inserting = true; + } + + existinGroup.Name = group.GroupName; + existinGroup.GroupIndex = group.GroupIndex; + + if (inserting) + { + ActiveCatalog.ColorCatalogsGroups.Add(existinGroup); + } } foreach (var item in colors) diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Views/CatalogView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Views/CatalogView.xaml index 9f3dd701a..6856cf4a2 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Views/CatalogView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Views/CatalogView.xaml @@ -191,16 +191,16 @@ - - - + + + - + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Views/CatalogsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Views/CatalogsView.xaml index dca9c0e96..6bc9caf4c 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Views/CatalogsView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Views/CatalogsView.xaml @@ -63,9 +63,9 @@ --> - + - + -- cgit v1.3.1