aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-11-26 05:49:22 +0200
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-11-26 05:49:22 +0200
commita431b1dd895834a517bf65a9cddc88162d432fd2 (patch)
treee65faea4952137e50f3217ac6bebbf6540548abb /Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs
parent01fb003c742e7f7ac086e9340254e8d0bd606214 (diff)
downloadTango-a431b1dd895834a517bf65a9cddc88162d432fd2.tar.gz
Tango-a431b1dd895834a517bf65a9cddc88162d432fd2.zip
Moved job app bar item control to main view model by current navigation vm.
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs')
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs23
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/MainViewVM.cs31
2 files changed, 31 insertions, 23 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs
index b4a30cb39..8d5bd284d 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobProgressViewVM.cs
@@ -26,7 +26,6 @@ namespace Tango.PPC.Jobs.ViewModels
{
private StopPrintingButton _stop_job_btn;
private JobHandler _handler;
- private JobProgressAppBarItem _appBarItem;
#region Properties
@@ -136,24 +135,6 @@ namespace Tango.PPC.Jobs.ViewModels
}
/// <summary>
- /// Called when the navigation system has navigated from this VM view.
- /// </summary>
- public override void OnNavigatedFrom()
- {
- base.OnNavigatedFrom();
-
- if (MachineProvider.MachineOperator.IsPrinting && _handler != null && !_handler.IsCanceled)
- {
- _appBarItem = NotificationProvider.PushAppBarItem<JobProgressAppBarItem>();
- _appBarItem.Pressed += (_, __) =>
- {
- _appBarItem?.Close();
- NavigationManager.NavigateTo<JobsModule>(nameof(JobProgressView));
- };
- }
- }
-
- /// <summary>
/// Called when the navigation system has navigated to this VM view.
/// </summary>
public override void OnNavigatedTo()
@@ -162,8 +143,6 @@ namespace Tango.PPC.Jobs.ViewModels
IsDisplayJobOutline = false;
- _appBarItem?.Close();
-
if (_handler != null && !_handler.Status.IsFailed)
{
_stop_job_btn.Push();
@@ -232,8 +211,6 @@ namespace Tango.PPC.Jobs.ViewModels
_stop_job_btn.Pop();
}
- _appBarItem?.Close();
-
if (_handler != null)
{
_handler.StatusChanged -= JobHandler_StatusChanged;
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/MainViewVM.cs
index fc178dea8..579e1e2f7 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/MainViewVM.cs
@@ -11,6 +11,7 @@ using Tango.Integration.Operation;
using Tango.PPC.Common;
using Tango.PPC.Common.Notifications;
using Tango.PPC.Common.Notifications.NotificationItems;
+using Tango.PPC.Jobs.AppBarItems;
using Tango.PPC.Jobs.Messages;
using Tango.PPC.Jobs.NavigationObjects;
using Tango.PPC.Jobs.Views;
@@ -24,7 +25,9 @@ namespace Tango.PPC.Jobs.ViewModels
public class MainViewVM : PPCViewModel
{
private NotificationItem _last_failed_job_notification;
+ private JobHandler _handler;
private bool resuming;
+ private JobProgressAppBarItem _appBarItem;
/// <summary>
/// Called when the application has been started.
@@ -35,10 +38,38 @@ namespace Tango.PPC.Jobs.ViewModels
MachineProvider.MachineOperator.PrintingFailed += MachineOperator_PrintingFailed;
MachineProvider.MachineOperator.ResumingJob += MachineOperator_ResumingJob;
MachineProvider.MachineOperator.PrintingStarted += MachineOperator_PrintingStarted;
+ MachineProvider.MachineOperator.PrintingEnded += MachineOperator_PrintingEnded;
+ NavigationManager.CurrentVMChanged += NavigationManager_CurrentVMChanged;
+ }
+
+ private void MachineOperator_PrintingEnded(object sender, PrintingEventArgs e)
+ {
+ _appBarItem?.Close();
+ _appBarItem = null;
+ }
+
+ private void NavigationManager_CurrentVMChanged(object sender, PPCViewModel vm)
+ {
+ if (vm.GetType() == typeof(JobProgressViewVM))
+ {
+ _appBarItem?.Close();
+ _appBarItem = null;
+ }
+ else if (vm.GetType() != typeof(JobSummeryViewVM) && _appBarItem == null && MachineProvider.MachineOperator.IsPrinting && _handler != null && !_handler.IsCanceled)
+ {
+ _appBarItem = NotificationProvider.PushAppBarItem<JobProgressAppBarItem>();
+ _appBarItem.Pressed += (_, __) =>
+ {
+ _appBarItem?.Close();
+ NavigationManager.NavigateTo<JobsModule>(nameof(JobProgressView));
+ };
+ }
}
private void MachineOperator_PrintingStarted(object sender, PrintingEventArgs e)
{
+ _handler = e.JobHandler;
+
if (resuming)
{
resuming = false;