aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-07-18 21:23:09 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-07-18 21:23:09 +0300
commitc90b4e2e753a0a86ebb2af4dc827cda206b148b6 (patch)
tree5ac04f62e1644099648ead833e65b67c19eaf226
parent210ec31f0a6ed9459b5cb7fd8b10ebe0166c2fb1 (diff)
downloadTango-c90b4e2e753a0a86ebb2af4dc827cda206b148b6.tar.gz
Tango-c90b4e2e753a0a86ebb2af4dc827cda206b148b6.zip
Fixed several possible issues with PPC start/stop dyeing buttons visibility.
Prevented navigation conflicts raised by impatient users.
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobSummeryViewVM.cs10
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs12
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs9
3 files changed, 30 insertions, 1 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 365075d4a..d6eb3bc63 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
@@ -26,6 +26,7 @@ namespace Tango.PPC.Jobs.ViewModels
{
private ObservablesContext _context;
private bool _canStartJob;
+ private bool _startingJob;
private bool _isPreparingJob;
/// <summary>
@@ -96,12 +97,17 @@ namespace Tango.PPC.Jobs.ViewModels
/// </summary>
private async void StartJob()
{
+ if (_startingJob) return;
+
+ _startingJob = true;
+
try
{
LogManager.Log("Start job command pressed. Starting job and navigating to job progress view...");
await PrintingManager.Print(Job, _context);
await NavigationManager.NavigateTo<JobsModule>(false, nameof(JobProgressView));
+ _startingJob = false;
}
catch (InsufficientLiquidQuantityException)
{
@@ -112,6 +118,10 @@ namespace Tango.PPC.Jobs.ViewModels
LogManager.Log(ex, "Could not start the current job.");
await NotificationProvider.ShowError($"{ex.Message}");
}
+ finally
+ {
+ _startingJob = false;
+ }
}
/// <summary>
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 efaf98966..665847081 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
@@ -56,6 +56,7 @@ namespace Tango.PPC.Jobs.ViewModels
private ActionTimer _volumeConversionTimer;
private IColorConverter _converter;
private string _current_job_string;
+ private bool startingJob = false;
#region Properties
@@ -545,7 +546,7 @@ namespace Tango.PPC.Jobs.ViewModels
}
catch (Exception ex)
{
- LogManager.Log(ex, $"Error loading job '{_job_to_load.Name}'");
+ LogManager.Log(ex, $"Error loading job '{(_job_to_load != null ? _job_to_load.Name : "null")}'");
await NotificationProvider.ShowError("An error occurred while trying to load the selected job.");
_can_navigate_back = true;
await NavigationManager.NavigateBack();
@@ -647,11 +648,16 @@ namespace Tango.PPC.Jobs.ViewModels
/// </summary>
private async void StartJob()
{
+ if (startingJob) return;
+
try
{
+ Debug.WriteLine("Job Starting...");
+ startingJob = true;
LogManager.Log("Start job command pressed. Starting job and navigating to job progress view...");
var handler = await PrintingManager.Print(Job, _db);
await NavigationManager.NavigateTo<JobsModule>(nameof(JobProgressView));
+ startingJob = false;
}
catch (InsufficientLiquidQuantityException)
{
@@ -662,6 +668,10 @@ namespace Tango.PPC.Jobs.ViewModels
LogManager.Log(ex, "Could not start the current job.");
await NotificationProvider.ShowError($"{ex.Message}.");
}
+ finally
+ {
+ startingJob = false;
+ }
}
/// <summary>
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs
index 3502648d4..7c71ef3d0 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Navigation/DefaultNavigationManager.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
@@ -501,6 +502,10 @@ namespace Tango.PPC.UI.Navigation
private void NotifyOnBeforeNavigated(object fromVM, object toVM)
{
+ IsBackEnabled = false;
+
+ if (fromVM == toVM) return;
+
if (fromVM is PPCViewModel)
{
(fromVM as PPCViewModel)?.OnBeforeNavigatedFrom();
@@ -514,6 +519,10 @@ namespace Tango.PPC.UI.Navigation
private void NotifyOnNavigated(object fromVM, object toVM)
{
+ IsBackEnabled = true;
+
+ if (fromVM == toVM) return;
+
if (fromVM is PPCViewModel)
{
(fromVM as PPCViewModel)?.OnNavigatedFrom();