diff options
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs')
| -rw-r--r-- | Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobsViewVM.cs | 46 |
1 files changed, 32 insertions, 14 deletions
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 d29323412..bd6f95d44 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 @@ -225,6 +225,7 @@ namespace Tango.PPC.Jobs.ViewModels RegisterForMessage<JobRemovedMessage>(HandleJobRemovedMessage); RegisterForMessage<JobSavedMessage>(HandleJobSavedMessage); + RegisterForMessage<NavigatedToJobsModuleMessage>((x) => Filter = null); } #endregion @@ -271,15 +272,20 @@ namespace Tango.PPC.Jobs.ViewModels { LogManager.Log($"Job '{job.Name}' selected."); - if (!directlyToEdit) + RaiseMessage(new JobSelectedMessage() { Job = job, Context = _db }); + + if (!directlyToEdit && MachineProvider.MachineOperator.Status == Integration.Operation.MachineStatuses.ReadyToDye) { - await NavigationManager.NavigateTo<JobsModule>(nameof(JobSummeryView)); + await NavigationManager.NavigateWithObject<JobsModule, JobSummeryView, JobSummeryNavigationObject>(new JobSummeryNavigationObject() + { + Context = _db, + Job = job, + }); } else { await NavigationManager.NavigateTo<JobsModule>(nameof(JobView)); } - RaiseMessage(new JobSelectedMessage() { Job = job, Context = _db }); } /// <summary> @@ -306,7 +312,7 @@ namespace Tango.PPC.Jobs.ViewModels Jobs = jobs; DraftJobsCollectionView = new ListCollectionView(Jobs); DraftJobsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Job.LastUpdated), ListSortDirection.Descending)); - DraftJobsCollectionView.Filter = new Predicate<object>(x => + DraftJobsCollectionView.Filter = new Predicate<object>(x => { var job = x as Job; @@ -323,7 +329,7 @@ namespace Tango.PPC.Jobs.ViewModels HistoryJobsCollectionView = new ListCollectionView(Jobs); HistoryJobsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Job.LastUpdated), ListSortDirection.Descending)); - HistoryJobsCollectionView.Filter = new Predicate<object>(x => + HistoryJobsCollectionView.Filter = new Predicate<object>(x => { var job = x as Job; @@ -372,7 +378,7 @@ namespace Tango.PPC.Jobs.ViewModels JobCreationViewVM vm = new JobCreationViewVM( machine.SupportedJobTypes.Count > 0 ? machine.SupportedJobTypes : Enum.GetValues(typeof(JobTypes)).Cast<JobTypes>().ToList(), - machine.SupportedColorSpaces.Count > 0 ? machine.SupportedColorSpaces : Enum.GetValues(typeof(ColorSpaces)).Cast<ColorSpaces>().Where(x => x.IsUserSpace()).ToList() + 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>(); @@ -419,13 +425,14 @@ namespace Tango.PPC.Jobs.ViewModels job.CreationDate = DateTime.UtcNow; job.JobStatus = JobStatuses.Draft; job.JobType = vm.SelectedJobType; + job.EnableLubrication = true; job.ColorSpaceGuid = Adapter.ColorSpaces.FirstOrDefault(x => x.Code == vm.SelectedColorSpace.ToInt32()).Guid; job.MachineGuid = MachineProvider.Machine.Guid; job.UserGuid = AuthenticationProvider.CurrentUser.Guid; job.RmlGuid = machine.DefaultRml != null ? machine.DefaultRmlGuid : Adapter.Rmls.FirstOrDefault().Guid; job.WindingMethodGuid = Adapter.WindingMethods.FirstOrDefault().Guid; job.SpoolTypeGuid = machine.DefaultSpoolType != null ? machine.DefaultSpoolTypeGuid : Adapter.SpoolTypes.FirstOrDefault().Guid; - + if (Jobs.Count > 0) { job.JobIndex = Jobs.Max(x => x.JobIndex) + 1; @@ -529,13 +536,16 @@ namespace Tango.PPC.Jobs.ViewModels /// </summary> private void OnFilterChanged() { - if (SelectedCategory == JobsCategory.Draft) - { - DraftJobsCollectionView.Refresh(); - } - else if (SelectedCategory == JobsCategory.History) + if (DraftJobsCollectionView != null && HistoryJobsCollectionView != null) { - HistoryJobsCollectionView.Refresh(); + if (SelectedCategory == JobsCategory.Draft) + { + DraftJobsCollectionView.Refresh(); + } + else if (SelectedCategory == JobsCategory.History) + { + HistoryJobsCollectionView.Refresh(); + } } } @@ -590,13 +600,21 @@ namespace Tango.PPC.Jobs.ViewModels StorageProvider.RegisterFileHandler(ExplorerFileDefinition.Job.Extension, HandleJobFileLoaded); } + public override void OnNavigatedTo() + { + base.OnNavigatedTo(); + Filter = null; + } + #endregion #region Job Export private async void ExportJob() { - var selected_job = SelectedJobs.First(); + var selected_job = SelectedJobs.FirstOrDefault(); + if (selected_job == null) return; + ClearSelection(); var result = await NavigationManager. |
