diff options
| author | Avi Levkovich <avi@twine-s.com> | 2019-08-01 17:23:44 +0300 |
|---|---|---|
| committer | Avi Levkovich <avi@twine-s.com> | 2019-08-01 17:23:44 +0300 |
| commit | 06c6cfec8af9c3b3f930da7fe4394ee885d24352 (patch) | |
| tree | 2667eb76e8fb204db99608e91b49bf73d8b0ecd3 /Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels | |
| parent | 42471da0b2a19c964fc2c3df39cc2e8a6aaf5e2e (diff) | |
| parent | 18c4c73f8b654dca09e1333d1f6a35e4cbdc9b17 (diff) | |
| download | Tango-06c6cfec8af9c3b3f930da7fe4394ee885d24352.tar.gz Tango-06c6cfec8af9c3b3f930da7fe4394ee885d24352.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels')
3 files changed, 64 insertions, 4 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobSummeryViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobSummeryViewVM.cs index 847edb52f..69d8b090f 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobSummeryViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobSummeryViewVM.cs @@ -107,6 +107,16 @@ namespace Tango.PPC.Jobs.ViewModels _context = obj.Context; Job = obj.Job; + if (Job.ColorSpace.Space == BL.Enumerations.ColorSpaces.Catalog) + { + if (_context.ColorCatalogs.SingleOrDefault(x => x.Guid == Job.ColorCatalogGuid) == null) + { + await NotificationProvider.ShowError("The selected color catalog for this job could not be found.\nCannot load job."); + await NavigationManager.NavigateBack(); + return; + } + } + Job = await new JobBuilder(_context).Set(Job.Guid) .WithConfiguration() .WithRML() 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 7ecfb7d27..2ae9df7fb 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 @@ -474,8 +474,20 @@ namespace Tango.PPC.Jobs.ViewModels if (Job.ColorSpace.Space == BL.Enumerations.ColorSpaces.Catalog) { - SelectedCatalog = await new ColorCatalogBuilder(_db).SetFirst().WithGroups().WithItems().BuildAsync(); - CatalogItems = SelectedCatalog.ColorCatalogsGroups.SelectMany(x => x.ColorCatalogsItems).OrderBy(x => x.ItemIndex).ToList(); + SelectedCatalog = await new ColorCatalogBuilder(_db).Set(Job.ColorCatalogGuid).WithGroups().WithItems().BuildAsync(); + + if (SelectedCatalog != null) + { + CatalogItems = SelectedCatalog.ColorCatalogsGroups.SelectMany(x => x.ColorCatalogsItems).OrderBy(x => x.ItemIndex).ToList(); + } + else + { + await NotificationProvider.ShowError("The selected color catalog for this job could not be found.\nCannot load job."); + Job = null; + _can_navigate_back = true; + await NavigationManager.NavigateBack(); + return; + } } foreach (var segment in Job.Segments) diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs index b7a6ad94a..3ea7ae6f4 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs @@ -46,6 +46,7 @@ namespace Tango.PPC.Jobs.ViewModels public class JobsViewVM : PPCViewModel<IJobsView> { private ObservablesContext _db; //Holds the db context for the job list. + private ObservableCollection<ColorCatalog> _catalogs; //Holds the available color catalogs. public enum JobsCategory { @@ -401,6 +402,8 @@ namespace Tango.PPC.Jobs.ViewModels { LogManager.Log("Adding new job..."); + var settings = SettingsManager.Default.GetOrCreate<JobsModuleSettings>(); + var machine = MachineProvider.Machine; JobCreationViewVM vm = new JobCreationViewVM( @@ -408,7 +411,7 @@ namespace Tango.PPC.Jobs.ViewModels machine.SupportedColorSpaces.Count > 0 ? machine.SupportedColorSpaces : Enum.GetValues(typeof(ColorSpaces)).Cast<ColorSpaces>().Where(x => x.IsUserSpace() || (ApplicationManager.IsInTechnicianMode && x == ColorSpaces.Volume)).ToList() ); - var settings = SettingsManager.Default.GetOrCreate<JobsModuleSettings>(); + CatalogSelectionViewVM catalogVM = new CatalogSelectionViewVM(_catalogs.ToList(), _catalogs.ToList().SingleOrDefault(x => x.Guid == settings.LastSelectedCatalogGuid)); if (settings.LastJobType != null) { @@ -447,6 +450,24 @@ namespace Tango.PPC.Jobs.ViewModels { vm = await NotificationProvider.ShowDialog<JobCreationViewVM>(vm); if (!vm.DialogResult) return; + + if (vm.SelectedColorSpace == ColorSpaces.Catalog) + { + if (catalogVM.SelectedCatalog == null) + { + catalogVM.SelectedCatalog = _catalogs.FirstOrDefault(); + } + + if (_catalogs.Count == 0) + { + await NotificationProvider.ShowError("No color catalogs found. Please selected another color space."); + return; + } + else if (_catalogs.Count > 1) + { + catalogVM = await NotificationProvider.ShowDialog<CatalogSelectionViewVM>(catalogVM); + } + } } else { @@ -457,6 +478,12 @@ namespace Tango.PPC.Jobs.ViewModels settings.LastJobType = vm.SelectedJobType; settings.LastJobColorSpace = vm.SelectedColorSpace; + + if (vm.SelectedColorSpace == ColorSpaces.Catalog) + { + settings.LastSelectedCatalogGuid = catalogVM.SelectedCatalog.Guid; + } + settings.Save(); Job job = new Job(); @@ -475,6 +502,11 @@ namespace Tango.PPC.Jobs.ViewModels job.WindingMethodGuid = Adapter.WindingMethods.FirstOrDefault().Guid; job.SpoolTypeGuid = machine.DefaultSpoolType != null ? machine.DefaultSpoolTypeGuid : Adapter.SpoolTypes.FirstOrDefault().Guid; + if (vm.SelectedColorSpace == ColorSpaces.Catalog) + { + job.ColorCatalogGuid = catalogVM.SelectedCatalog.Guid; + } + if (Jobs.Count > 0) { job.JobIndex = Jobs.Max(x => x.JobIndex) + 1; @@ -679,12 +711,18 @@ namespace Tango.PPC.Jobs.ViewModels ExternalBridgeService.ColorProfileRequest += ExternalBridgeService_ColorProfileRequest; } - public override void OnApplicationReady() + public async override void OnApplicationReady() { base.OnApplicationReady(); StorageProvider.RegisterFileHandler(ExplorerFileDefinition.Job.Extension, HandleJobFileLoaded); StorageProvider.RegisterFileHandler(ExplorerFileDefinition.ColorProfile.Extension, HandleColorProfileFileLoaded); StorageProvider.RegisterFileHandler(ExplorerFileDefinition.Pulse.Extension, HandlePulseFileLoaded); + + //Load catalogs. + using (ObservablesContext c = ObservablesContext.CreateDefault()) + { + _catalogs = (await c.ColorCatalogs.ToListAsync()).ToObservableCollection(); + } } public override void OnNavigatedTo() |
