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 --- .../Machine Studio Installer.aip | 94 +--- .../Advanced Installer Projects/PPC Installer.aip | 102 +--- .../ViewModels/MainViewVM.cs | 41 +- .../Views/JobView.xaml | 6 +- .../ViewModels/MachineTechViewVM.cs | 4 +- .../PPC/Modules/Tango.PPC.Jobs/Views/JobsView.xaml | 4 +- .../AvailableWiFiConnectionsControl.xaml | 4 +- .../HotSpot/DefaultHotSpotProvider.cs | 2 +- .../MachineUpdate/MachineUpdateManager.cs | 11 +- .../Tango.PPC.Common/Printing/IPrintingManager.cs | 6 +- .../Printing/DefaultPrintingManager.cs | 14 +- .../PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs | 2 +- .../ViewModels/ExternalBridgeViewVM.cs | 13 +- .../Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs | 8 + .../PPC/Tango.PPC.UI/Views/MachineUpdateView.xaml | 2 +- .../PPC/Tango.PPC.UI/Views/MainView.xaml | 2 +- .../ColorConversion/TangoColorConverter.cs | 92 +++- .../ExtensionMethods/ExceptionExtensions.cs | 6 +- .../ExtensionMethods/FrameworkElementExtensions.cs | 199 ++++++- .../Tango.DragAndDrop/DragAndDropService.cs | 5 +- .../ExternalBridge/ExternalBridgeService.cs | 6 + .../DefaultGradientGenerationConfiguration.cs | 134 +++++ .../Operation/IGradientGenerationConfiguration.cs | 34 ++ .../Operation/IMachineOperator.cs | 16 +- .../Tango.Integration/Operation/MachineOperator.cs | 579 +++++++++++---------- .../Operation/PreparingJobProgressEventArgs.cs | 31 ++ .../Tango.Integration/Tango.Integration.csproj | 5 +- .../SQLExaminer/Configurations/UpdateMachine.xml | Bin 39266 -> 41074 bytes .../Tango.Touch/Controls/LightTouchDataGrid.cs | 16 +- 29 files changed, 906 insertions(+), 532 deletions(-) create mode 100644 Software/Visual_Studio/Tango.Integration/Operation/DefaultGradientGenerationConfiguration.cs create mode 100644 Software/Visual_Studio/Tango.Integration/Operation/IGradientGenerationConfiguration.cs create mode 100644 Software/Visual_Studio/Tango.Integration/Operation/PreparingJobProgressEventArgs.cs (limited to 'Software/Visual_Studio') diff --git a/Software/Visual_Studio/Advanced Installer Projects/Machine Studio Installer.aip b/Software/Visual_Studio/Advanced Installer Projects/Machine Studio Installer.aip index 65e40810e..5f01dbb66 100644 --- a/Software/Visual_Studio/Advanced Installer Projects/Machine Studio Installer.aip +++ b/Software/Visual_Studio/Advanced Installer Projects/Machine Studio Installer.aip @@ -67,17 +67,9 @@ - - - - - - - - @@ -107,7 +99,6 @@ - @@ -123,9 +114,7 @@ - - @@ -134,7 +123,6 @@ - @@ -142,11 +130,8 @@ - - - @@ -158,18 +143,13 @@ - - - - - @@ -196,7 +176,6 @@ - @@ -213,23 +192,15 @@ - - - - - - - - @@ -237,25 +208,19 @@ - - - - - - @@ -309,12 +274,8 @@ - - - - @@ -322,13 +283,13 @@ + - - + @@ -372,21 +333,12 @@ - - - - - - - - - @@ -433,7 +385,6 @@ - @@ -442,7 +393,6 @@ - @@ -467,9 +417,7 @@ - - @@ -478,7 +426,6 @@ - @@ -488,11 +435,8 @@ - - - @@ -504,18 +448,13 @@ - - - - - @@ -550,7 +489,6 @@ - @@ -567,24 +505,16 @@ - - - - - - - - @@ -592,12 +522,10 @@ - - @@ -606,17 +534,13 @@ - - - - - + @@ -750,19 +674,11 @@ - - - - - - - - @@ -773,9 +689,6 @@ - - - @@ -869,6 +782,7 @@ + diff --git a/Software/Visual_Studio/Advanced Installer Projects/PPC Installer.aip b/Software/Visual_Studio/Advanced Installer Projects/PPC Installer.aip index 747e6eae3..edeedd43d 100644 --- a/Software/Visual_Studio/Advanced Installer Projects/PPC Installer.aip +++ b/Software/Visual_Studio/Advanced Installer Projects/PPC Installer.aip @@ -18,10 +18,10 @@ - + - + @@ -73,17 +73,9 @@ - - - - - - - - @@ -110,12 +102,11 @@ - - + @@ -130,46 +121,20 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -205,19 +170,15 @@ - - - - + - - + @@ -229,7 +190,7 @@ - + @@ -252,21 +213,12 @@ - - - - - - - - - @@ -310,14 +262,12 @@ - - @@ -337,23 +287,12 @@ - - - - - - - - - - - @@ -367,28 +306,13 @@ - - - - - - - - - - - - - - - @@ -482,20 +406,9 @@ - - - - - - - - - - - @@ -507,7 +420,7 @@ - + @@ -575,6 +488,7 @@ + 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 diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs index 666a56704..e78047563 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs @@ -1749,13 +1749,13 @@ namespace Tango.MachineStudio.Technician.ViewModels /// private void InitJobRunnerItem(JobRunnerItem item) { - item.StartJob += () => + item.StartJob += async () => { try { CheckMachineOperator(); - var handler = MachineOperator.Print(item.Job, item.ProcessParameters); + var handler = await MachineOperator.Print(item.Job, item.ProcessParameters); item.JobHandler = handler; diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobsView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobsView.xaml index ace1d38af..47a3df569 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobsView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Views/JobsView.xaml @@ -279,8 +279,8 @@ - - + + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connectivity/AvailableWiFiConnectionsControl.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connectivity/AvailableWiFiConnectionsControl.xaml index 80581551e..dac37ba10 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connectivity/AvailableWiFiConnectionsControl.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connectivity/AvailableWiFiConnectionsControl.xaml @@ -64,8 +64,8 @@ Connect automatically - Connect - Disconnect + Connect + Disconnect diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/HotSpot/DefaultHotSpotProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/HotSpot/DefaultHotSpotProvider.cs index 4f035d814..835a7fc4a 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/HotSpot/DefaultHotSpotProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/HotSpot/DefaultHotSpotProvider.cs @@ -77,7 +77,7 @@ namespace Tango.PPC.Common.HotSpot { try { - CmdCommand command = new CmdCommand("netsh", $"wlan set hostednetwork mode=allow ssid='{"Tango-" + _machineProvider.Machine.SerialNumber}' key='{password}'"); + CmdCommand command = new CmdCommand("netsh", $"wlan set hostednetwork mode=allow ssid={"Tango-" + _machineProvider.Machine.SerialNumber} key={password}"); await command.Run(); command = new CmdCommand("netsh", "wlan start hosted network"); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs index 3fffc2045..b64b624fe 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineUpdate/MachineUpdateManager.cs @@ -75,13 +75,10 @@ namespace Tango.PPC.Common.MachineUpdate private Task Login(String serialNumber) { - return Task.Factory.StartNew(() => + return _client.Login(new LoginRequest() { - return _client.Login(new LoginRequest() - { - Mode = LoginMode.Machine, - SerialNumber = serialNumber, - }).Result; + Mode = LoginMode.Machine, + SerialNumber = serialNumber, }); } @@ -310,7 +307,7 @@ namespace Tango.PPC.Common.MachineUpdate LogManager.Log($"Connecting to machine service on {machineServiceAddress}..."); - Login(serialNumber).Wait(); + Login(serialNumber).GetAwaiter().GetResult(); LogManager.Log($"Checking if updates available..."); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Printing/IPrintingManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Printing/IPrintingManager.cs index 37a71c965..dc097a805 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Printing/IPrintingManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Printing/IPrintingManager.cs @@ -22,7 +22,7 @@ namespace Tango.PPC.Common.Printing /// The job. /// The context. /// - JobHandler Print(Job job, ObservablesContext context); + Task Print(Job job, ObservablesContext context); /// /// Creates a sample dye job from the specified job and prints it. @@ -31,7 +31,7 @@ namespace Tango.PPC.Common.Printing /// The job. /// The context. /// - JobHandler PrintSample(Job job, ObservablesContext context); + Task PrintSample(Job job, ObservablesContext context); /// /// Creates a fine tuning job from the specified job and fine tune items. @@ -41,6 +41,6 @@ namespace Tango.PPC.Common.Printing /// The context. /// The fine tune items. /// - JobHandler PrintFineTuning(Job job, ObservablesContext context, IEnumerable fineTuneItems); + Task PrintFineTuning(Job job, ObservablesContext context, IEnumerable fineTuneItems); } } 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 d6770ed45..f05c05a44 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Printing/DefaultPrintingManager.cs @@ -42,13 +42,13 @@ namespace Tango.PPC.UI.Printing /// The job. /// The context. /// - public JobHandler Print(Job job, ObservablesContext context) + public async Task Print(Job job, ObservablesContext context) { #if STUBPRINT - var handler = _machineProvider.MachineOperator.PrintStub(job); + var handler = await _machineProvider.MachineOperator.PrintStub(job); #else - var handler = _machineProvider.MachineOperator.Print(job); + var handler = await _machineProvider.MachineOperator.Print(job); #endif handler.Completed += async (x, e) => @@ -104,7 +104,7 @@ namespace Tango.PPC.UI.Printing /// The job. /// The context. /// - public JobHandler PrintSample(Job job, ObservablesContext context) + public async Task PrintSample(Job job, ObservablesContext context) { LogManager.Log("Cloning job..."); Job sampleDyeJob = job.Clone(); @@ -131,7 +131,7 @@ namespace Tango.PPC.UI.Printing LogManager.Log("Executing sample dye job..."); - var handler = _machineProvider.MachineOperator.Print(sampleDyeJob); + var handler = await _machineProvider.MachineOperator.Print(sampleDyeJob); handler.Completed += async (x, e) => { try @@ -157,7 +157,7 @@ namespace Tango.PPC.UI.Printing /// The context. /// The fine tune items. /// - public JobHandler PrintFineTuning(Job job, ObservablesContext context, IEnumerable fineTuneItems) + public async Task PrintFineTuning(Job job, ObservablesContext context, IEnumerable fineTuneItems) { LogManager.Log("Cloning job..."); Job fineTuneJob = job.Clone(); @@ -172,7 +172,7 @@ namespace Tango.PPC.UI.Printing var segment = fineTuneJob.AddSolidSegment(suggestion.Color); } - var handler = _machineProvider.MachineOperator.Print(fineTuneJob); + var handler = await _machineProvider.MachineOperator.Print(fineTuneJob); handler.Completed += async (x, e) => { try diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs index fa54f491e..a0db99ffb 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs @@ -8,4 +8,4 @@ using System.Windows; // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Tango PPC Application")] -[assembly: AssemblyVersion("1.0.6.0")] +[assembly: AssemblyVersion("1.0.9.0")] diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs index 83f629159..80a95d1bf 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/ExternalBridgeViewVM.cs @@ -116,12 +116,15 @@ namespace Tango.PPC.UI.ViewModels /// The instance containing the event data. private void ExternalBridgeService_ClientDisconnected(object sender, EventArgs e) { - LogManager.Log("External bridge client disconnected. Navigating to home module..."); - - InvokeUI(() => + if (IsVisible) { - NavigationManager.NavigateTo(NavigationView.HomeModule); - }); + LogManager.Log("External bridge client disconnected. Navigating to home module..."); + + InvokeUI(() => + { + NavigationManager.NavigateTo(NavigationView.HomeModule); + }); + } } /// diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs index 07da99818..f265c5dbf 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MachineUpdateViewVM.cs @@ -140,6 +140,14 @@ namespace Tango.PPC.UI.ViewModels _isChecking = true; IsDbUpdate = false; + await Task.Delay(2000); + if (!await ConnectivityProvider.CheckInternetConnection()) + { + _isChecking = false; + await NavigateTo(MachineUpdateView.UpdateCheckErrorView); + return; + } + var response = await MachineUpdateManager.CheckForUpdate(MachineProvider.Machine.SerialNumber); if (response.IsUpdateAvailable) diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineUpdateView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineUpdateView.xaml index ba7e9e019..fba8a599d 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineUpdateView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineUpdateView.xaml @@ -174,7 +174,7 @@ Update Failed - + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml index e4c107049..c63ef1e13 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MainView.xaml @@ -59,7 +59,7 @@ - + diff --git a/Software/Visual_Studio/Tango.BL/ColorConversion/TangoColorConverter.cs b/Software/Visual_Studio/Tango.BL/ColorConversion/TangoColorConverter.cs index d44859413..3c8a58459 100644 --- a/Software/Visual_Studio/Tango.BL/ColorConversion/TangoColorConverter.cs +++ b/Software/Visual_Studio/Tango.BL/ColorConversion/TangoColorConverter.cs @@ -9,6 +9,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Media; using Tango.BL.Entities; +using Tango.BL.Enumerations; using Tango.Logging; using Tango.PMR; using Tango.PMR.ColorLab; @@ -70,9 +71,9 @@ namespace Tango.BL.ColorConversion conversionInput.ColorSpace = PMR.ColorLab.ColorSpace.Rgb; conversionInput.InputCoordinates = new InputCoordinates(); - conversionInput.InputCoordinates.Red = Math.Max((int)color.R, 1); - conversionInput.InputCoordinates.Green = Math.Max((int)color.G, 1); - conversionInput.InputCoordinates.Blue = Math.Max((int)color.B, 1); + conversionInput.InputCoordinates.Red = Math.Max((int)color.R, 0); + conversionInput.InputCoordinates.Green = Math.Max((int)color.G, 0); + conversionInput.InputCoordinates.Blue = Math.Max((int)color.B, 0); conversionInput.ThreadL = 92.1815;//brushStop.Segment.Job.Rml.WhitePoint.L; conversionInput.ThreadA = 2.2555;//brushStop.Segment.Job.Rml.WhitePoint.A; @@ -290,5 +291,90 @@ namespace Tango.BL.ColorConversion return conversionInput; } + + public static void ApplyBrushStopCorrection(BrushStop stop, ProcessParametersTable processTable, ConversionOutput conversionOutput) + { + var output = conversionOutput; + + stop.SetLiquidVolumes(stop.Segment.Job.Machine.Configuration, stop.Segment.Job.Rml, processTable); + + foreach (var outputLiquid in output.SingleCoordinates.OutputLiquids) + { + var liquidVolume = stop.LiquidVolumes.SingleOrDefault(x => x.IdsPack.LiquidType.Code == outputLiquid.LiquidType.ToInt32()); + + if (liquidVolume == null) + { + throw new NullReferenceException("Liquid volume not found for color conversion output liquid '" + outputLiquid.LiquidType + "'."); + } + + liquidVolume.Volume = outputLiquid.Volume; + } + } + + public static List CreateSegmentLinearGradient(Segment segment, ProcessParametersTable processTable, int resolutionCM) + { + List stops = new List(); + + int stopIndex = 1; + + for (double cm = 0; cm < segment.Length; cm += (resolutionCM / 100d)) + { + double offset = (double)cm / segment.Length; + + var color = GetRelativeColor(segment.BrushStops.ToList(), offset); + var output = GetSuggestions(segment.Job, color); + + BrushStop s = new BrushStop(); + s.Segment = segment; + s.ColorSpace = new Entities.ColorSpace(); + s.ColorSpace.Code = ColorSpaces.RGB.ToInt32(); + s.Corrected = true; + s.OffsetPercent = offset * 100d; + s.OffsetMeters = segment.Length * offset; + s.Red = color.R; + s.Green = color.G; + s.Blue = color.B; + s.StopIndex = stopIndex++; + + ApplyBrushStopCorrection(s, processTable, output); + + stops.Add(s); + } + + return stops; + } + + private static Color GetRelativeColor(List brushStopsCollection, double offset) + { + brushStopsCollection = brushStopsCollection.Select(x => x.ShallowClone()).ToList(); + brushStopsCollection.ForEach(x => x.OffsetPercent = x.OffsetPercent / 100d); + + var point = brushStopsCollection.SingleOrDefault(f => f.OffsetPercent == offset); + if (point != null) return point.Color; + + BrushStop before = brushStopsCollection.Where(w => w.OffsetPercent == brushStopsCollection.Min(m => m.OffsetPercent)).First(); + BrushStop after = brushStopsCollection.Where(w => w.OffsetPercent == brushStopsCollection.Max(m => m.OffsetPercent)).First(); + + foreach (var gs in brushStopsCollection) + { + if (gs.OffsetPercent < offset && gs.OffsetPercent > before.OffsetPercent) + { + before = gs; + } + if (gs.OffsetPercent > offset && gs.OffsetPercent < after.OffsetPercent) + { + after = gs; + } + } + + var color = new Color(); + + color.ScA = (float)((offset - before.OffsetPercent) * (after.Color.ScA - before.Color.ScA) / (after.OffsetPercent - before.OffsetPercent) + before.Color.ScA); + color.ScR = (float)((offset - before.OffsetPercent) * (after.Color.ScR - before.Color.ScR) / (after.OffsetPercent - before.OffsetPercent) + before.Color.ScR); + color.ScG = (float)((offset - before.OffsetPercent) * (after.Color.ScG - before.Color.ScG) / (after.OffsetPercent - before.OffsetPercent) + before.Color.ScG); + color.ScB = (float)((offset - before.OffsetPercent) * (after.Color.ScB - before.Color.ScB) / (after.OffsetPercent - before.OffsetPercent) + before.Color.ScB); + + return color; + } } } diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/ExceptionExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/ExceptionExtensions.cs index 86434cdc4..af4fc39b5 100644 --- a/Software/Visual_Studio/Tango.Core/ExtensionMethods/ExceptionExtensions.cs +++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/ExceptionExtensions.cs @@ -43,10 +43,14 @@ public static class ExceptionExtensions { try { - message += Environment.NewLine + String.Join(Environment.NewLine, (exception as AggregateException).InnerExceptions.Select(x => x.Message)); + message = String.Join(Environment.NewLine, (exception as AggregateException).InnerExceptions.Select(x => x.FlattenMessage())); } catch { } } + else if (exception.InnerException != null) + { + message += Environment.NewLine + exception.InnerException.FlattenMessage(); + } return message; } diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/FrameworkElementExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/FrameworkElementExtensions.cs index 2e1791b63..08f3bb101 100644 --- a/Software/Visual_Studio/Tango.Core/ExtensionMethods/FrameworkElementExtensions.cs +++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/FrameworkElementExtensions.cs @@ -8,6 +8,7 @@ using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Controls.Primitives; +using System.Windows.Input; using System.Windows.Markup; using System.Windows.Media; using System.Windows.Media.Animation; @@ -18,6 +19,14 @@ public static class FrameworkElementExtensions { #region Mouse Or Touch Events + //Used to hold the registered event handlers for later use by UnRegisterMouseOrTouch. + private static List _containers = new List(); + private class ElementEventsContainer + { + public EventHandler Handler { get; set; } + public Action Clear { get; set; } + } + /// /// Registers for mouse or touch down. /// @@ -29,7 +38,7 @@ public static class FrameworkElementExtensions bool mousePressed = false; bool touchDown = false; - element.MouseDown += (x, e) => + MouseButtonEventHandler mouseDownHandler = (x, e) => { if (!touchDown) { @@ -53,7 +62,9 @@ public static class FrameworkElementExtensions } }; - element.TouchDown += (x, e) => + element.MouseDown += mouseDownHandler; + + EventHandler touchDownHandler = (x, e) => { if (!mousePressed) { @@ -77,16 +88,31 @@ public static class FrameworkElementExtensions } }; - element.MouseUp += (_, __) => + element.TouchDown += touchDownHandler; + + MouseButtonEventHandler mouseUpHandler = (_, __) => { touchDown = false; mousePressed = false; }; - element.TouchDown += (_, __) => - { + element.MouseUp += mouseUpHandler; + + //element.TouchDown += (_, __) => + //{ + + //}; + ElementEventsContainer container = new ElementEventsContainer(); + container.Handler = handler; + container.Clear = () => + { + element.MouseUp -= mouseUpHandler; + element.TouchDown -= touchDownHandler; + element.MouseDown -= mouseDownHandler; }; + + _containers.Add(container); } /// @@ -99,6 +125,101 @@ public static class FrameworkElementExtensions RegisterForMouseOrTouchDown(element, null, handler); } + /// + /// Registers for mouse or touch up. + /// + /// The element. + /// The relative to. + /// The handler. + public static void RegisterForMouseOrTouchUp(this FrameworkElement element, FrameworkElement relativeTo, EventHandler handler) + { + bool mouseReleased = false; + bool touchReleased = false; + + MouseButtonEventHandler mouseUpHandler = (x, e) => + { + if (!touchReleased) + { + mouseReleased = true; + + var args = new MouseOrTouchEventArgs() + { + Location = new Point(e.GetPosition(relativeTo != null ? relativeTo : element).X, e.GetPosition(relativeTo != null ? relativeTo : element).Y), + Source = e.Source, + OriginalSource = e.OriginalSource, + Handled = e.Handled, + GetPositionAction = e.GetPosition + }; + + handler(element, args); + e.Handled = args.Handled; + } + else + { + touchReleased = false; + } + }; + + element.MouseUp += mouseUpHandler; + + EventHandler touchUpHandler = (x, e) => + { + + if (!mouseReleased) + { + touchReleased = true; + + var args = new MouseOrTouchEventArgs() + { + Location = new Point(e.GetTouchPoint(relativeTo != null ? relativeTo : element).Position.X, e.GetTouchPoint(relativeTo != null ? relativeTo : element).Position.Y), + Source = e.Source, + OriginalSource = e.OriginalSource, + Handled = e.Handled, + GetPositionAction = (s) => { return e.GetTouchPoint(s).Position; }, + }; + + handler(element, args); + e.Handled = args.Handled; + } + else + { + touchReleased = false; + } + + }; + + element.TouchUp += touchUpHandler; + + EventHandler touchDownHandler = (_, __) => + { + touchReleased = false; + mouseReleased = false; + }; + + element.TouchDown += touchDownHandler; + + ElementEventsContainer container = new ElementEventsContainer(); + container.Handler = handler; + container.Clear = () => + { + element.TouchDown -= touchDownHandler; + element.TouchUp -= touchUpHandler; + element.MouseUp -= mouseUpHandler; + }; + + _containers.Add(container); + } + + /// + /// Registers for mouse or touch up. + /// + /// The element. + /// The handler. + public static void RegisterForMouseOrTouchUp(this FrameworkElement element, EventHandler handler) + { + RegisterForMouseOrTouchUp(element, null, handler); + } + /// /// Registers for preview mouse or touch down. /// @@ -110,7 +231,7 @@ public static class FrameworkElementExtensions bool mousePressed = false; bool touchDown = false; - element.PreviewMouseDown += (x, e) => + MouseButtonEventHandler previewMouseDownHandler = (x, e) => { if (!touchDown) { @@ -134,7 +255,9 @@ public static class FrameworkElementExtensions } }; - element.PreviewTouchDown += (x, e) => + element.PreviewMouseDown += previewMouseDownHandler; + + EventHandler previewTouchDownHandler = (x, e) => { if (!mousePressed) { @@ -158,16 +281,31 @@ public static class FrameworkElementExtensions } }; - element.PreviewMouseUp += (_, __) => + element.PreviewTouchDown += previewTouchDownHandler; + + MouseButtonEventHandler previewMouseUpHandler = (_, __) => { touchDown = false; mousePressed = false; }; - element.PreviewTouchDown += (_, __) => - { + element.PreviewMouseUp += previewMouseUpHandler; + + //element.PreviewTouchDown += (_, __) => + //{ + + //}; + ElementEventsContainer container = new ElementEventsContainer(); + container.Handler = handler; + container.Clear = () => + { + element.PreviewTouchDown -= previewTouchDownHandler; + element.PreviewMouseDown -= previewMouseDownHandler; + element.PreviewMouseUp -= previewMouseUpHandler; }; + + _containers.Add(container); } /// @@ -191,7 +329,7 @@ public static class FrameworkElementExtensions bool mouseReleased = false; bool touchReleased = false; - element.PreviewMouseUp += (x, e) => + MouseButtonEventHandler previewMouseUpHandler = (x, e) => { if (!touchReleased) { @@ -215,8 +353,11 @@ public static class FrameworkElementExtensions } }; - element.PreviewTouchUp += (x, e) => + element.PreviewMouseUp += previewMouseUpHandler; + + EventHandler previewTouchHandler = (x, e) => { + if (!mouseReleased) { touchReleased = true; @@ -237,13 +378,29 @@ public static class FrameworkElementExtensions { touchReleased = false; } + }; - element.PreviewTouchDown += (_, __) => + element.PreviewTouchUp += previewTouchHandler; + + EventHandler previewTouchDownHandler = (_, __) => { touchReleased = false; mouseReleased = false; }; + + element.PreviewTouchDown += previewTouchDownHandler; + + ElementEventsContainer container = new ElementEventsContainer(); + container.Handler = handler; + container.Clear = () => + { + element.PreviewTouchDown -= previewTouchDownHandler; + element.PreviewTouchUp -= previewTouchHandler; + element.PreviewMouseUp -= previewMouseUpHandler; + }; + + _containers.Add(container); } /// @@ -256,6 +413,22 @@ public static class FrameworkElementExtensions RegisterForPreviewMouseOrTouchUp(element, null, handler); } + /// + /// Detaches the specified handler from event which it was originally registered. + /// + /// The element. + /// The handler. + public static void UnRegisterMouseOrTouch(this FrameworkElement element, EventHandler handler) + { + var containers = _containers.Where(x => x.Handler == handler); + + foreach (var container in containers.ToList()) + { + container.Clear(); + _containers.Remove(container); + } + } + /// /// Registers for mouse or touch move. /// diff --git a/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs b/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs index 586071363..8833feff8 100644 --- a/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs +++ b/Software/Visual_Studio/Tango.DragAndDrop/DragAndDropService.cs @@ -730,6 +730,7 @@ namespace Tango.DragAndDrop if ((e.Source != sender && dragThumb == null) || (dragThumb != null && dragThumb != e.OriginalSource)) { + _currentDragedElement = null; return; } @@ -759,10 +760,10 @@ namespace Tango.DragAndDrop { FrameworkElement element = _currentDragedElement; - int minDragOffset = GetMinDragOffset(element); - if (element != null) { + int minDragOffset = GetMinDragOffset(element); + var surface = GetDraggingSurface(element); if (surface != null) diff --git a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeService.cs b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeService.cs index c4f559c58..4cdd372f5 100644 --- a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeService.cs +++ b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeService.cs @@ -283,6 +283,12 @@ namespace Tango.Integration.ExternalBridge { if (IsInSession) { + if (container.Type == MessageType.ExternalBridgeLoginRequest) + { + SendErrorResponse(new AuthenticationException("Machine is already in session."), container.Token); + return; + } + if (_messageHandlers.ContainsKey(container.Type)) { try diff --git a/Software/Visual_Studio/Tango.Integration/Operation/DefaultGradientGenerationConfiguration.cs b/Software/Visual_Studio/Tango.Integration/Operation/DefaultGradientGenerationConfiguration.cs new file mode 100644 index 000000000..2f531a95f --- /dev/null +++ b/Software/Visual_Studio/Tango.Integration/Operation/DefaultGradientGenerationConfiguration.cs @@ -0,0 +1,134 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media; +using Tango.BL.ColorConversion; +using Tango.BL.Entities; +using Tango.BL.Enumerations; +using Tango.Core; + +namespace Tango.Integration.Operation +{ + /// + /// Represents the default gradient steps generation configuration. + /// + public class DefaultGradientGenerationConfiguration : ExtendedObject, IGradientGenerationConfiguration + { + private bool _isEnabled; + /// + /// Gets or sets a value indicating whether to generate the gradient steps. + /// + public bool IsEnabled + { + get { return _isEnabled; } + set { _isEnabled = value; RaisePropertyChangedAuto(); } + } + + private int _resolutionCM; + /// + /// Gets or sets the gradient steps resolution in centimeters. + /// + public int ResolutionCM + { + get { return _resolutionCM; } + set { _resolutionCM = value; RaisePropertyChangedAuto(); } + } + + /// + /// Initializes a new instance of the class. + /// + public DefaultGradientGenerationConfiguration() + { + ResolutionCM = 10; + } + + /// + /// Creates a collection of brush stops representing the required gradient steps. + /// + /// The segment. + /// The process parameters. + /// Progress callback. + /// + public List Generate(Segment segment, ProcessParametersTable processParameters, Action progress = null) + { + List stops = new List(); + + int stopIndex = 1; + + for (double cm = 0; cm < segment.Length; cm += (ResolutionCM / 100d)) + { + double offset = (double)cm / segment.Length; + + var color = GetRelativeColor(segment.BrushStops.ToList(), offset); + var output = TangoColorConverter.GetSuggestions(segment.Job, color); + + BrushStop s = new BrushStop(); + s.Segment = segment; + s.ColorSpace = new ColorSpace(); + s.ColorSpace.Code = ColorSpaces.RGB.ToInt32(); + s.Corrected = true; + s.OffsetPercent = offset * 100d; + s.OffsetMeters = segment.Length * offset; + s.Red = color.R; + s.Green = color.G; + s.Blue = color.B; + s.StopIndex = stopIndex++; + + TangoColorConverter.ApplyBrushStopCorrection(s, processParameters, output); + + stops.Add(s); + + progress?.Invoke(new PreparingJobProgressEventArgs() + { + Job = segment.Job, + Total = segment.Length, + Progress = cm, + }); + } + + progress?.Invoke(new PreparingJobProgressEventArgs() + { + Job = segment.Job, + Total = segment.Length, + Progress = segment.Length, + }); + + return stops; + } + + private Color GetRelativeColor(List brushStopsCollection, double offset) + { + brushStopsCollection = brushStopsCollection.Select(x => x.ShallowClone()).ToList(); + brushStopsCollection.ForEach(x => x.OffsetPercent = x.OffsetPercent / 100d); + + var point = brushStopsCollection.SingleOrDefault(f => f.OffsetPercent == offset); + if (point != null) return point.Color; + + BrushStop before = brushStopsCollection.Where(w => w.OffsetPercent == brushStopsCollection.Min(m => m.OffsetPercent)).First(); + BrushStop after = brushStopsCollection.Where(w => w.OffsetPercent == brushStopsCollection.Max(m => m.OffsetPercent)).First(); + + foreach (var gs in brushStopsCollection) + { + if (gs.OffsetPercent < offset && gs.OffsetPercent > before.OffsetPercent) + { + before = gs; + } + if (gs.OffsetPercent > offset && gs.OffsetPercent < after.OffsetPercent) + { + after = gs; + } + } + + var color = new Color(); + + color.ScA = (float)((offset - before.OffsetPercent) * (after.Color.ScA - before.Color.ScA) / (after.OffsetPercent - before.OffsetPercent) + before.Color.ScA); + color.ScR = (float)((offset - before.OffsetPercent) * (after.Color.ScR - before.Color.ScR) / (after.OffsetPercent - before.OffsetPercent) + before.Color.ScR); + color.ScG = (float)((offset - before.OffsetPercent) * (after.Color.ScG - before.Color.ScG) / (after.OffsetPercent - before.OffsetPercent) + before.Color.ScG); + color.ScB = (float)((offset - before.OffsetPercent) * (after.Color.ScB - before.Color.ScB) / (after.OffsetPercent - before.OffsetPercent) + before.Color.ScB); + + return color; + } + } +} diff --git a/Software/Visual_Studio/Tango.Integration/Operation/IGradientGenerationConfiguration.cs b/Software/Visual_Studio/Tango.Integration/Operation/IGradientGenerationConfiguration.cs new file mode 100644 index 000000000..238d80d61 --- /dev/null +++ b/Software/Visual_Studio/Tango.Integration/Operation/IGradientGenerationConfiguration.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; + +namespace Tango.Integration.Operation +{ + /// + /// Represents a gradient steps generation configuration. + /// + public interface IGradientGenerationConfiguration + { + /// + /// Gets or sets a value indicating whether to generate the gradient steps. + /// + bool IsEnabled { get; set; } + + /// + /// Gets or sets the gradient steps resolution in centimeters. + /// + int ResolutionCM { get; set; } + + /// + /// Creates a collection of brush stops representing the required gradient steps. + /// + /// The segment. + /// The process parameters. + /// Progress callback. + /// + List Generate(Segment segment, ProcessParametersTable processParameters, Action progress = null); + } +} diff --git a/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs index 992323c6d..a5534a063 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs @@ -60,6 +60,11 @@ namespace Tango.Integration.Operation /// RunningJobStatus RunningJobStatus { get; } + /// + /// Gets or sets the gradients generation configuration. + /// + IGradientGenerationConfiguration GradientGenerationConfiguration { get; set; } + /// /// Gets a value indicating whether this instance is printing. /// @@ -75,6 +80,11 @@ namespace Tango.Integration.Operation /// event EventHandler StatusChanged; + /// + /// Reports about the job printing preparation progress. + /// + event EventHandler PreparingJobProgress; + /// /// Occurs when a printing process has started. /// @@ -192,7 +202,7 @@ namespace Tango.Integration.Operation /// /// The job. /// - JobHandler Print(Job job); + Task Print(Job job); /// /// Executes a print stub for emulating a full job. @@ -201,7 +211,7 @@ namespace Tango.Integration.Operation /// /// The job. /// - JobHandler PrintStub(Job job); + Task PrintStub(Job job); /// /// Prints the specified job using the specified job parameters. @@ -209,7 +219,7 @@ namespace Tango.Integration.Operation /// The job. /// Process parameters table /// - JobHandler Print(Job job, ProcessParametersTable processParameters); + Task Print(Job job, ProcessParametersTable processParameters); /// /// Uploads the specified process parameters to the embedded device. diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index 520b06626..ba9d21451 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs @@ -88,6 +88,7 @@ namespace Tango.Integration.Operation EnableJobResume = true; LogEmbeddedDebuggingToFile = true; FirmwareUpgradeMode = FirmwareUpgradeModes.DFU | FirmwareUpgradeModes.TFP_PACKAGE; + GradientGenerationConfiguration = new DefaultGradientGenerationConfiguration(); } /// @@ -143,6 +144,11 @@ namespace Tango.Integration.Operation /// public event EventHandler ResponseReceived; + /// + /// Reports about the job printing preparation progress. + /// + public event EventHandler PreparingJobProgress; + /// /// Occurs when a printing process has started. /// @@ -378,6 +384,16 @@ namespace Tango.Integration.Operation set { _deviceInformation = value; RaisePropertyChangedAuto(); } } + private IGradientGenerationConfiguration _gradientGenerationConfiguration; + /// + /// Gets or sets the gradients generation configuration. + /// + public IGradientGenerationConfiguration GradientGenerationConfiguration + { + get { return _gradientGenerationConfiguration; } + set { _gradientGenerationConfiguration = value; RaisePropertyChangedAuto(); } + } + #endregion #region Virtual Methods @@ -933,7 +949,17 @@ namespace Tango.Integration.Operation jobSegment.Length = segment.LengthWithFactor; jobSegment.Name = segment.Name; - foreach (var stop in segment.BrushStops) + var stops = segment.BrushStops.ToList(); + + if (GradientGenerationConfiguration != null && GradientGenerationConfiguration.IsEnabled) + { + GradientGenerationConfiguration.Generate(segment, processParameters, (e) => + { + PreparingJobProgress?.Invoke(this, e); + }); + } + + foreach (var stop in stops) { JobBrushStop jobStop = new JobBrushStop(); jobStop.Index = stop.StopIndex; @@ -1073,7 +1099,7 @@ namespace Tango.Integration.Operation /// /// The job. /// - public JobHandler Print(Job job) + public Task Print(Job job) { //Check not brush stop has color space 'Volume'. if (job.Segments.SelectMany(x => x.BrushStops).ToList().Exists(x => x.ColorSpace.Code == ColorSpaces.Volume.ToInt32())) @@ -1217,181 +1243,185 @@ namespace Tango.Integration.Operation /// The job. /// Process parameters table /// - public JobHandler Print(Job job, ProcessParametersTable processParameters) + public Task Print(Job job, ProcessParametersTable processParameters) { - if (Status != MachineStatuses.ReadyToDye) + return Task.Factory.StartNew(() => { - throw new InvalidOperationException("Could not print while status = " + Status); - } + if (Status != MachineStatuses.ReadyToDye) + { + throw new InvalidOperationException("Could not print while status = " + Status); + } - RunningJob = null; - RunningJobStatus = null; + RunningJob = null; + RunningJobStatus = null; - var originalJob = job; + var originalJob = job; - CurrentProcessParameters = processParameters; + CurrentProcessParameters = processParameters; - JobRequest request = new JobRequest(); + JobRequest request = new JobRequest(); - if (job.NumberOfUnits < 1) - { - job.NumberOfUnits = 1; - } + if (job.NumberOfUnits < 1) + { + job.NumberOfUnits = 1; + } - job = job.Clone(); + job = job.Clone(); - int max = job.OrderedSegments.Last().SegmentIndex; + int max = job.OrderedSegments.Last().SegmentIndex; - var segments = job.OrderedSegments.ToList(); + var segments = job.OrderedSegments.ToList(); - for (int i = 0; i < job.NumberOfUnits - 1; i++) - { - foreach (var s in segments) + for (int i = 0; i < job.NumberOfUnits - 1; i++) { - var cloned = s.Clone(job); - cloned.SegmentIndex = max++; - job.Segments.Add(cloned); + foreach (var s in segments) + { + var cloned = s.Clone(job); + cloned.SegmentIndex = max++; + job.Segments.Add(cloned); + } } - } - JobTicket ticket = new JobTicket(); - ticket.Guid = originalJob.Guid; - ticket.EnableInterSegment = job.EnableInterSegment; - ticket.InterSegmentLength = job.InterSegmentLength; - ticket.EnableLubrication = job.EnableLubrication; - ticket.Length = job.Length; - ticket.WindingMethod = (JobWindingMethod)job.WindingMethod.Code; - ticket.Spool = new JobSpool(); + JobTicket ticket = new JobTicket(); + ticket.Guid = originalJob.Guid; + ticket.EnableInterSegment = job.EnableInterSegment; + ticket.InterSegmentLength = job.InterSegmentLength; + ticket.EnableLubrication = job.EnableLubrication; + ticket.Length = job.Length; + ticket.WindingMethod = (JobWindingMethod)job.WindingMethod.Code; + ticket.Spool = new JobSpool(); - job.SpoolType.MapPrimitivesTo(ticket.Spool); + job.SpoolType.MapPrimitivesTo(ticket.Spool); - var spool = job.Machine.Spools.SingleOrDefault(x => x.SpoolType == job.SpoolType); + var spool = job.Machine.Spools.SingleOrDefault(x => x.SpoolType == job.SpoolType); - if (spool == null) - { - throw new InvalidOperationException("Job spool type is not registered with this machine."); - } - else - { - spool.MapPrimitivesTo(ticket.Spool); - } + if (spool == null) + { + throw new InvalidOperationException("Job spool type is not registered with this machine."); + } + else + { + spool.MapPrimitivesTo(ticket.Spool); + } - ticket.Spool.JobSpoolType = (JobSpoolType)job.SpoolType.Code; + ticket.Spool.JobSpoolType = (JobSpoolType)job.SpoolType.Code; - ProcessParameters process = new ProcessParameters(); - processParameters.MapPrimitivesTo(process); - ticket.ProcessParameters = process; + ProcessParameters process = new ProcessParameters(); + processParameters.MapPrimitivesTo(process); + ticket.ProcessParameters = process; - foreach (var segment in job.OrderedSegments) - { - ticket.Segments.Add(CreatePMRJobSegment(segment, job, processParameters)); - } + foreach (var segment in job.OrderedSegments) + { + ticket.Segments.Add(CreatePMRJobSegment(segment, job, processParameters)); + } - request.JobTicket = ticket.Clone(); + request.JobTicket = ticket.Clone(); - JobHandler handler = null; + JobHandler handler = null; - handler = new JobHandler(async () => - { - try - { - var result = await SendRequest(new AbortJobRequest()); - PrintingAborted?.Invoke(this, new PrintingEventArgs(handler, originalJob)); - PrintingEnded?.Invoke(this, new PrintingEventArgs(handler, originalJob)); - handler.RaiseCanceled(); - } - catch (Exception ex) + handler = new JobHandler(async () => { - LogManager.Log(ex, "Failed to cancel job."); - } - }, originalJob, ticket, processParameters, JobHandlingMode); + try + { + var result = await SendRequest(new AbortJobRequest()); + PrintingAborted?.Invoke(this, new PrintingEventArgs(handler, originalJob)); + PrintingEnded?.Invoke(this, new PrintingEventArgs(handler, originalJob)); + handler.RaiseCanceled(); + } + catch (Exception ex) + { + LogManager.Log(ex, "Failed to cancel job."); + } + }, originalJob, ticket, processParameters, JobHandlingMode); - handler.StatusChanged += (x, s) => - { - RunningJobStatus = s; - }; + handler.StatusChanged += (x, s) => + { + RunningJobStatus = s; + }; - if (!job.IsAllSegmentsPerSpool) - { - ContinueSingleSpoolJob(job.OrderedSegments.First(), job, processParameters, handler); - return handler; - } + if (!job.IsAllSegmentsPerSpool) + { + ContinueSingleSpoolJob(job.OrderedSegments.First(), job, processParameters, handler); + return handler; + } - request.JobTicket.UploadStrategy = JobUploadStrategy; + request.JobTicket.UploadStrategy = JobUploadStrategy; - ThreadFactory.StartNew(async () => - { - if (JobUploadStrategy == JobUploadStrategy.JobDescriptionFile) + ThreadFactory.StartNew(async () => { - request.JobTicket.Segments.Clear(); - - JobDescriptionFile jobDescriptionFile = new JobDescriptionFile(ticket.Segments); - MemoryStream ms = jobDescriptionFile.ToStream(); + if (JobUploadStrategy == JobUploadStrategy.JobDescriptionFile) + { + request.JobTicket.Segments.Clear(); - var storage = CreateStorageManager(); + JobDescriptionFile jobDescriptionFile = new JobDescriptionFile(ticket.Segments); + MemoryStream ms = jobDescriptionFile.ToStream(); - var storageInfo = await storage.GetStorageDrive(); - var root_folder = await storage.GetRootFolder(); + var storage = CreateStorageManager(); - var existing_item = root_folder.Items.SingleOrDefault(x => x.Name == JOB_DESCRIPTION_FILE_NAME); - if (existing_item != null) - { - await storage.DeleteItem(existing_item); - } + var storageInfo = await storage.GetStorageDrive(); + var root_folder = await storage.GetRootFolder(); - String job_file_path = Path.Combine(storageInfo.Root, JOB_DESCRIPTION_FILE_NAME); + var existing_item = root_folder.Items.SingleOrDefault(x => x.Name == JOB_DESCRIPTION_FILE_NAME); + if (existing_item != null) + { + await storage.DeleteItem(existing_item); + } - await storage.UploadFileSync(job_file_path, ms); + String job_file_path = Path.Combine(storageInfo.Root, JOB_DESCRIPTION_FILE_NAME); - ms.Dispose(); + await storage.UploadFileSync(job_file_path, ms); - request.JobTicket.JobDescriptionFile = job_file_path; - } + ms.Dispose(); - LogRequestSent(request); - bool responseLogged = false; + request.JobTicket.JobDescriptionFile = job_file_path; + } - Status = MachineStatuses.Printing; - RunningJob = originalJob; - PrintingStarted?.Invoke(this, new PrintingEventArgs(handler, originalJob)); + LogRequestSent(request); + bool responseLogged = false; - SendContinuousRequest(request, null, TimeSpan.FromSeconds(2)).Subscribe((response) => - { - handler.RaiseStatusReceived(response.Message.Status); + Status = MachineStatuses.Printing; + RunningJob = originalJob; + PrintingStarted?.Invoke(this, new PrintingEventArgs(handler, originalJob)); - if (!responseLogged) + SendContinuousRequest(request, null, TimeSpan.FromSeconds(2)).Subscribe((response) => { - responseLogged = true; - LogResponseReceived(response.Message); - } - }, (ex) => - { - if (!(ex is ContinuousResponseAbortedException)) + handler.RaiseStatusReceived(response.Message.Status); + + if (!responseLogged) + { + responseLogged = true; + LogResponseReceived(response.Message); + } + }, (ex) => { - Status = MachineStatuses.ReadyToDye; + if (!(ex is ContinuousResponseAbortedException)) + { + Status = MachineStatuses.ReadyToDye; - if (!handler.IsCanceled) + if (!handler.IsCanceled) + { + PrintingFailed?.Invoke(this, new PrintingFailedEventArgs(handler, originalJob, ex)); + PrintingEnded?.Invoke(this, new PrintingEventArgs(handler, originalJob)); + handler.RaiseFailed(ex); + LogRequestFailed(request, ex); + } + } + else { - PrintingFailed?.Invoke(this, new PrintingFailedEventArgs(handler, originalJob, ex)); - PrintingEnded?.Invoke(this, new PrintingEventArgs(handler, originalJob)); - handler.RaiseFailed(ex); - LogRequestFailed(request, ex); + Status = MachineStatuses.ReadyToDye; } - } - else + }, () => { Status = MachineStatuses.ReadyToDye; - } - }, () => - { - Status = MachineStatuses.ReadyToDye; - PrintingCompleted?.Invoke(this, new PrintingEventArgs(handler, originalJob)); - PrintingEnded?.Invoke(this, new PrintingEventArgs(handler, originalJob)); - handler.RaiseCompleted(); + PrintingCompleted?.Invoke(this, new PrintingEventArgs(handler, originalJob)); + PrintingEnded?.Invoke(this, new PrintingEventArgs(handler, originalJob)); + handler.RaiseCompleted(); + }); }); - }); - return handler; + return handler; + + }); } /// @@ -1415,204 +1445,209 @@ namespace Tango.Integration.Operation /// or /// Liquid volume not found for color conversion output liquid '" + outputLiquid.LiquidType + "'. /// - public JobHandler PrintStub(Job job) + public Task PrintStub(Job job) { - //Check not brush stop has color space 'Volume'. - if (job.Segments.SelectMany(x => x.BrushStops).ToList().Exists(x => x.ColorSpace.Code == ColorSpaces.Volume.ToInt32())) + return Task.Factory.StartNew(() => { - throw new InvalidOperationException("Cannot print a brush stop with volume color space when process parameters table has not been specified."); - } - //Get least common process parameters table index. - int processParametersTableIndex = 0; + //Check not brush stop has color space 'Volume'. + if (job.Segments.SelectMany(x => x.BrushStops).ToList().Exists(x => x.ColorSpace.Code == ColorSpaces.Volume.ToInt32())) + { + throw new InvalidOperationException("Cannot print a brush stop with volume color space when process parameters table has not been specified."); + } - if (job.Rml == null) - { - throw new NullReferenceException("Job RML is null"); - } + //Get least common process parameters table index. + int processParametersTableIndex = 0; - var processGroup = job.Rml.ProcessParametersTablesGroups.FirstOrDefault(x => x.Active); + if (job.Rml == null) + { + throw new NullReferenceException("Job RML is null"); + } - if (processGroup == null) - { - throw new NullReferenceException("Could not locate an active process parameters tables group for RML " + job.Rml.Name); - } + var processGroup = job.Rml.ProcessParametersTablesGroups.FirstOrDefault(x => x.Active); - var processParameters = processGroup.ProcessParametersTables.FirstOrDefault(x => x.TableIndex == processParametersTableIndex); + if (processGroup == null) + { + throw new NullReferenceException("Could not locate an active process parameters tables group for RML " + job.Rml.Name); + } - if (processParameters == null) - { - throw new NullReferenceException("Could not locate process parameters table index " + processParametersTableIndex + " in group " + processGroup.Name + " for RML " + job.Rml.Name); - } + var processParameters = processGroup.ProcessParametersTables.FirstOrDefault(x => x.TableIndex == processParametersTableIndex); - //Perform color correction - foreach (var stop in job.Segments.SelectMany(x => x.BrushStops)) - { - if (stop.LiquidVolumes == null) + if (processParameters == null) { - stop.SetLiquidVolumes(job.Machine.Configuration, job.Rml, processParameters); + throw new NullReferenceException("Could not locate process parameters table index " + processParametersTableIndex + " in group " + processGroup.Name + " for RML " + job.Rml.Name); } - foreach (var liquidVolume in stop.LiquidVolumes) + //Perform color correction + foreach (var stop in job.Segments.SelectMany(x => x.BrushStops)) { - liquidVolume.Volume = 10; + if (stop.LiquidVolumes == null) + { + stop.SetLiquidVolumes(job.Machine.Configuration, job.Rml, processParameters); + } + + foreach (var liquidVolume in stop.LiquidVolumes) + { + liquidVolume.Volume = 10; + } } - } - if (Status != MachineStatuses.ReadyToDye) - { - throw new InvalidOperationException("Could not print while status = " + Status); - } + if (Status != MachineStatuses.ReadyToDye) + { + throw new InvalidOperationException("Could not print while status = " + Status); + } - RunningJob = null; - RunningJobStatus = null; + RunningJob = null; + RunningJobStatus = null; - var originalJob = job; + var originalJob = job; - CurrentProcessParameters = processParameters; + CurrentProcessParameters = processParameters; - StubJobRequest request = new StubJobRequest(); + StubJobRequest request = new StubJobRequest(); - if (job.NumberOfUnits < 1) - { - job.NumberOfUnits = 1; - } + if (job.NumberOfUnits < 1) + { + job.NumberOfUnits = 1; + } - job = job.Clone(); + job = job.Clone(); - var segments = job.OrderedSegments.ToList(); + var segments = job.OrderedSegments.ToList(); - for (int i = 0; i < job.NumberOfUnits - 1; i++) - { - foreach (var s in segments) + for (int i = 0; i < job.NumberOfUnits - 1; i++) { - job.Segments.Add(s); + foreach (var s in segments) + { + job.Segments.Add(s); + } } - } - - JobTicket ticket = new JobTicket(); - ticket.Guid = originalJob.Guid; - ticket.EnableInterSegment = job.EnableInterSegment; - ticket.InterSegmentLength = job.InterSegmentLength; - ticket.Length = job.Length; - ticket.WindingMethod = (JobWindingMethod)job.WindingMethod.Code; - ticket.Spool = new JobSpool(); - job.SpoolType.MapPrimitivesTo(ticket.Spool); - ticket.Spool.JobSpoolType = (JobSpoolType)job.SpoolType.Code; + JobTicket ticket = new JobTicket(); + ticket.Guid = originalJob.Guid; + ticket.EnableInterSegment = job.EnableInterSegment; + ticket.InterSegmentLength = job.InterSegmentLength; + ticket.Length = job.Length; + ticket.WindingMethod = (JobWindingMethod)job.WindingMethod.Code; + ticket.Spool = new JobSpool(); - ProcessParameters process = new ProcessParameters(); - processParameters.MapPrimitivesTo(process); - ticket.ProcessParameters = process; + job.SpoolType.MapPrimitivesTo(ticket.Spool); + ticket.Spool.JobSpoolType = (JobSpoolType)job.SpoolType.Code; - foreach (var segment in job.OrderedSegments) - { - JobSegment jobSegment = new JobSegment(); - jobSegment.Length = segment.LengthWithFactor; - jobSegment.Name = segment.Name; + ProcessParameters process = new ProcessParameters(); + processParameters.MapPrimitivesTo(process); + ticket.ProcessParameters = process; - foreach (var stop in segment.BrushStops) + foreach (var segment in job.OrderedSegments) { - JobBrushStop jobStop = new JobBrushStop(); - jobStop.Index = stop.StopIndex; - jobStop.OffsetPercent = stop.OffsetPercent; - jobStop.OffsetMeters = stop.OffsetMeters; + JobSegment jobSegment = new JobSegment(); + jobSegment.Length = segment.LengthWithFactor; + jobSegment.Name = segment.Name; - if (stop.LiquidVolumes == null) + foreach (var stop in segment.BrushStops) { - stop.SetLiquidVolumes(job.Machine.Configuration, job.Rml, processParameters); - } + JobBrushStop jobStop = new JobBrushStop(); + jobStop.Index = stop.StopIndex; + jobStop.OffsetPercent = stop.OffsetPercent; + jobStop.OffsetMeters = stop.OffsetMeters; - foreach (var liquidVolume in stop.LiquidVolumes) - { - JobDispenser dispenser = new JobDispenser(); - dispenser.Index = liquidVolume.IdsPack.PackIndex; - dispenser.Volume = liquidVolume.Volume; - dispenser.DispenserLiquidType = (DispenserLiquidType)liquidVolume.IdsPack.LiquidType.Code; - dispenser.DispenserStepDivision = (DispenserStepDivision)liquidVolume.DispenserStepDivision; + if (stop.LiquidVolumes == null) + { + stop.SetLiquidVolumes(job.Machine.Configuration, job.Rml, processParameters); + } - dispenser.NanoliterPerPulse = liquidVolume.IdsPack.Dispenser.NlPerPulse; + foreach (var liquidVolume in stop.LiquidVolumes) + { + JobDispenser dispenser = new JobDispenser(); + dispenser.Index = liquidVolume.IdsPack.PackIndex; + dispenser.Volume = liquidVolume.Volume; + dispenser.DispenserLiquidType = (DispenserLiquidType)liquidVolume.IdsPack.LiquidType.Code; + dispenser.DispenserStepDivision = (DispenserStepDivision)liquidVolume.DispenserStepDivision; + + dispenser.NanoliterPerPulse = liquidVolume.IdsPack.Dispenser.NlPerPulse; - dispenser.LiquidMaxNanoliterPerCentimeter = liquidVolume.LiquidMaxNanoliterPerCentimeter; - dispenser.NanoliterPerCentimeter = liquidVolume.NanoliterPerCentimeter; - dispenser.NanolitterPerSecond = liquidVolume.NanoliterPerSecond; - dispenser.PulsePerSecond = liquidVolume.PulsePerSecond; + dispenser.LiquidMaxNanoliterPerCentimeter = liquidVolume.LiquidMaxNanoliterPerCentimeter; + dispenser.NanoliterPerCentimeter = liquidVolume.NanoliterPerCentimeter; + dispenser.NanolitterPerSecond = liquidVolume.NanoliterPerSecond; + dispenser.PulsePerSecond = liquidVolume.PulsePerSecond; - jobStop.Dispensers.Add(dispenser); + jobStop.Dispensers.Add(dispenser); + } + + jobSegment.BrushStops.Add(jobStop); } - jobSegment.BrushStops.Add(jobStop); + ticket.Segments.Add(jobSegment); } - ticket.Segments.Add(jobSegment); - } + request.JobTicket = ticket; - request.JobTicket = ticket; - - JobHandler handler = null; + JobHandler handler = null; - handler = new JobHandler(async () => - { - try + handler = new JobHandler(async () => { - var result = await SendRequest(new StubAbortJobRequest()); - PrintingAborted?.Invoke(this, new PrintingEventArgs(handler, originalJob)); - PrintingEnded?.Invoke(this, new PrintingEventArgs(handler, originalJob)); - handler.RaiseCanceled(); - } - catch (Exception ex) - { - LogManager.Log(ex, "Failed to cancel job."); - } - }, originalJob, ticket, processParameters, JobHandlingMode); - - handler.StatusChanged += (x, s) => - { - RunningJobStatus = s; - }; + try + { + var result = await SendRequest(new StubAbortJobRequest()); + PrintingAborted?.Invoke(this, new PrintingEventArgs(handler, originalJob)); + PrintingEnded?.Invoke(this, new PrintingEventArgs(handler, originalJob)); + handler.RaiseCanceled(); + } + catch (Exception ex) + { + LogManager.Log(ex, "Failed to cancel job."); + } + }, originalJob, ticket, processParameters, JobHandlingMode); - LogRequestSent(request); - bool responseLogged = false; + handler.StatusChanged += (x, s) => + { + RunningJobStatus = s; + }; - SendContinuousRequest(request, null, TimeSpan.FromSeconds(2)).Subscribe((response) => - { - handler.RaiseStatusReceived(response.Message.Status); + LogRequestSent(request); + bool responseLogged = false; - if (!responseLogged) + SendContinuousRequest(request, null, TimeSpan.FromSeconds(2)).Subscribe((response) => { - responseLogged = true; - Status = MachineStatuses.Printing; - RunningJob = originalJob; - PrintingStarted?.Invoke(this, new PrintingEventArgs(handler, originalJob)); - LogResponseReceived(response.Message); - } - }, (ex) => - { - if (!(ex is ContinuousResponseAbortedException)) + handler.RaiseStatusReceived(response.Message.Status); + + if (!responseLogged) + { + responseLogged = true; + Status = MachineStatuses.Printing; + RunningJob = originalJob; + PrintingStarted?.Invoke(this, new PrintingEventArgs(handler, originalJob)); + LogResponseReceived(response.Message); + } + }, (ex) => { - Status = MachineStatuses.ReadyToDye; + if (!(ex is ContinuousResponseAbortedException)) + { + Status = MachineStatuses.ReadyToDye; - if (!handler.IsCanceled) + if (!handler.IsCanceled) + { + PrintingFailed?.Invoke(this, new PrintingFailedEventArgs(handler, originalJob, ex)); + PrintingEnded?.Invoke(this, new PrintingEventArgs(handler, originalJob)); + handler.RaiseFailed(ex); + LogRequestFailed(request, ex); + } + } + else { - PrintingFailed?.Invoke(this, new PrintingFailedEventArgs(handler, originalJob, ex)); - PrintingEnded?.Invoke(this, new PrintingEventArgs(handler, originalJob)); - handler.RaiseFailed(ex); - LogRequestFailed(request, ex); + Status = MachineStatuses.ReadyToDye; } - } - else + }, () => { Status = MachineStatuses.ReadyToDye; - } - }, () => - { - Status = MachineStatuses.ReadyToDye; - PrintingCompleted?.Invoke(this, new PrintingEventArgs(handler, originalJob)); - PrintingEnded?.Invoke(this, new PrintingEventArgs(handler, originalJob)); - handler.RaiseCompleted(); - }); + PrintingCompleted?.Invoke(this, new PrintingEventArgs(handler, originalJob)); + PrintingEnded?.Invoke(this, new PrintingEventArgs(handler, originalJob)); + handler.RaiseCompleted(); + }); + + return handler; - return handler; + }); } /// diff --git a/Software/Visual_Studio/Tango.Integration/Operation/PreparingJobProgressEventArgs.cs b/Software/Visual_Studio/Tango.Integration/Operation/PreparingJobProgressEventArgs.cs new file mode 100644 index 000000000..7c53fd7fb --- /dev/null +++ b/Software/Visual_Studio/Tango.Integration/Operation/PreparingJobProgressEventArgs.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; + +namespace Tango.Integration.Operation +{ + /// + /// Represents the event arguments. + /// + /// + public class PreparingJobProgressEventArgs : EventArgs + { + /// + /// Gets or sets the job. + /// + public Job Job { get; set; } + + /// + /// Gets or sets the progress. + /// + public double Progress { get; set; } + + /// + /// Gets or sets the total progress. + /// + public double Total { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj b/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj index 8d6d43c02..7bea3eccb 100644 --- a/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj +++ b/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj @@ -92,7 +92,10 @@ + + + @@ -176,7 +179,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/UpdateMachine.xml b/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/UpdateMachine.xml index f352bebb6..8d5e99f72 100644 Binary files a/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/UpdateMachine.xml and b/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/UpdateMachine.xml differ diff --git a/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGrid.cs b/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGrid.cs index f098af31d..552543320 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGrid.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/LightTouchDataGrid.cs @@ -555,16 +555,14 @@ namespace Tango.Touch.Controls current_top += (ordered[i].Margin.Top + ordered[i].ActualHeight + ordered[i].Margin.Bottom); - if (contentPresenter.Tag == null) - { - LightTouchDataGridRow row = contentPresenter.FindChild(); + LightTouchDataGridRow row = contentPresenter.FindChild(); - if (row != null) - { - contentPresenter.Tag = 1; - row.RegisterForPreviewMouseOrTouchUp(OnRowMouseTouchUp); - row.RegisterForPreviewMouseOrTouchDown(OnRowMouseTouchDown); - } + if (row != null) + { + row.UnRegisterMouseOrTouch(OnRowMouseTouchUp); + row.RegisterForPreviewMouseOrTouchUp(OnRowMouseTouchUp); + row.UnRegisterMouseOrTouch(OnRowMouseTouchDown); + row.RegisterForPreviewMouseOrTouchDown(OnRowMouseTouchDown); } } -- cgit v1.3.1