From 8a1e772f025eaf3bfdf17905d9e33c460993e559 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 1 Jul 2019 17:56:49 +0300 Subject: Many bug fixes !!! --- .../Converters/MachineEventToViewConverter.cs | 24 +++++++---- .../Tango.PPC.Events/EventsViews/JobEventView.xaml | 27 +++++++++++++ .../EventsViews/JobEventView.xaml.cs | 28 +++++++++++++ .../Tango.PPC.Events/Tango.PPC.Events.csproj | 9 ++++- .../Tango.PPC.Events/ViewModels/MainViewVM.cs | 6 ++- .../Modules/Tango.PPC.Events/Views/MainView.xaml | 2 +- .../Dialogs/BasicColorCorrectionView.xaml | 25 ++++++++++++ .../Tango.PPC.Jobs/ViewModels/JobSummeryViewVM.cs | 2 +- .../Modules/Tango.PPC.Jobs/ViewModels/JobViewVM.cs | 47 +++++++++++++++++----- .../Modules/Tango.PPC.Jobs/Views/JobsView.xaml.cs | 30 +++++++------- .../EventLogging/DefaultEventLogger.cs | 45 +++++++++++++++++++++ .../Connectivity/DefaultConnectivityProvider.cs | 35 ++++++++++++++++ .../Printing/DefaultPrintingManager.cs | 22 ++++++++++ .../Visual_Studio/PPC/Tango.PPC.UI/app.manifest | 2 +- 14 files changed, 268 insertions(+), 36 deletions(-) create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/JobEventView.xaml create mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/JobEventView.xaml.cs (limited to 'Software/Visual_Studio/PPC') diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Converters/MachineEventToViewConverter.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Converters/MachineEventToViewConverter.cs index b0d00bf9f..47c9e0ddf 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Converters/MachineEventToViewConverter.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Converters/MachineEventToViewConverter.cs @@ -7,30 +7,40 @@ using System.Threading.Tasks; using System.Windows; using System.Windows.Data; using Tango.BL.Entities; +using Tango.BL.Enumerations; +using Tango.PPC.Events.EventsViews; namespace Tango.PPC.Events.Converters { public class MachineEventToViewConverter : IValueConverter { - private static List _views = new List(); + private static Dictionary _eventViews = new Dictionary(); + + static MachineEventToViewConverter() + { + _eventViews.Add(EventTypes.JOB_STARTED, typeof(JobEventView)); + _eventViews.Add(EventTypes.JOB_ABORTED, typeof(JobEventView)); + _eventViews.Add(EventTypes.JOB_COMPLETED, typeof(JobEventView)); + _eventViews.Add(EventTypes.JOB_FAILED, typeof(JobEventView)); + } public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { MachinesEvent ev = value as MachinesEvent; + FrameworkElement view = null; if (ev != null) { - FrameworkElement view = _views.SingleOrDefault(x => x.GetType() == typeof(EventsViews.GeneralView)); - - if (view != null) + if (_eventViews.ContainsKey(ev.Type)) { - return view; + view = Activator.CreateInstance(_eventViews[ev.Type]) as FrameworkElement; } else { - view = Activator.CreateInstance(); - return view; + view = Activator.CreateInstance(); } + + return view; } else { diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/JobEventView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/JobEventView.xaml new file mode 100644 index 000000000..d283b08d3 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/JobEventView.xaml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/JobEventView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/JobEventView.xaml.cs new file mode 100644 index 000000000..89faa3a85 --- /dev/null +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/EventsViews/JobEventView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.PPC.Events.EventsViews +{ + /// + /// Interaction logic for JobEventView.xaml + /// + public partial class JobEventView : UserControl + { + public JobEventView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Tango.PPC.Events.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Tango.PPC.Events.csproj index e446e3812..e2133e585 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Tango.PPC.Events.csproj +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Tango.PPC.Events.csproj @@ -72,6 +72,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + MSBuild:Compile Designer @@ -91,6 +95,9 @@ GeneralView.xaml + + JobEventView.xaml + Code @@ -173,7 +180,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/ViewModels/MainViewVM.cs index 997ea70d5..d2a730cd7 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/ViewModels/MainViewVM.cs @@ -97,7 +97,7 @@ namespace Tango.PPC.Events.ViewModels using (var db = ObservablesContext.CreateDefault()) { var last_week = DateTime.UtcNow.AddDays(-7); - HistoryEvents = (await db.MachinesEvents.Where(x => x.MachineGuid == MachineProvider.Machine.Guid && x.DateTime > last_week).Take(100).Include(x => x.EventType).Where(x => (EventTypeNotificationTimes)x.EventType.EventNotificationTime != EventTypeNotificationTimes.None).ToListAsync()).OrderByDescending(x => x.DateTime).ToObservableCollection(); + HistoryEvents = (await db.MachinesEvents.Where(x => x.MachineGuid == MachineProvider.Machine.Guid && x.DateTime > last_week).Take(100).Include(x => x.EventType).Where(x => (EventTypeNotificationTimes)x.EventType.EventNotificationTime != EventTypeNotificationTimes.None || x.EventType.Code == (int)EventTypes.JOB_FAILED || x.EventType.Code == (int)EventTypes.JOB_STARTED || x.EventType.Code == (int)EventTypes.JOB_COMPLETED || x.EventType.Code == (int)EventTypes.JOB_ABORTED).ToListAsync()).OrderByDescending(x => x.DateTime).ToObservableCollection(); } MachineProvider.MachineOperator.StatusChanged += MachineOperator_StatusChanged; @@ -160,6 +160,10 @@ namespace Tango.PPC.Events.ViewModels _notifications.Add(new KeyValuePair(ev.EventType.Type, notificationItem)); } + else if (ev.IsJobProgressEvent()) + { + HistoryEvents.Insert(0, ev); + } }); } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Views/MainView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Views/MainView.xaml index f263e4b7b..af42a5576 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Events/Views/MainView.xaml @@ -135,7 +135,7 @@ - + diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Dialogs/BasicColorCorrectionView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Dialogs/BasicColorCorrectionView.xaml index 9583d0738..4fcccc9e5 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Dialogs/BasicColorCorrectionView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Dialogs/BasicColorCorrectionView.xaml @@ -27,10 +27,35 @@ + + + , , + + + + + , + , + + 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 1a980fc4a..b413758c8 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 @@ -89,7 +89,7 @@ namespace Tango.PPC.Jobs.ViewModels catch (Exception ex) { LogManager.Log(ex, "Could not start the current job."); - await NotificationProvider.ShowError($"Cannot start job.\n{ex.Message}."); + await NotificationProvider.ShowError($"{ex.Message}"); } } 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 3a777e142..0d1d2f3cb 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 @@ -407,7 +407,7 @@ namespace Tango.PPC.Jobs.ViewModels _check_gamut_thread = new Thread(CheckGamutThreadMethod); _check_gamut_thread.IsBackground = true; - StartSampleDyeCommand = new RelayCommand(StartSampleDye); + StartSampleDyeCommand = new RelayCommand(StartSampleDye, CanStartJob); DyeCommand = new RelayCommand(StartJob, CanStartJob); ApproveSampleCommand = new RelayCommand(ApproveSampleDye); @@ -415,7 +415,7 @@ namespace Tango.PPC.Jobs.ViewModels AnotherSampleCommand = new RelayCommand(DyeAnotherSample); InvokeFineTuningPaletteCommand = new RelayCommand(InvokeFineTuningPalette); ResetFineTuningCommand = new RelayCommand(ResetFineTuning); - StartFineTuningCommand = new RelayCommand(StartFineTuning, () => FineTuneItems.Any(x => x.IsSelected)); + StartFineTuningCommand = new RelayCommand(StartFineTuning, () => FineTuneItems.Any(x => x.IsSelected) && CanStartJob()); RepeatFineTuningCommand = new RelayCommand(RepeatFineTuning); ApproveFineTuningCommand = new RelayCommand(ApproveFineTuning); OpenTwineCatalogCommand = new RelayCommand(OpenTwineCatalog); @@ -463,6 +463,8 @@ namespace Tango.PPC.Jobs.ViewModels Job.RmlChanged -= OnRmlChanged; Job.RmlChanged += OnRmlChanged; + Job.NameChanged -= Job_NameChanged; + Job.NameChanged += Job_NameChanged; Job.ValidateOnPropertyChanged = true; @@ -490,6 +492,7 @@ namespace Tango.PPC.Jobs.ViewModels SegmentsCollectionView = CollectionViewSource.GetDefaultView(Job.Segments); SegmentsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Segment.SegmentIndex), ListSortDirection.Ascending)); + ResetFineTuning(); _job_to_load = null; } @@ -517,7 +520,11 @@ namespace Tango.PPC.Jobs.ViewModels View.DisplayFineTuning(); } + ValidateBrushStops(); + DyeCommand.RaiseCanExecuteChanged(); + StartSampleDyeCommand.RaiseCanExecuteChanged(); + StartFineTuningCommand.RaiseCanExecuteChanged(); } catch (Exception ex) { @@ -534,6 +541,11 @@ namespace Tango.PPC.Jobs.ViewModels } } + private void Job_NameChanged(object sender, string e) + { + DyeCommand.RaiseCanExecuteChanged(); + } + /// /// Saves the job. /// @@ -564,12 +576,17 @@ namespace Tango.PPC.Jobs.ViewModels Job.LastUpdated = DateTime.UtcNow; Job.JobStatus = BL.Enumerations.JobStatuses.Draft; await _db.SaveChangesAsync(); - RaiseMessage(new JobSavedMessage() { Job = Job }); if (displayNotification) { await NotificationProvider.ShowInfo(String.Format("Job '{0}' saved successfully.", Job.Name)); } + + RaiseMessage(new JobSavedMessage() { Job = Job }); + } + else + { + await NotificationProvider.ShowError($"Error saving job. {Job.ValidationErrors.FirstOrDefault()}"); } } catch (Exception ex) @@ -617,7 +634,7 @@ namespace Tango.PPC.Jobs.ViewModels catch (Exception ex) { LogManager.Log(ex, "Could not start the current job."); - await NotificationProvider.ShowError($"Cannot start job.\n{ex.Message}."); + await NotificationProvider.ShowError($"{ex.Message}."); } } @@ -627,7 +644,7 @@ namespace Tango.PPC.Jobs.ViewModels private bool CanStartJob() { return - Job != null && + Job != null && Job.Validate(_db) && !Job.Segments.SelectMany(x => x.BrushStops).ToList().Exists(x => x.IsOutOfGamut); } @@ -653,6 +670,8 @@ namespace Tango.PPC.Jobs.ViewModels var replacement = CoatsCatalogItems.SingleOrDefault(x => x.Name == stop.ColorCatalog.Name); stop.ColorCatalog = replacement; } + + ResetFineTuning(); } #endregion @@ -748,6 +767,8 @@ namespace Tango.PPC.Jobs.ViewModels _db.Segments.Remove(segment); ArrangeSegmentsIndices(); + + DyeCommand.RaiseCanExecuteChanged(); } } catch (Exception ex) @@ -815,8 +836,9 @@ namespace Tango.PPC.Jobs.ViewModels if (brushStop.Segment.BrushStops.Count > 2) { LogManager.Log($"removing brush stop {brushStop.StopIndex} from segment {brushStop.Segment.SegmentIndex}."); + var segment = brushStop.Segment; _db.BrushStops.Remove(brushStop); - ArrangeBrushStopsIndices(brushStop.Segment); + ArrangeBrushStopsIndices(segment); } else { @@ -946,6 +968,11 @@ namespace Tango.PPC.Jobs.ViewModels } } + private bool ValidateBrushStops() + { + return Job.Segments.SelectMany(x => x.BrushStops).ToList().All(x => x.Validate(_db)); + } + #endregion #region Job Selection Message @@ -979,7 +1006,7 @@ namespace Tango.PPC.Jobs.ViewModels catch (Exception ex) { LogManager.Log(ex, $"Error executing sample dye for job {Job.Name}."); - await NotificationProvider.ShowError("An error occurred while trying to execute the sample dye."); + await NotificationProvider.ShowError(ex.Message); } } @@ -1119,7 +1146,7 @@ namespace Tango.PPC.Jobs.ViewModels catch (Exception ex) { LogManager.Log(ex, "Error executing fine tuning job."); - await NotificationProvider.ShowError("An error occurred while trying to start the fine tuning job."); + await NotificationProvider.ShowError(ex.Message); } } @@ -1177,7 +1204,7 @@ namespace Tango.PPC.Jobs.ViewModels { Thread.Sleep(500); - if (Job != null && IsVisible && (Job.ColorSpace != null && (Job.ColorSpace.Code == BL.Enumerations.ColorSpaces.RGB.ToInt32() || Job.ColorSpace.Code == BL.Enumerations.ColorSpaces.LAB.ToInt32()))) + if (Job != null && Job.Rml.Ccts.Count > 0 && IsVisible && (Job.ColorSpace != null && (Job.ColorSpace.Code == BL.Enumerations.ColorSpaces.RGB.ToInt32() || Job.ColorSpace.Code == BL.Enumerations.ColorSpaces.LAB.ToInt32()))) { var brushStops = Job.Segments.SelectMany(x => x.BrushStops).Where(x => !x.Corrected && !x.OutOfGamutChecked).ToList(); @@ -1199,6 +1226,8 @@ namespace Tango.PPC.Jobs.ViewModels InvokeUI(() => { DyeCommand.RaiseCanExecuteChanged(); + StartSampleDyeCommand.RaiseCanExecuteChanged(); + StartFineTuningCommand.RaiseCanExecuteChanged(); }); } } diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobsView.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobsView.xaml.cs index 2653179e1..23785881d 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobsView.xaml.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobsView.xaml.cs @@ -28,23 +28,23 @@ namespace Tango.PPC.Jobs.Views TangoIOC.Default.Register(this); } - private void TouchNavigationLinks_SelectionChanged(object sender, SelectionChangedEventArgs e) + private async void TouchNavigationLinks_SelectionChanged(object sender, SelectionChangedEventArgs e) { - //if (dataGridJobs != null) - //{ - // await Task.Delay(200); + if (dataGridJobs != null) + { + await Task.Delay(200); - // if (navigationLinks.SelectedIndex == 0) - // { - // dataGridJobs.LayoutRows(false); - // dataGridJobs.ScrollViewer.ScrollToTop(); - // } - // else - // { - // dataGridJobsHistory.LayoutRows(false); - // dataGridJobsHistory.ScrollViewer.ScrollToTop(); - // } - //} + if (navigationLinks.SelectedIndex == 0) + { + dataGridJobs.LayoutRows(false); + dataGridJobs.ScrollViewer.ScrollToTop(); + } + else + { + dataGridJobsHistory.LayoutRows(false); + dataGridJobsHistory.ScrollViewer.ScrollToTop(); + } + } } public void ScrollToTop() diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/DefaultEventLogger.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/DefaultEventLogger.cs index 7ccb76858..f9674e409 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/DefaultEventLogger.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/EventLogging/DefaultEventLogger.cs @@ -80,6 +80,11 @@ namespace Tango.PPC.Common.EventLogging _machineProvider.MachineOperator.RequestFailed += Machine_RequestFailed; _machineProvider.MachineOperator.ResponseReceived += Machine_ResponseReceived; _machineProvider.MachineOperator.StateChanged += MachineOperator_StateChanged; + _machineProvider.MachineOperator.PrintingStarted += MachineOperator_PrintingStarted; + _machineProvider.MachineOperator.PrintingAborted += MachineOperator_PrintingAborted; + _machineProvider.MachineOperator.PrintingCompleted += MachineOperator_PrintingCompleted; + _machineProvider.MachineOperator.PrintingFailed += MachineOperator_PrintingFailed; + } #endregion @@ -114,6 +119,46 @@ namespace Tango.PPC.Common.EventLogging #region Event Handlers + /// + /// Handles the PrintingFailed event of the MachineOperator. + /// + /// The source of the event. + /// The instance containing the event data. + private void MachineOperator_PrintingFailed(object sender, PrintingFailedEventArgs e) + { + Log(EventTypes.JOB_FAILED, e.Exception.Message); + } + + /// + /// Handles the PrintingCompleted event of the MachineOperator. + /// + /// The source of the event. + /// The instance containing the event data. + private void MachineOperator_PrintingCompleted(object sender, PrintingEventArgs e) + { + Log(EventTypes.JOB_COMPLETED, $"Job '{e.Job.Name}' completed successfully."); + } + + /// + /// Handles the PrintingAborted event of the MachineOperator. + /// + /// The source of the event. + /// The instance containing the event data. + private void MachineOperator_PrintingAborted(object sender, PrintingEventArgs e) + { + Log(EventTypes.JOB_ABORTED, $"Job '{e.Job.Name}' has been aborted."); + } + + /// + /// Handles the PrintingStarted event of the MachineOperator. + /// + /// The source of the event. + /// The instance containing the event data. + private void MachineOperator_PrintingStarted(object sender, PrintingEventArgs e) + { + Log(EventTypes.JOB_STARTED, $"Job '{e.Job.Name}' started."); + } + /// /// Handles the machine operator state changed event. /// diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs index dabfc5893..53e143def 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs @@ -28,6 +28,8 @@ namespace Tango.PPC.UI.Connectivity private INotificationProvider _notification; private IMachineProvider _machineProvider; private Rfc2898Cryptographer _cryptographer; + private System.Timers.Timer _updateTimer; + private WiFiNetwork _connectedNetwork; /// /// Occurs when the connectivity provider state has changed (e.g network connected/disconnected). @@ -136,12 +138,40 @@ namespace Tango.PPC.UI.Connectivity IsConnected = networks.Exists(x => x.IsConnected); + if (IsConnected) + { + _connectedNetwork = auto_connect_network; + } + if (auto_connect_network != null && !auto_connect_network.IsConnected) { auto_connect_network.AutoConnect = true; await Connect(auto_connect_network, _cryptographer.Decrypt(settings.AutoConnectWiFiPassword)); } }); + + _updateTimer = new System.Timers.Timer(TimeSpan.FromSeconds(30).TotalMilliseconds); + _updateTimer.Elapsed += _updateTimer_Elapsed; + _updateTimer.Start(); + } + + /// + /// Periodically checks if WiFI network is gone/disconnected. + /// + /// The source of the event. + /// The instance containing the event data. + private void _updateTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) + { + if (IsConnected && _connectedNetwork != null) + { + var networks = GetAvailableWiFiNetworks().Result; + var matching_network = networks.FirstOrDefault(x => x.Name == _connectedNetwork.Name); + + if (matching_network == null || !matching_network.AccessPoint.IsConnected) + { + OnConnectionStateChanged(false); + } + } } /// @@ -264,6 +294,7 @@ namespace Tango.PPC.UI.Connectivity settings.AutoConnectWiFiName = network.AutoConnect ? network.Name : null; settings.AutoConnectWiFiPassword = _cryptographer.Encrypt(auth.Password); settings.Save(); + _connectedNetwork = network; } return result; @@ -295,6 +326,10 @@ namespace Tango.PPC.UI.Connectivity /// if set to true [connected]. protected virtual void OnConnectionStateChanged(bool connected) { + if (!connected) + { + _connectedNetwork = null; + } IsConnected = connected; ConnectionStateChanged?.Invoke(this, new ConnectionStateEventArgs() { IsConnected = connected }); } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs index 1f09023cb..456c69625 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs @@ -45,6 +45,8 @@ namespace Tango.PPC.UI.Printing /// public async Task Print(Job job, ObservablesContext context) { + ThrowIfJobInvalid(job); + JobHandler handler = null; #if STUBPRINT @@ -149,6 +151,8 @@ namespace Tango.PPC.UI.Printing /// public async Task PrintSample(Job job, ObservablesContext context) { + ThrowIfJobInvalid(job); + LogManager.Log("Cloning job..."); Job sampleDyeJob = job.Clone(); sampleDyeJob.Guid = job.Guid; @@ -202,6 +206,8 @@ namespace Tango.PPC.UI.Printing /// public async Task PrintFineTuning(Job job, ObservablesContext context, IEnumerable fineTuneItems) { + ThrowIfJobInvalid(job); + LogManager.Log("Cloning job..."); Job fineTuneJob = job.Clone(); fineTuneJob.NumberOfUnits = 1; @@ -241,5 +247,21 @@ namespace Tango.PPC.UI.Printing { TangoMessenger.Default.Send(new JobSavedMessage() { Job = job }); } + + private void ThrowIfJobInvalid(Job job) + { + if (job.Segments.SelectMany(x => x.BrushStops).Any(x => x.IsOutOfGamut)) + { + throw new InvalidOperationException("Error starting job. Color is out of range."); + } + if (job.Segments.SelectMany(x => x.BrushStops).Any(x => x.ColorSpace.IsCatalog && x.ColorCatalog == null)) + { + throw new InvalidOperationException("Error starting job. Please select a catalog color."); + } + if (job.Rml.Ccts.Count == 0) + { + throw new InvalidOperationException($"Error starting job. No color table found for thread '{job.Rml.Name}'."); + } + } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest index d72e75011..efc5f8179 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest @@ -16,7 +16,7 @@ Remove this element if your application requires this virtualization for backwards compatibility. --> - + -- cgit v1.3.1