From c5cde62cecfdd413e9902b26b30b0d4dfd05a24d Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 14 Mar 2019 13:25:32 +0200 Subject: Machine Studio v4.0.10 PPC v1.0.9 --- .../ViewModels/MainViewVM.cs | 41 +++++++++++++++++----- .../Views/JobView.xaml | 6 ++-- 2 files changed, 35 insertions(+), 12 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs index 35aca807c..04d2fae4b 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs @@ -46,6 +46,7 @@ using System.Data.Entity; using System.Runtime.ExceptionServices; using Tango.BL.Builders; using Tango.MachineStudio.Common.Navigation; +using System.Diagnostics; namespace Tango.MachineStudio.Developer.ViewModels { @@ -78,6 +79,7 @@ namespace Tango.MachineStudio.Developer.ViewModels private bool _dialog_shown; private bool _disable_gamut_check; private bool _rml_has_no_cct; + private TaskItem _preparingTaskItem; #region Properties @@ -739,8 +741,8 @@ namespace Tango.MachineStudio.Developer.ViewModels RemoveBrushStopCommand = new RelayCommand(RemoveSelectedBrushStops, () => SelectedBrushStop != null && CanWork); SaveJobCommand = new RelayCommand(SaveActiveJob, () => SelectedMachine != null && CanWork); DiscardJobCommand = new RelayCommand(BackToJobs, () => SelectedMachine != null && CanWork); - StartJobCommand = new RelayCommand(() => StartJob(), () => ActiveJob != null && CanWork && !IsJobRunning && MachineOperator != null && !MachineOperator.MachineEventsStateProvider.Events.ToList().Exists(x => x.Actions.Contains(BL.Enumerations.EventTypeActions.PreventJob))); - StartJobAndRecordCommand = new RelayCommand(StartJobAndRecord, () => _dataCaptureVM != null && !_dataCaptureVM.Recorder.IsRecording && !_dataCaptureVM.Player.IsPlaying && ActiveJob != null && !IsJobRunning && MachineOperator != null && !MachineOperator.MachineEventsStateProvider.Events.ToList().Exists(x => x.Actions.Contains(BL.Enumerations.EventTypeActions.PreventJob))); + StartJobCommand = new RelayCommand(() => StartJob(), () => ActiveJob != null && CanWork && !IsJobRunning && MachineOperator != null); + StartJobAndRecordCommand = new RelayCommand(StartJobAndRecord, () => _dataCaptureVM != null && !_dataCaptureVM.Recorder.IsRecording && !_dataCaptureVM.Player.IsPlaying && ActiveJob != null && !IsJobRunning && MachineOperator != null); StopJobCommand = new RelayCommand(StopJob, () => IsJobRunning && CanWork); CloseJobCompletionStatusCommand = new RelayCommand(CloseJobCompletionStatusBar); LoadJobCommand = new RelayCommand(() => LoadSelectedJob(), () => SelectedMachineJob != null && CanWork); @@ -956,6 +958,17 @@ namespace Tango.MachineStudio.Developer.ViewModels MachineOperator.ResumingJob -= MachineOperator_ResumingJob; MachineOperator.ResumingJob += MachineOperator_ResumingJob; + + MachineOperator.PreparingJobProgress -= MachineOperator_PreparingJobProgress; + MachineOperator.PreparingJobProgress += MachineOperator_PreparingJobProgress; + } + } + + private void MachineOperator_PreparingJobProgress(object sender, PreparingJobProgressEventArgs e) + { + if (_preparingTaskItem != null) + { + _preparingTaskItem.Message = $"Preparing job for printing {(e.Progress / e.Total * 100d).ToString("0.0")}%..."; } } @@ -991,6 +1004,7 @@ namespace Tango.MachineStudio.Developer.ViewModels private void MachineEventsStateProvider_EventsChanged(object sender, IEnumerable changedEvents) { InvokeUI(StartJobCommand.RaiseCanExecuteChanged); + InvokeUI(StartJobAndRecordCommand.RaiseCanExecuteChanged); } /// @@ -1277,7 +1291,7 @@ namespace Tango.MachineStudio.Developer.ViewModels /// /// Starts the job. /// - private void StartJob(Func resumeFunc = null) + private async void StartJob(Func resumeFunc = null) { LogManager.Log(String.Format("Starting job {0}...", ActiveJob.Name)); if (MachineOperator == null || MachineOperator.State != TransportComponentState.Connected) @@ -1301,22 +1315,27 @@ namespace Tango.MachineStudio.Developer.ViewModels IsJobFailed = false; IsJobCanceled = false; IsJobCompleted = false; - IsJobRunning = true; - ShowJobStatus = true; RunningJob = ActiveJob; _runningJobEstimatedDuration = EstimatedDuration; RunningJobSegments = RunningJob.EffectiveSegments.ToList(); - _navigation.NavigateTo(DeveloperNavigationView.RunningJobView); - try { + IsFree = false; LogManager.Log("Sending job to machine operator..."); if (resumeFunc == null) { - JobHandler = MachineOperator.Print(ActiveJob, SelectedProcessParametersTable); + using (var item = _notification.PushTaskItem("Preparing job for printing...")) + { + _preparingTaskItem = item; + JobHandler = await MachineOperator.Print(ActiveJob, SelectedProcessParametersTable); + } + + _navigation.NavigateTo(DeveloperNavigationView.RunningJobView); + IsJobRunning = true; + ShowJobStatus = true; } else { @@ -1403,6 +1422,10 @@ namespace Tango.MachineStudio.Developer.ViewModels SetJobFailed(); StopRecordingIfInProgress(); } + finally + { + IsFree = true; + } } /// @@ -2077,7 +2100,7 @@ namespace Tango.MachineStudio.Developer.ViewModels newJob.ColorSpace = _machineDbContext.ColorSpaces.FirstOrDefault(); newJob.Machine = SelectedMachine; - + SelectedMachine.Jobs.Add(newJob); var segment = newJob.AddSolidSegment(); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml index 1057f7c84..9504d5769 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml @@ -432,7 +432,7 @@ - + @@ -866,8 +866,8 @@ - - Enable Color Conversion + + Enable Gradient Generation -- cgit v1.3.1