diff options
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 | 48 |
1 files changed, 27 insertions, 21 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 f0cf87079..c7946ee6a 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 @@ -396,7 +396,8 @@ namespace Tango.PPC.Jobs.ViewModels { LogManager.Log($"Loading selected job '{_job_to_load.Name}'..."); - NotificationProvider.SetGlobalBusyMessage("Loading job details..."); + //NotificationProvider.SetGlobalBusyMessage("Loading job details..."); + IsFree = false; _can_navigate_back = false; @@ -433,10 +434,6 @@ namespace Tango.PPC.Jobs.ViewModels SegmentsCollectionView = CollectionViewSource.GetDefaultView(Job.Segments); SegmentsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Segment.SegmentIndex), ListSortDirection.Ascending)); - InvokeUIOnIdle(() => - { - NotificationProvider.ReleaseGlobalBusyMessage(); - }); _job_to_load = null; } @@ -471,10 +468,16 @@ namespace Tango.PPC.Jobs.ViewModels LogManager.Log(ex, $"Error loading job '{_job_to_load.Name}'"); await NotificationProvider.ShowError("An error occurred while trying to load the selected job."); } + finally + { + InvokeUIOnIdle(() => + { + IsFree = true; + //NotificationProvider.ReleaseGlobalBusyMessage(); + }); + } } - - /// <summary> /// Saves the job. /// </summary> @@ -545,18 +548,18 @@ namespace Tango.PPC.Jobs.ViewModels /// <summary> /// Starts the job. /// </summary> - private void StartJob() + private async void StartJob() { try { LogManager.Log("Start job command pressed. Starting job and navigating to job progress view..."); - PrintingManager.Print(Job, _db); - NavigationManager.NavigateTo<JobsModule>(nameof(JobProgressView)); + await PrintingManager.Print(Job, _db); + await NavigationManager.NavigateTo<JobsModule>(nameof(JobProgressView)); } catch (Exception ex) { LogManager.Log(ex, "Could not start the current job."); - NotificationProvider.ShowError($"Cannot start job.\n{ex.Message}."); + await NotificationProvider.ShowError($"Cannot start job.\n{ex.Message}."); } } @@ -764,8 +767,11 @@ namespace Tango.PPC.Jobs.ViewModels /// <param name="brushStop">The brush stop.</param> public void OnBrushStopFieldValueChanged(BrushStop brushStop) { - brushStop.Corrected = false; - brushStop.OutOfGamutChecked = false; + if (brushStop != null) + { + brushStop.Corrected = false; + brushStop.OutOfGamutChecked = false; + } } /// <summary> @@ -802,20 +808,20 @@ namespace Tango.PPC.Jobs.ViewModels /// <summary> /// Starts a sample dye. /// </summary> - private void StartSampleDye() + private async void StartSampleDye() { try { LogManager.Log("Sample dye command pressed..."); - PrintingManager.PrintSample(Job, _db); + await PrintingManager.PrintSample(Job, _db); - NavigationManager.NavigateTo<JobsModule>(nameof(JobProgressView)); + await NavigationManager.NavigateTo<JobsModule>(nameof(JobProgressView)); } catch (Exception ex) { LogManager.Log(ex, $"Error executing sample dye for job {Job.Name}."); - NotificationProvider.ShowError("An error occurred while trying to execute the sample dye."); + await NotificationProvider.ShowError("An error occurred while trying to execute the sample dye."); } } @@ -940,7 +946,7 @@ namespace Tango.PPC.Jobs.ViewModels /// <summary> /// Starts the fine tuning. /// </summary> - private void StartFineTuning() + private async void StartFineTuning() { try { @@ -948,14 +954,14 @@ namespace Tango.PPC.Jobs.ViewModels _jobs_fine_tune_items[Job.Guid] = FineTuneItems.ToList(); - PrintingManager.PrintFineTuning(Job, _db, FineTuneItems); + await PrintingManager.PrintFineTuning(Job, _db, FineTuneItems); - NavigationManager.NavigateTo<JobsModule>(nameof(JobProgressView)); + await NavigationManager.NavigateTo<JobsModule>(nameof(JobProgressView)); } catch (Exception ex) { LogManager.Log(ex, "Error executing fine tuning job."); - NotificationProvider.ShowError("An error occurred while trying to start the fine tuning job."); + await NotificationProvider.ShowError("An error occurred while trying to start the fine tuning job."); } } |
