aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-07-11 20:05:13 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-07-11 20:05:13 +0300
commit14cd4ba2174c3e0bd74f58f2cc72769fd326a6e6 (patch)
tree78901a0b5053610ce2f86b436a037f17715d6368 /Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs
parent009a02d57e244e9a8ed5d70fc0743f10f68f5a33 (diff)
downloadTango-14cd4ba2174c3e0bd74f58f2cc72769fd326a6e6.tar.gz
Tango-14cd4ba2174c3e0bd74f58f2cc72769fd326a6e6.zip
Working on PPC.
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.cs41
1 files changed, 36 insertions, 5 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 82cfc3456..b23e8b8ed 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
@@ -181,6 +181,11 @@ namespace Tango.PPC.Jobs.ViewModels
/// </summary>
public RelayCommand StartSampleDyeCommand { get; set; }
+ /// <summary>
+ /// Gets or sets the dye command.
+ /// </summary>
+ public RelayCommand DyeCommand { get; set; }
+
#endregion
#region Constructors
@@ -230,6 +235,7 @@ namespace Tango.PPC.Jobs.ViewModels
_check_gamut_thread.IsBackground = true;
StartSampleDyeCommand = new RelayCommand(StartSampleDye);
+ DyeCommand = new RelayCommand(StartJob, CanStartJob);
}
#endregion
@@ -260,6 +266,19 @@ namespace Tango.PPC.Jobs.ViewModels
}
}
+ private void StartJob()
+ {
+ ApplicationManager.ConnectedMachine.Print(Job);
+ NavigationManager.NavigateTo<JobsModule>(nameof(JobProgressView));
+ }
+
+ private bool CanStartJob()
+ {
+ return
+ Job != null &&
+ !Job.Segments.SelectMany(x => x.BrushStops).ToList().Exists(x => x.IsOutOfGamut);
+ }
+
#endregion
#region Segments Management
@@ -417,10 +436,10 @@ namespace Tango.PPC.Jobs.ViewModels
/// <summary>
/// Starts a sample dye.
/// </summary>
- private async void StartSampleDye()
+ private void StartSampleDye()
{
Job sampleDyeJob = Job.Clone();
- sampleDyeJob.Name += " sample";
+ sampleDyeJob.Name = Job.Name + " (sample)";
if (Job.JobType == BL.Enumerations.JobTypes.Embroidery)
{
@@ -436,7 +455,9 @@ namespace Tango.PPC.Jobs.ViewModels
}
}
- await NavigationManager.NavigateForResult<JobsModule, JobProgressView, Object, Job>(sampleDyeJob);
+ ApplicationManager.ConnectedMachine.Print(sampleDyeJob);
+
+ NavigationManager.NavigateTo<JobsModule>(nameof(JobProgressView));
}
#endregion
@@ -458,6 +479,11 @@ namespace Tango.PPC.Jobs.ViewModels
stop.IsOutOfGamut = TangoColorConverter.IsOutOfGamut(stop);
stop.OutOfGamutChecked = true;
}
+
+ InvokeUI(() =>
+ {
+ DyeCommand.RaiseCanExecuteChanged();
+ });
}
}
}
@@ -479,6 +505,8 @@ namespace Tango.PPC.Jobs.ViewModels
/// </summary>
public async override void OnNavigatedTo()
{
+ if (_job_to_load == null) return;
+
NotificationProvider.SetGlobalBusyMessage("Loading job details...");
_can_navigate_back = false;
@@ -518,14 +546,17 @@ namespace Tango.PPC.Jobs.ViewModels
{
NotificationProvider.ReleaseGlobalBusyMessage();
});
+
+ _job_to_load = null;
}
+
/// <summary>
- /// Called before the navigation system navigates from this object.
+ /// Called before the navigation system navigates back from this object.
/// Return false to abort the navigation.
/// </summary>
/// <returns></returns>
- public async override Task<bool> OnNavigateOutRequest()
+ public async override Task<bool> OnNavigateBackRequest()
{
bool result = true;