diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-07-08 17:50:11 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-07-08 17:50:11 +0300 |
| commit | c5713f263db2aa8eda95e13c14ed31d1335b6bc0 (patch) | |
| tree | efb2685fd1f3296021e74e5b97bf87e83a533451 /Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs | |
| parent | 45a4da6b34d2aedea27e2826931f0705eb05130f (diff) | |
| download | Tango-c5713f263db2aa8eda95e13c14ed31d1335b6bc0.tar.gz Tango-c5713f263db2aa8eda95e13c14ed31d1335b6bc0.zip | |
Refactoring of all color catalogs objects !!!
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs')
| -rw-r--r-- | Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs | 115 |
1 files changed, 48 insertions, 67 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs index fb1f240c5..08a5e1168 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs @@ -17,7 +17,6 @@ using System.ComponentModel; using System.Windows.Data; using Tango.PPC.Jobs.Dialogs; using Tango.PPC.Jobs.Views; -using Tango.BL.Catalogs; using System.Runtime.InteropServices; using System.Threading; using Tango.SharedUI.Helpers; @@ -186,34 +185,39 @@ namespace Tango.PPC.Jobs.ViewModels set { _isJobDetailsExpanded = value; RaisePropertyChangedAuto(); } } - private List<ColorCatalog> _twineCatalogItems; + private List<ColorCatalogsItem> _catalogItems; /// <summary> /// Gets or sets the twine catalog items. /// </summary> - public List<ColorCatalog> TwineCatalogItems + public List<ColorCatalogsItem> CatalogItems { - get { return _twineCatalogItems; } - set { _twineCatalogItems = value; RaisePropertyChangedAuto(); } + get { return _catalogItems; } + set { _catalogItems = value; RaisePropertyChangedAuto(); } } + private ColorCatalogsItem _selectedCatalogItem; /// <summary> - /// Gets or sets the twine catalog automatic complete provider. + /// Gets or sets the selected catalog item. /// </summary> - public IAutoCompleteProvider TwineCatalogAutoCompleteProvider { get; set; } + public ColorCatalogsItem SelectedCatalogItem + { + get { return _selectedCatalogItem; } + set { _selectedCatalogItem = value; RaisePropertyChangedAuto(); } + } /// <summary> - /// Gets or sets the coats catalog automatic complete provider. + /// Gets or sets the twine catalog automatic complete provider. /// </summary> - public IAutoCompleteProvider CoatsCatalogAutoCompleteProvider { get; set; } + public IAutoCompleteProvider CatalogAutoCompleteProvider { get; set; } - private List<ColorCatalog> _coatsCatalogItems; + private ColorCatalog _selectedCatalog; /// <summary> - /// Gets or sets the coats catalog items. + /// Gets or sets the selected catalog. /// </summary> - public List<ColorCatalog> CoatsCatalogItems + public ColorCatalog SelectedCatalog { - get { return _coatsCatalogItems; } - set { _coatsCatalogItems = value; RaisePropertyChangedAuto(); } + get { return _selectedCatalog; } + set { _selectedCatalog = value; RaisePropertyChangedAuto(); } } #endregion @@ -268,12 +272,7 @@ namespace Tango.PPC.Jobs.ViewModels /// <summary> /// Gets or sets the twine catalog field tap command. /// </summary> - public RelayCommand<BrushStop> OpenTwineCatalogCommand { get; set; } - - /// <summary> - /// Gets or sets the open coats catalog command. - /// </summary> - public RelayCommand<BrushStop> OpenCoatsCatalogCommand { get; set; } + public RelayCommand<BrushStop> OpenCatalogCommand { get; set; } /// <summary> /// Gets or sets the increase decrease samples to dye command. @@ -360,8 +359,7 @@ namespace Tango.PPC.Jobs.ViewModels FineTuneItems = new ObservableCollection<FineTuneItem>(); ApprovalFineTuneItems = new ObservableCollection<FineTuneItem>(); - TwineCatalogItems = new List<ColorCatalog>(); - CoatsCatalogItems = new List<ColorCatalog>(); + CatalogItems = new List<ColorCatalogsItem>(); CustomersAutoCompleteProvider = new AutoCompleteProvider<Customer>((customer, filter) => { @@ -369,14 +367,9 @@ namespace Tango.PPC.Jobs.ViewModels }); - TwineCatalogAutoCompleteProvider = new AutoCompleteProvider<ColorCatalog>((color, filter) => + CatalogAutoCompleteProvider = new AutoCompleteProvider<ColorCatalogsItem>((item, filter) => { - return !String.IsNullOrWhiteSpace(filter) && color.RmlGuid == Job.Rml.Guid && color.Name.ToLower().StartsWith(filter.ToLower()); - }); - - CoatsCatalogAutoCompleteProvider = new AutoCompleteProvider<ColorCatalog>((color, filter) => - { - return !String.IsNullOrWhiteSpace(filter) && color.RmlGuid == Job.Rml.Guid && color.Name.ToLower().StartsWith(filter.ToLower()); + return !String.IsNullOrWhiteSpace(filter) && item.Name.ToLower().StartsWith(filter.ToLower()); }); //Initialize Commands @@ -421,8 +414,7 @@ namespace Tango.PPC.Jobs.ViewModels StartFineTuningCommand = new RelayCommand(StartFineTuning, () => FineTuneItems.Any(x => x.IsSelected) && CanStartJob()); RepeatFineTuningCommand = new RelayCommand(RepeatFineTuning); ApproveFineTuningCommand = new RelayCommand(ApproveFineTuning); - OpenTwineCatalogCommand = new RelayCommand<BrushStop>(OpenTwineCatalog); - OpenCoatsCatalogCommand = new RelayCommand<BrushStop>(OpenCoatsCatalog); + OpenCatalogCommand = new RelayCommand<BrushStop>(OpenCatalog); ExportEmbroideryCommand = new RelayCommand(ExportEmbroidery); } @@ -479,8 +471,12 @@ namespace Tango.PPC.Jobs.ViewModels SpoolTypes = await _db.SpoolTypes.ToListAsync(); LogManager.Log("Loading Customers..."); Customers = await _db.Customers.Where(x => x.OrganizationGuid == MachineProvider.Machine.OrganizationGuid).ToListAsync(); - TwineCatalogItems = await _db.ColorCatalogs.Where(x => x.RmlGuid == Job.Rml.Guid && x.ColorSpace.Code == (int)BL.Enumerations.ColorSpaces.Twine).OrderBy(x => x.Name).ToListAsync(); - CoatsCatalogItems = await _db.ColorCatalogs.Where(x => x.RmlGuid == Job.Rml.Guid && x.ColorSpace.Code == (int)BL.Enumerations.ColorSpaces.Coats).OrderBy(x => x.Name).ToListAsync(); + + if (Job.ColorSpace.Space == BL.Enumerations.ColorSpaces.Catalog) + { + SelectedCatalog = await new ColorCatalogBuilder(_db).SetFirst().WithGroups().WithItems().BuildAsync(); + CatalogItems = SelectedCatalog.ColorCatalogsGroups.SelectMany(x => x.ColorCatalogsItems).ToList(); + } foreach (var segment in Job.Segments) { @@ -655,24 +651,23 @@ namespace Tango.PPC.Jobs.ViewModels #region RML Changed - protected virtual async void OnRmlChanged(object sender, Rml rml) + protected virtual void OnRmlChanged(object sender, Rml rml) { - TwineCatalogItems = await _db.ColorCatalogs.Where(x => x.RmlGuid == rml.Guid && x.ColorSpace.Code == (int)BL.Enumerations.ColorSpaces.Twine).OrderBy(x => x.Name).ToListAsync(); - CoatsCatalogItems = await _db.ColorCatalogs.Where(x => x.RmlGuid == rml.Guid && x.ColorSpace.Code == (int)BL.Enumerations.ColorSpaces.Coats).OrderBy(x => x.Name).ToListAsync(); + //There is no need for that. - //Replace all brush stops twine color catalogs. - foreach (var stop in Job.Segments.SelectMany(x => x.BrushStops).Where(x => x.ColorCatalog != null && x.BrushColorSpace == BL.Enumerations.ColorSpaces.Twine).ToList()) - { - var replacement = TwineCatalogItems.SingleOrDefault(x => x.Name == stop.ColorCatalog.Name); - stop.ColorCatalog = replacement; - } + ////Replace all brush stops twine color catalogs. + //foreach (var stop in Job.Segments.SelectMany(x => x.BrushStops).Where(x => x.ColorCatalog != null && x.BrushColorSpace == BL.Enumerations.ColorSpaces.Twine).ToList()) + //{ + // var replacement = CatalogItems.SingleOrDefault(x => x.Name == stop.ColorCatalog.Name); + // stop.ColorCatalog = replacement; + //} - //Replace all brush stops coats color catalogs. - foreach (var stop in Job.Segments.SelectMany(x => x.BrushStops).Where(x => x.ColorCatalog != null && x.BrushColorSpace == BL.Enumerations.ColorSpaces.Coats).ToList()) - { - var replacement = CoatsCatalogItems.SingleOrDefault(x => x.Name == stop.ColorCatalog.Name); - stop.ColorCatalog = replacement; - } + ////Replace all brush stops coats color catalogs. + //foreach (var stop in Job.Segments.SelectMany(x => x.BrushStops).Where(x => x.ColorCatalog != null && x.BrushColorSpace == BL.Enumerations.ColorSpaces.Coats).ToList()) + //{ + // var replacement = CoatsCatalogItems.SingleOrDefault(x => x.Name == stop.ColorCatalog.Name); + // stop.ColorCatalog = replacement; + //} ResetFineTuning(); } @@ -935,31 +930,17 @@ namespace Tango.PPC.Jobs.ViewModels /// Opens the twine catalog for the specified brush stop. /// </summary> /// <param name="stop">The stop.</param> - private async void OpenTwineCatalog(BrushStop stop) - { - var catalogItem = await NavigationManager.NavigateForResult<JobsModule, TwineCatalogView, CatalogItem, TwineCatalogNavigationObject>(new TwineCatalogNavigationObject() - { - BrushStop = stop, - RML = Job.Rml, - }, true); - - if (catalogItem != null) - { - stop.ColorCatalog = TwineCatalogItems.SingleOrDefault(x => x.Name == catalogItem.Entity.Name); - } - } - - private async void OpenCoatsCatalog(BrushStop stop) + private async void OpenCatalog(BrushStop stop) { - var catalogItem = await NavigationManager.NavigateForResult<JobsModule, CoatsCatalogView, CatalogItem, TwineCatalogNavigationObject>(new TwineCatalogNavigationObject() + var catalogItem = await NavigationManager.NavigateForResult<JobsModule, TwineCatalogView, ColorCatalogsItem, TwineCatalogNavigationObject>(new TwineCatalogNavigationObject() { - BrushStop = stop, - RML = Job.Rml, + SelectedItem = stop.ColorCatalogsItem, + Catalog = SelectedCatalog }, true); if (catalogItem != null) { - stop.ColorCatalog = CoatsCatalogItems.SingleOrDefault(x => x.Name == catalogItem.Entity.Name); + stop.ColorCatalogsItem = catalogItem; } } |
