From b6b16143304b50744e974ddaa9c71c49766be4dc Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Sun, 9 Jan 2022 16:17:15 +0200 Subject: #5821 RML extension - Color calibration window --- .../Models/CalibrationPlotModel.cs | 205 +++++++++++++++++++++ .../Models/ColorLinearizationModel.cs | 43 +++++ .../Models/MachineModel.cs | 17 +- 3 files changed, 262 insertions(+), 3 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/CalibrationPlotModel.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ColorLinearizationModel.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/CalibrationPlotModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/CalibrationPlotModel.cs new file mode 100644 index 000000000..d6a7212c0 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/CalibrationPlotModel.cs @@ -0,0 +1,205 @@ +using OxyPlot; +using OxyPlot.Wpf; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using Tango.BL.Entities; +using Tango.BL.Enumerations; +using Tango.Core; + +namespace Tango.MachineStudio.ThreadExtensions.Models +{ + + public class CalibrationPlotModel : ExtendedObject + { + #region Properties + + public Plot DataPlotControl { get; set; } + public Plot LinearizationPlotControl { get; set; } + + private string _title; + + public string Title + { + get { return _title; } + set { _title = value; RaisePropertyChangedAuto(); } + } + + private FactorColors _color; + + private IList _LPoints; + + public IList LPoints + { + get { return _LPoints; } + set { _LPoints = value; } + } + + private IList _APoints; + + public IList APoints + { + get { return _APoints; } + set { _APoints = value; } + } + + private IList _BPoints; + + public IList BPoints + { + get { return _BPoints; } + set { _BPoints = value; } + } + + private IList _points; + /// + /// Binding to ItemsSource of line chart. + /// + public IList LinearizationPoints + { + get { return _points; } + set + { + _points = value; + RaisePropertyChangedAuto(); + } + } + + private int _step; + public int XStep + { + get { return _step; } + set { _step = value; RaisePropertyChangedAuto(); } + } + + private double _minY; + /// + /// From use to binding to left axis min value + /// + public double MinY + { + get { return _minY; } + set + { + _minY = value; RaisePropertyChangedAuto(); + } + } + + private double _maxY; + /// + /// To use to binding to left axis max value + /// + public double MaxY + { + get { return _maxY; } + set + { + _maxY = value; RaisePropertyChangedAuto(); + } + } + private int _maxX; + /// + /// Gets or sets the maximum lab plot X values for LinearizationGraph left part + /// + public int MaxX + { + get { return _maxX; } + set + { + _maxX = value; + RaisePropertyChangedAuto(); + } + } + + private double _linearizationMaxX; + + public double LinearizationMaxX + { + get { return _linearizationMaxX; } + set + { + _linearizationMaxX = value; + RaisePropertyChangedAuto(); + } + } + + private double _linearizationMaxY; + + public double LinearizationMaxY + { + get { return _linearizationMaxY; } + set + { + _linearizationMaxY = value; + RaisePropertyChangedAuto(); + } + } + #endregion + + public CalibrationPlotModel(FactorColors color, string title) + { + LinearizationPoints = new List(); + LPoints = new List(); + APoints = new List(); + BPoints = new List(); + _color = color; + _title = title; + + } + public void ClearResults() + { + LPoints.Clear(); + APoints.Clear(); + BPoints.Clear(); + LinearizationPoints.Clear(); + } + + public void InitDataGraph(List items) + { + if (DataPlotControl == null) + { + Debug.WriteLine("ERROR!!! CreateGraph. Plot Control is NULL."); + return; + } + + if (items == null || items.Count == 0) + return; + + ClearResults(); + DataPlotControl.InvalidatePlot(true); + LinearizationPlotControl.InvalidatePlot(true); + + foreach (var labItem in items) + { + LPoints.Add(new DataPoint(labItem.InkPercentage, labItem.L)); + APoints.Add(new DataPoint(labItem.InkPercentage, labItem.A)); + BPoints.Add(new DataPoint(labItem.InkPercentage, labItem.B)); + } + int maxValue = (int)(items.Max(x => x.InkPercentage)); + MaxX = Math.Max(100, maxValue); + + MinY = Math.Min(0, items.Min(x => Math.Min(x.L, Math.Min(x.A, x.B)))); + MaxY = Math.Max( 100, items.Max(x => Math.Max(x.L, Math.Max(x.A, x.B)))); + + DataPlotControl.InvalidatePlot(true); + } + + public void InitLinearizationGraph(List items, List outputPoints) + { + + if (outputPoints == null) + return; + + foreach (var nw in items.Zip(outputPoints, Tuple.Create)) + { + LinearizationPoints.Add(new DataPoint(nw.Item1.InkPercentage, nw.Item2)); + } + + LinearizationMaxX = Math.Max(100, LinearizationPoints.Max(x => x.X)); + LinearizationMaxY = Math.Max(100, LinearizationPoints.Max(x => x.Y)); + + LinearizationPlotControl.InvalidatePlot(true); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ColorLinearizationModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ColorLinearizationModel.cs new file mode 100644 index 000000000..39774f7d8 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ColorLinearizationModel.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Documents; + +namespace Tango.MachineStudio.ThreadExtensions.Models +{ + public class ColorLinearizationModel + { + public class LinearizationDataItem + { + public double InkPercentage { get; set; } + public double L { get; set; } + public double A { get; set; } + public double B { get; set; } + } + + public ColorLinearizationModel() + { + + } + + public void GetDataFromFile(string fileName, out List items, ref string errors) + { + items = null; + try + { + using (ExcelReader reader = new ExcelReader(fileName)) + { + items = reader.GetDataByIndex("Sheet1", 2); + } + } + catch (Exception ex) + { + errors = ex.Message; + } + + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/MachineModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/MachineModel.cs index e41a6a220..c2b00fe92 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/MachineModel.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/MachineModel.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.BL.Entities; using Tango.Core; namespace Tango.MachineStudio.ThreadExtensions.Models @@ -10,14 +11,14 @@ namespace Tango.MachineStudio.ThreadExtensions.Models public class MachineModel : ExtendedObject { public String Guid { get; set; } - + public string Name { get; set; } protected String _serialnumber; - + public String SerialNumber { - get{ return _serialnumber; } + get { return _serialnumber; } set { _serialnumber = value; @@ -35,6 +36,16 @@ namespace Tango.MachineStudio.ThreadExtensions.Models } } + protected IEnumerable _idspacks; + public IEnumerable IdsPacks + { + get { return _idspacks; } + set + { + _idspacks = value; + } + } + public MachineModel() { HasRMLTest = false; -- cgit v1.3.1 From 85597e05c8e3d5bd8662e89885b6fec27cbf0fc7 Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Thu, 13 Jan 2022 14:40:35 +0200 Subject: #5821 Save all changes in DB and loading data. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 22675456 -> 22675456 bytes .../Models/CalibrationPlotModel.cs | 24 +- .../Models/ColorLinearizationModel.cs | 1 - .../ViewModels/ColorCalibrationTabVM.cs | 314 ++++++++++++--------- .../ViewModels/ColorCalibrationViewVM.cs | 173 ++++++++---- .../ViewModels/MainViewVM.cs | 5 +- .../Views/ColorCalibrationView.xaml | 2 +- .../Views/ColorCalibrationView.xaml.cs | 68 ++--- .../RMLExtensionColorCalibrationBuilder.cs | 64 +++++ ...ensionColorCalibrationTestsLiquidDataBuilder.cs | 42 +++ .../DTO/RmlExtensionColorCalibrationDTOBase.cs | 4 +- .../Tango.BL/DTO/RmlExtensionColorShadeDTOBase.cs | 4 +- .../Entities/RmlExtensionColorCalibrationBase.cs | 42 +-- ...RmlExtensionColorCalibrationsTestsLiquidData.cs | 5 + .../Entities/RmlExtensionColorShadeBase.cs | 42 +-- Software/Visual_Studio/Tango.BL/Tango.BL.csproj | 2 + .../DB/RML_EXTENSION_COLOR_CALIBRATIONS.cs | 2 +- .../DB/RML_EXTENSION_COLOR_SHADES.cs | 2 +- .../Tango.DAL.Remote/DB/RemoteADO.edmx | 32 +-- .../Tango.DAL.Remote/DB/RemoteADO.edmx.diagram | 198 ++++++------- 21 files changed, 625 insertions(+), 401 deletions(-) create mode 100644 Software/Visual_Studio/Tango.BL/Builders/RMLExtensionColorCalibrationBuilder.cs create mode 100644 Software/Visual_Studio/Tango.BL/Builders/RMLExtensionColorCalibrationTestsLiquidDataBuilder.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index c3b215d87..ef02f27a0 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 165b7e2d5..7bbba7f83 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/CalibrationPlotModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/CalibrationPlotModel.cs index d6a7212c0..0f844097d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/CalibrationPlotModel.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/CalibrationPlotModel.cs @@ -157,18 +157,14 @@ namespace Tango.MachineStudio.ThreadExtensions.Models public void InitDataGraph(List items) { - if (DataPlotControl == null) - { - Debug.WriteLine("ERROR!!! CreateGraph. Plot Control is NULL."); - return; - } - if (items == null || items.Count == 0) return; ClearResults(); - DataPlotControl.InvalidatePlot(true); - LinearizationPlotControl.InvalidatePlot(true); + if (DataPlotControl != null) + DataPlotControl.InvalidatePlot(true); + if (LinearizationPlotControl != null) + LinearizationPlotControl.InvalidatePlot(true); foreach (var labItem in items) { @@ -181,16 +177,17 @@ namespace Tango.MachineStudio.ThreadExtensions.Models MinY = Math.Min(0, items.Min(x => Math.Min(x.L, Math.Min(x.A, x.B)))); MaxY = Math.Max( 100, items.Max(x => Math.Max(x.L, Math.Max(x.A, x.B)))); - - DataPlotControl.InvalidatePlot(true); + + if (DataPlotControl != null) + DataPlotControl.InvalidatePlot(true); } public void InitLinearizationGraph(List items, List outputPoints) { - if (outputPoints == null) return; + LinearizationPoints.Clear(); foreach (var nw in items.Zip(outputPoints, Tuple.Create)) { LinearizationPoints.Add(new DataPoint(nw.Item1.InkPercentage, nw.Item2)); @@ -199,7 +196,10 @@ namespace Tango.MachineStudio.ThreadExtensions.Models LinearizationMaxX = Math.Max(100, LinearizationPoints.Max(x => x.X)); LinearizationMaxY = Math.Max(100, LinearizationPoints.Max(x => x.Y)); - LinearizationPlotControl.InvalidatePlot(true); + if (LinearizationPlotControl != null) + { + LinearizationPlotControl.InvalidatePlot(true); + } } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ColorLinearizationModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ColorLinearizationModel.cs index 39774f7d8..148f0f416 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ColorLinearizationModel.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ColorLinearizationModel.cs @@ -37,7 +37,6 @@ namespace Tango.MachineStudio.ThreadExtensions.Models { errors = ex.Message; } - } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationTabVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationTabVM.cs index 103052b52..eed8d41d4 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationTabVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationTabVM.cs @@ -12,6 +12,8 @@ using Tango.MachineStudio.Common.Notifications; using Tango.PMR.ColorLab; using Tango.ColorCalibration; using Tango.BL.ActionLogs; +using Tango.BL.Entities; +using Tango.Core; namespace Tango.MachineStudio.ThreadExtensions.ViewModels { @@ -20,7 +22,8 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels private INotificationProvider _notification; private IActionLogManager _actionLogManager; private ILinearizationMeasurements _linearizationMeasurementscalibrator; - + private List _liquids; + #region Properties private string _name; @@ -33,6 +36,8 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels set { _name = value; + if(RmlExtensionColorCalibrationsTest != null) + RmlExtensionColorCalibrationsTest.Name = _name; RaisePropertyChangedAuto(); } } @@ -42,7 +47,9 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels public int TabIndex { get { return _tabIndex; } - set { _tabIndex = value; } + set { _tabIndex = value; + RaisePropertyChangedAuto(); + } } @@ -55,75 +62,43 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels get { return _isSelected; } set { _isSelected = value; RaisePropertyChangedAuto(); } } + + public CalibrationPlotModel CyanPlot { get; set; } + + public CalibrationPlotModel MagentaPlot { get; set; } + + public CalibrationPlotModel YellowPlot { get; set; } + + public CalibrationPlotModel BlackPlot { get; set; } + + public CalibrationDataVM CyanCalibrationData { get; set; } + + public CalibrationDataVM MagentaCalibrationData { get; set; } + + public CalibrationDataVM YellowCalibrationData { get; set; } + + public CalibrationDataVM BlackCalibrationData { get; set; } + + private RmlExtensionColorCalibrationsTest _rmlExtensionColorCalibrationsTest; - private CalibrationPlotModel _cyanPlot; - - public CalibrationPlotModel CyanPlot + public RmlExtensionColorCalibrationsTest RmlExtensionColorCalibrationsTest { - get { return _cyanPlot; } - set - { - _cyanPlot = value; - RaisePropertyChangedAuto(); + get { return _rmlExtensionColorCalibrationsTest; } + set { _rmlExtensionColorCalibrationsTest = value; + OnRmlExtensionColorCalibrationsTestChanged(); } } - private CalibrationPlotModel _magentaPlot; - - public CalibrationPlotModel MagentaPlot - { - get { return _magentaPlot; } - set { _magentaPlot = value; } - } - - private CalibrationPlotModel _yellowPlot; - - public CalibrationPlotModel YellowPlot - { - get { return _yellowPlot; } - set { _yellowPlot = value; } - } - - private CalibrationPlotModel _blackPlot; - - public CalibrationPlotModel BlackPlot - { - get { return _blackPlot; } - set { _blackPlot = value; } - } - - private CalibrationDataVM _cyanCalibrationData; - - public CalibrationDataVM CyanCalibrationData - { - get { return _cyanCalibrationData; } - set { _cyanCalibrationData = value; } - } - - private CalibrationDataVM _magentaCalibrationData; - - public CalibrationDataVM MagentaCalibrationData - { - get { return _magentaCalibrationData; } - set { _magentaCalibrationData = value; } - } - - private CalibrationDataVM _yellowCalibrationData; - - public CalibrationDataVM YellowCalibrationData - { - get { return _yellowCalibrationData; } - set { _yellowCalibrationData = value; } - } - - private CalibrationDataVM _blackCalibrationData; - - public CalibrationDataVM BlackCalibrationData - { - get { return _blackCalibrationData; } - set { _blackCalibrationData = value; RaisePropertyChangedAuto(); } - } - + /// + /// Gets or sets last points before save. Used in Save to remove points before save new. + /// + /// + /// The removed points. + /// + public Dictionary> RemovedPoints { get; set; } + + public bool IsTabLoaded { get; set; } + #endregion @@ -136,11 +111,14 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels #endregion - public ColorCalibrationTabVM(INotificationProvider notification, IActionLogManager actionLogManager) + public ColorCalibrationTabVM(INotificationProvider notification, IActionLogManager actionLogManager, List liquids) { _notification = notification; _actionLogManager = actionLogManager; _linearizationMeasurementscalibrator = new DefaultColorCalibrator(); + _liquids = liquids; + RemovedPoints = new Dictionary>(); + IsTabLoaded = false; CyanPlot = new CalibrationPlotModel(FactorColors.CYAN, "Cyan"); YellowPlot = new CalibrationPlotModel(FactorColors.YELLOW, "Yellow"); @@ -156,105 +134,92 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels ImportMagentaDataCommand = new RelayCommand(ImportMagentaData); ImportYellowDataCommand = new RelayCommand(ImportYellowData); ImportBlackDataCommand = new RelayCommand(ImportBlackData); + } #region Methods - private async void ImportCyanData(object obj) + private void ImportCyanData(object obj) { - List items; if (ImportDataFromFile(out items) && items.Count > 0) { - CyanPlot.InitDataGraph(items); - - List outputPoints = new List(); - - await Task.Factory.StartNew(() => + CreatePlots(PMR.ColorLab.LiquidType.Cyan, CyanPlot, items, CyanCalibrationData); + SynchronizedObservableCollection data = RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData; + var liquidtype = _liquids.Where(l => l.Type == LiquidTypes.Cyan).FirstOrDefault(); + var cyanliquidData = RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData.Where(x => x.LiquidTypeGuid == liquidtype.Guid).FirstOrDefault(); + if(cyanliquidData != null) { - outputPoints = GetLinearizationMeasurements(items, PMR.ColorLab.LiquidType.Cyan); - }); - - CyanPlot.InitLinearizationGraph(items, outputPoints); - CyanCalibrationData.CalibrationPoints.Clear(); - var index = 1; - foreach (var nw in items.Zip(outputPoints, Tuple.Create)) - { - CyanCalibrationData.CalibrationPoints.Add(new CalibrationDataPointVM() { Index = index++, X = nw.Item1.InkPercentage, Y = nw.Item2 }); + if(!RemovedPoints.ContainsKey(LiquidTypes.Cyan)) + { + RemovedPoints[LiquidTypes.Cyan] = new List(cyanliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.ToList()); + } + cyanliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Clear(); + items.ForEach(x => cyanliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Add(new RmlExtensionColorCalibrationsTestsLiquidDataPoint() { Ink = x.InkPercentage, L = x.L, A = x.A, B = x.B })); } } } - private async void ImportMagentaData(object obj) + private void ImportMagentaData(object obj) { - List items; if (ImportDataFromFile(out items) && items.Count > 0) { - MagentaPlot.InitDataGraph(items); - - List outputPoints = new List(); - - await Task.Factory.StartNew(() => + CreatePlots(PMR.ColorLab.LiquidType.Magenta, MagentaPlot, items, MagentaCalibrationData); + SynchronizedObservableCollection data = RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData; + var liquidtype = _liquids.Where(l => l.Type == LiquidTypes.Magenta).FirstOrDefault(); + var magentaliquidData = RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData.Where(x => x.LiquidTypeGuid == liquidtype.Guid).FirstOrDefault(); + if (magentaliquidData != null) { - outputPoints = GetLinearizationMeasurements(items, PMR.ColorLab.LiquidType.Magenta); - }); - - MagentaPlot.InitLinearizationGraph(items, outputPoints); - MagentaCalibrationData.CalibrationPoints.Clear(); - var index = 1; - foreach (var nw in items.Zip(outputPoints, Tuple.Create)) - { - MagentaCalibrationData.CalibrationPoints.Add(new CalibrationDataPointVM() { Index = index++, X = nw.Item1.InkPercentage, Y = nw.Item2}); - } + if (!RemovedPoints.ContainsKey(LiquidTypes.Magenta)) + { + RemovedPoints[LiquidTypes.Magenta] = new List(magentaliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.ToList()); + } + magentaliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Clear(); + items.ForEach(x => magentaliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Add(new RmlExtensionColorCalibrationsTestsLiquidDataPoint() { Ink = x.InkPercentage, L = x.L, A = x.A, B = x.B })); + } } } - private async void ImportYellowData(object obj) + private void ImportYellowData(object obj) { - List items; if (ImportDataFromFile(out items) && items.Count > 0) { - YellowPlot.InitDataGraph(items); - - List outputPoints = new List(); - - await Task.Factory.StartNew(() => + CreatePlots(PMR.ColorLab.LiquidType.Yellow, YellowPlot, items, YellowCalibrationData); + SynchronizedObservableCollection data = RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData; + var liquidtype = _liquids.Where(l => l.Type == LiquidTypes.Yellow).FirstOrDefault(); + var yellowliquidData = RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData.Where(x => x.LiquidTypeGuid == liquidtype.Guid).FirstOrDefault(); + if (yellowliquidData != null) { - outputPoints = GetLinearizationMeasurements(items, PMR.ColorLab.LiquidType.Yellow); - }); - YellowPlot.InitLinearizationGraph(items, outputPoints); - YellowCalibrationData.CalibrationPoints.Clear(); - var index = 1; - foreach (var nw in items.Zip(outputPoints, Tuple.Create)) - { - YellowCalibrationData.CalibrationPoints.Add(new CalibrationDataPointVM() { Index = index++, X = nw.Item1.InkPercentage, Y = nw.Item2 }); + if (!RemovedPoints.ContainsKey(LiquidTypes.Yellow)) + { + RemovedPoints[LiquidTypes.Yellow] = new List(yellowliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.ToList()); + } + yellowliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Clear(); + items.ForEach(x => yellowliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Add(new RmlExtensionColorCalibrationsTestsLiquidDataPoint() { Ink = x.InkPercentage, L = x.L, A = x.A, B = x.B })); } } } - - - private async void ImportBlackData(object obj) + + private void ImportBlackData(object obj) { List items; if (ImportDataFromFile(out items) && items.Count > 0) { - BlackPlot.InitDataGraph(items); - - List outputPoints = new List(); - - await Task.Factory.StartNew(() => + CreatePlots(PMR.ColorLab.LiquidType.Black, BlackPlot, items, BlackCalibrationData); + SynchronizedObservableCollection data = RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData; + var liquidtype = _liquids.Where(l => l.Type == LiquidTypes.Black).FirstOrDefault(); + var blackliquidData = RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData.Where(x => x.LiquidTypeGuid == liquidtype.Guid).FirstOrDefault(); + if (blackliquidData != null) { - outputPoints = GetLinearizationMeasurements(items, PMR.ColorLab.LiquidType.Black); - }); - BlackPlot.InitLinearizationGraph(items, outputPoints); - BlackCalibrationData.CalibrationPoints.Clear(); - var index = 1; - foreach (var nw in items.Zip(outputPoints, Tuple.Create)) - { - BlackCalibrationData.CalibrationPoints.Add(new CalibrationDataPointVM() { Index = index++, X = nw.Item1.InkPercentage, Y = nw.Item2 }); + if (!RemovedPoints.ContainsKey(LiquidTypes.Black)) + { + RemovedPoints[LiquidTypes.Black] = new List(blackliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.ToList()); + } + blackliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Clear(); + items.ForEach(x => blackliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Add(new RmlExtensionColorCalibrationsTestsLiquidDataPoint() { Ink = x.InkPercentage, L = x.L, A = x.A, B = x.B })); } } @@ -286,6 +251,93 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels return false; } + public void InitData() + { + if(RmlExtensionColorCalibrationsTest != null) + { + SynchronizedObservableCollection data = RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData; + foreach( var liquidData in data) + { + var liquidType = liquidData.LiquidType; + var points = liquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.OrderBy(y => y.Ink).ToList(); ; + if (points.Count > 0) + { + List items = new List(); + points.ForEach(x => items.Add(new ColorLinearizationModel.LinearizationDataItem() { InkPercentage = x.Ink, L = x.L, A = x.A, B = x.B })); + items.OrderBy(y => y.InkPercentage).ToList(); + CreatePlots(ConvertLiquidTypeToPMR(liquidType), GetPlot(liquidType), items, GetCalibrationDataVM(liquidType)); + } + } + } + } + + private CalibrationPlotModel GetPlot(BL.Entities.LiquidType liquidType) + { + switch(liquidType.Type) + { + case LiquidTypes.Cyan: + return CyanPlot; + case LiquidTypes.Magenta: + return MagentaPlot; + case LiquidTypes.Yellow: + return YellowPlot; + case LiquidTypes.Black: + return BlackPlot; + default: + return null; + } + } + private CalibrationDataVM GetCalibrationDataVM(BL.Entities.LiquidType liquidType) + { + switch (liquidType.Type) + { + case LiquidTypes.Cyan: + return CyanCalibrationData; + case LiquidTypes.Magenta: + return MagentaCalibrationData; + case LiquidTypes.Yellow: + return YellowCalibrationData; + case LiquidTypes.Black: + return BlackCalibrationData; + default: + return null; + } + } + private PMR.ColorLab.LiquidType ConvertLiquidTypeToPMR(BL.Entities.LiquidType liquidType) + { + if (liquidType.Type == LiquidTypes.Cyan) + return PMR.ColorLab.LiquidType.Cyan; + if (liquidType.Type == LiquidTypes.Yellow) + return PMR.ColorLab.LiquidType.Yellow; + if (liquidType.Type == LiquidTypes.Magenta) + return PMR.ColorLab.LiquidType.Magenta; + return PMR.ColorLab.LiquidType.Black; + } + + private async void CreatePlots(PMR.ColorLab.LiquidType liquidtype, CalibrationPlotModel plot, List items, CalibrationDataVM calibrationTable) + { + plot.InitDataGraph(items); + + List outputPoints = new List(); + + await Task.Factory.StartNew(() => + { + outputPoints = GetLinearizationMeasurements(items, liquidtype); + }); + + plot.InitLinearizationGraph(items, outputPoints); + calibrationTable.CalibrationPoints.Clear(); + var index = 1; + foreach (var nw in items.Zip(outputPoints, Tuple.Create)) + { + calibrationTable.CalibrationPoints.Add(new CalibrationDataPointVM() { Index = index++, X = nw.Item1.InkPercentage, Y = nw.Item2 }); + } + } + + private void OnRmlExtensionColorCalibrationsTestChanged() + { + + } #endregion #region CreateLinearizationGraph diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationViewVM.cs index 99bb896d7..fc15c8caf 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationViewVM.cs @@ -31,6 +31,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels private IActionLogManager _actionLogManager; private ObservablesContext _active_context; + private List _liquids; public event EventHandler SaveColorCalibration; @@ -69,7 +70,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels private string _RMLExtentionGUID; - public string RMLExtemtionGUID + public string RMLExtentionGUID { get { return _RMLExtentionGUID; } set @@ -130,6 +131,22 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels } } + private RmlExtensionColorCalibration _rmlExtensionColorCalibration; + + public RmlExtensionColorCalibration RmlExtensionColorCalibration + { + get { return _rmlExtensionColorCalibration; } + set { _rmlExtensionColorCalibration = value; } + } + + //private ObservableCollection _rmlExtensionColorCalibrationsTests; + + //public ObservableCollection RmlExtensionColorCalibrationsTests + //{ + // get { return _rmlExtensionColorCalibrationsTests; } + // set { _rmlExtensionColorCalibrationsTests = value; } + //} + #endregion @@ -164,9 +181,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels CreateColorDataImportExcelTemplateCommand = new RelayCommand(CreateColorDataImportExcelTemplate); } - - #region Methods private void OnRMLExtensionGUIDChanged() @@ -175,6 +190,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels private void SelectedMachineChanged() { + SelectedTab = null; LoadColorCalibrations(); } @@ -293,46 +309,90 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels IsFree = false; return; } - IsFree = false; - if (_active_context != null) + try { - _active_context.Dispose(); - } + IsFree = false; + if (_active_context != null) + { + _active_context.Dispose(); + } - _active_context = ObservablesContext.CreateDefault(); + _active_context = ObservablesContext.CreateDefault(); + if (_liquids == null) + { + _liquids = _active_context.LiquidTypes.ToList(); + } + CalibrationTabs.Clear(); + LogManager.Log("Loading color calibration tests ..."); - await Task.Factory.StartNew(() => - { using (_notification.PushTaskItem("Loading Color Calibrations Tests ...")) { + var testResults = await new RMLExtensionColorCalibrationBuilder(_active_context).SetAll().ForRMLExtension(RMLExtentionGUID).ForMachine(Machine.Guid).WithTests().BuildAsync(); + RmlExtensionColorCalibration = testResults.OrderBy(x => x.ID).ToList().FirstOrDefault(); + if (RmlExtensionColorCalibration == null) + { + RmlExtensionColorCalibration = new RmlExtensionColorCalibration() { RmlsExtensionsGuid = RMLExtentionGUID, MachineGuid = Machine.Guid }; + _active_context.RmlExtensionColorCalibrations.Add(RmlExtensionColorCalibration); + _active_context.SaveChanges(); + } + + foreach (var test in RmlExtensionColorCalibration.RmlExtensionColorCalibrationsTests) + { + CalibrationTabs.Add(new ColorCalibrationTabVM(_notification, _actionLogManager, _liquids) { RmlExtensionColorCalibrationsTest = test, Name = test.Name }); + if (CalibrationTabs.Count == 1) + SelectedTab = CalibrationTabs[0]; + } + if (CalibrationTabs.Count == 0) + { + SelectedTab = CreateNewColorCalibrationTabVM("Untitled", 1); + CalibrationTabs.Add(SelectedTab); + _active_context.SaveChanges(); + } + if (IsViewLoaded) + { + CalibrationTabs.ToList().ForEach(x => x.InitData()); + } } - }); - if (CalibrationTabs.Count == 0) + } + catch (Exception ex) { - SelectedTab = CreateNewColorCalibrationTabVM("Untitled", 1); - CalibrationTabs.Add(SelectedTab); - //_active_context.RmlExtensionCalibrationTests.Add(SelectedTab.TestResult); - // await _active_context.SaveChangesAsync(); + LogManager.Log(ex, $"Error loading Color Calibration tests.\n{ex.FlattenMessage()}"); } - //LoadColorCalibarions(); - IsFree = true; - } - - public void UpdatePlots() - { - if (IsViewLoaded) + finally { - //CyanPlot.CreateGraph(CyanProcessData.ToList(), true); - //MagentaPlot.CreateGraph(MagentaProcessData.ToList(), true); - //YellowPlot.CreateGraph(YellowProcessData.ToList(), false); - //BlackPlot.CreateGraph(BlackProcessData.ToList(), true); + IsFree = true; } } - + private ColorCalibrationTabVM CreateNewColorCalibrationTabVM(string name, int index) { - ColorCalibrationTabVM newtab = new ColorCalibrationTabVM(_notification, _actionLogManager) { Name = name , TabIndex = index}; - + ColorCalibrationTabVM newtab = new ColorCalibrationTabVM(_notification, _actionLogManager, _liquids) { Name = name, TabIndex = index }; + + newtab.RmlExtensionColorCalibrationsTest = new RmlExtensionColorCalibrationsTest() + { + RmlExtensionColorCalibrationGuid = RMLExtentionGUID, + Name = name + }; + var liquidDataCollection = new SynchronizedObservableCollection(); + var liquidtype = _liquids.Where(l => l.Type == LiquidTypes.Cyan).FirstOrDefault(); + var l_guid = liquidtype.Guid; + liquidDataCollection.Add(new RmlExtensionColorCalibrationsTestsLiquidData() { RmlExtensionColorCalibrationsTestGuid = newtab.RmlExtensionColorCalibrationsTest.Guid, LiquidTypeGuid = l_guid }); + liquidtype = _liquids.Where(l => l.Type == LiquidTypes.Magenta).FirstOrDefault(); + l_guid = liquidtype.Guid; + liquidDataCollection.Add(new RmlExtensionColorCalibrationsTestsLiquidData() { RmlExtensionColorCalibrationsTestGuid = newtab.RmlExtensionColorCalibrationsTest.Guid, LiquidTypeGuid = l_guid}); + liquidtype = _liquids.Where(l => l.Type == LiquidTypes.Yellow).FirstOrDefault(); + l_guid = liquidtype.Guid; + liquidDataCollection.Add(new RmlExtensionColorCalibrationsTestsLiquidData() { RmlExtensionColorCalibrationsTestGuid = newtab.RmlExtensionColorCalibrationsTest.Guid, LiquidTypeGuid = l_guid }); + liquidtype = _liquids.Where(l => l.Type == LiquidTypes.Black).FirstOrDefault(); + l_guid = liquidtype.Guid; + liquidDataCollection.Add(new RmlExtensionColorCalibrationsTestsLiquidData() { RmlExtensionColorCalibrationsTestGuid = newtab.RmlExtensionColorCalibrationsTest.Guid, LiquidTypeGuid = l_guid }); + newtab.RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData = liquidDataCollection; + if(RmlExtensionColorCalibration != null) + { + RmlExtensionColorCalibration.RmlExtensionColorCalibrationsTests.Add(newtab.RmlExtensionColorCalibrationsTest); + // _active_context.RmlExtensionColorCalibrations.Add(RmlExtensionColorCalibration); + } + return newtab; } @@ -350,7 +410,16 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels return; if (_notification.ShowQuestion("Are you sure you want to delete the selected tab?")) { - // _active_context.RmlExtensionTestResults.Remove(tab.TestResult); + foreach( var liquidData in tab.RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData) + { + + _active_context.RmlExtensionColorCalibrationsTestsLiquidDataPoints.RemoveRange(liquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints); + } + _active_context.RmlExtensionColorCalibrationsTestsLiquidData.RemoveRange(tab.RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData); + tab.RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData = null; + + RmlExtensionColorCalibration.RmlExtensionColorCalibrationsTests.Remove(tab.RmlExtensionColorCalibrationsTest); + _active_context.RmlExtensionColorCalibrationsTests.Remove(tab.RmlExtensionColorCalibrationsTest); CalibrationTabs.Remove(tab); SelectedTab = CalibrationTabs.LastOrDefault(); @@ -377,8 +446,8 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels if (!String.IsNullOrWhiteSpace(name)) { var tab = CreateNewColorCalibrationTabVM(name, (CalibrationTabs.Count + 1)); + _active_context.SaveChanges(); CalibrationTabs.Add(tab); - //_active_context.RmlExtensionTestResults.Add(tab.TestResult); SelectedTab = tab; return true; } @@ -420,30 +489,24 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels try { IsFree = false; + DateTime lastUpdated = DateTime.UtcNow; + RmlExtensionColorCalibration.LastUpdated = lastUpdated; - //SelectedColorProcessParameter.LastUpdated = DateTime.UtcNow; - - //foreach (var item in RemovedColorProcessDataBeforeSave) - //{ - // var existingColorProcessData = await _active_context.ColorProcessData.FirstOrDefaultAsync(y => y.Guid == item); - // if (existingColorProcessData != null) - // { - // _active_context.ColorProcessData.Remove(existingColorProcessData); - // } - //} - //foreach (var colordata in SelectedColorProcessParameter.ColorProcessData) - //{ - // colordata.LastUpdated = DateTime.UtcNow; - //} - //foreach (var factordata in SelectedColorProcessParameter.ColorProcessFactors) - //{ - // factordata.LastUpdated = DateTime.UtcNow; - //} - //foreach (var inkdata in SelectedColorProcessParameter.ColorProcessInkUptake) - //{ - // inkdata.LastUpdated = DateTime.UtcNow; - //} - + foreach (var tab in CalibrationTabs) + { + tab.RmlExtensionColorCalibrationsTest.LastUpdated = lastUpdated; + var removedPoints = tab.RemovedPoints; + foreach (var liquidData in tab.RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData) + { + var liquidtype = _liquids.Where(l => l.Guid == liquidData.LiquidTypeGuid).FirstOrDefault(); + if (liquidtype != null && removedPoints.ContainsKey(liquidtype.Type)) + { + _active_context.RmlExtensionColorCalibrationsTestsLiquidDataPoints.RemoveRange(removedPoints[liquidtype.Type]); + } + liquidData.LastUpdated = lastUpdated; + } + tab.RemovedPoints.Clear(); + } await _active_context.SaveChangesAsync(); // LoadColorParameters(); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs index e8aafca9d..1cc6e1dcc 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs @@ -1047,14 +1047,11 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels TestResultsViewVM.ThreadName = ActiveRML.Manufacturer; ColorCalibrationViewVM = new ColorCalibrationViewVM(_notification, _actionLogManager); - ColorCalibrationViewVM.RMLExtemtionGUID = guid; + ColorCalibrationViewVM.RMLExtentionGUID = guid; ColorCalibrationViewVM.ActiveRML = ActiveRML; ColorCalibrationViewVM.RMLGUID = ActiveRML.Guid; ColorCalibrationViewVM.Machine = SelectedMachine; - - - if (ActiveRMLExtension.RMLStatus == RMLExtensionStatus.New) { ColorParametersVewVM.SaveColorParameters -= UpdateStatus; diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorCalibrationView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorCalibrationView.xaml index 278d58d02..407ad2e9f 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorCalibrationView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorCalibrationView.xaml @@ -175,7 +175,7 @@ - + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorCalibrationView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorCalibrationView.xaml.cs index 06bd67231..84219c093 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorCalibrationView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorCalibrationView.xaml.cs @@ -26,30 +26,8 @@ namespace Tango.MachineStudio.ThreadExtensions.Views public ColorCalibrationView() { InitializeComponent(); - //this.Loaded += ColorCalibrationView_Loaded; } - - //private void ColorCalibrationView_Loaded(object sender, RoutedEventArgs e) - //{ - // if (contentGrid != null && contentGrid.DataContext is ColorCalibrationViewVM) - // { - // ColorCalibrationViewVM vm = (ColorCalibrationViewVM)contentGrid.DataContext; - // DataTemplate myDataTemplate = cyanChartsContent.ContentTemplate; - - - // vm.CyanPlot.DataPlotControl = (Plot)cyanChartsContent.ContentTemplate.FindName("LABDataPlot", cyanChartsContent); - // vm.CyanPlot.LinearizationPlotControl = (Plot)cyanChartsContent.ContentTemplate.FindName("LinearizationPlot", cyanChartsContent); - // vm.MagentaPlot.DataPlotControl = (Plot)magentaChartsContent.ContentTemplate.FindName("LABDataPlot", cyanChartsContent); - // vm.MagentaPlot.LinearizationPlotControl = (Plot)magentaChartsContent.ContentTemplate.FindName("LinearizationPlot", cyanChartsContent); - // vm.YellowPlot.DataPlotControl = (Plot)yellowChartsContent.ContentTemplate.FindName("LABDataPlot", cyanChartsContent); - // vm.YellowPlot.LinearizationPlotControl = (Plot)yellowChartsContent.ContentTemplate.FindName("LinearizationPlot", cyanChartsContent); - // vm.BlackPlot.DataPlotControl = (Plot)blackChartsContent.ContentTemplate.FindName("LABDataPlot", cyanChartsContent); - // vm.BlackPlot.LinearizationPlotControl = (Plot)blackChartsContent.ContentTemplate.FindName("LinearizationPlot", cyanChartsContent); - - // vm.IsViewLoaded = true; - // } - //} - + private void ContentGrid_Loaded(object sender, RoutedEventArgs e) { var grid = (UIElement)sender; @@ -57,21 +35,43 @@ namespace Tango.MachineStudio.ThreadExtensions.Views { ColorCalibrationViewVM vm = (ColorCalibrationViewVM)((UniformGrid)grid).DataContext; ColorCalibrationTabVM selectedTab = vm.SelectedTab; - // var Plot = (cyanChartsContent as FrameworkElement).FindChild("LABDataPlot"); - if (selectedTab != null) + if (selectedTab != null && !selectedTab.IsTabLoaded) { - selectedTab.CyanPlot.DataPlotControl = (cyanChartsContent as FrameworkElement).FindChild("LABDataPlot"); - selectedTab.CyanPlot.LinearizationPlotControl = (cyanChartsContent as FrameworkElement).FindChild("LinearizationPlot"); - selectedTab.MagentaPlot.DataPlotControl = (magentaChartsContent as FrameworkElement).FindChild("LABDataPlot"); - selectedTab.MagentaPlot.LinearizationPlotControl = (magentaChartsContent as FrameworkElement).FindChild("LinearizationPlot"); - selectedTab.YellowPlot.DataPlotControl = (yellowChartsContent as FrameworkElement).FindChild("LABDataPlot"); - selectedTab.YellowPlot.LinearizationPlotControl = (yellowChartsContent as FrameworkElement).FindChild("LinearizationPlot"); - selectedTab.BlackPlot.DataPlotControl = (blackChartsContent as FrameworkElement).FindChild("LABDataPlot"); - selectedTab.BlackPlot.LinearizationPlotControl = (blackChartsContent as FrameworkElement).FindChild("LinearizationPlot"); - + InitPlots(selectedTab); vm.IsViewLoaded = true; } } } + + private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + var listBox = (UIElement)sender; + if (listBox != null && ((ListBox)listBox).DataContext is ColorCalibrationViewVM) + { + ColorCalibrationViewVM vm = (ColorCalibrationViewVM)((ListBox)listBox).DataContext; + ColorCalibrationTabVM selectedTab = vm.SelectedTab; + InitPlots(selectedTab); + } + } + + private void InitPlots(ColorCalibrationTabVM selectedTab) + { + if (selectedTab != null && !selectedTab.IsTabLoaded) + { + if (null == (cyanChartsContent as FrameworkElement).FindChild("LABDataPlot")) + return; + selectedTab.CyanPlot.DataPlotControl = (cyanChartsContent as FrameworkElement).FindChild("LABDataPlot"); + selectedTab.CyanPlot.LinearizationPlotControl = (cyanChartsContent as FrameworkElement).FindChild("LinearizationPlot"); + selectedTab.MagentaPlot.DataPlotControl = (magentaChartsContent as FrameworkElement).FindChild("LABDataPlot"); + selectedTab.MagentaPlot.LinearizationPlotControl = (magentaChartsContent as FrameworkElement).FindChild("LinearizationPlot"); + selectedTab.YellowPlot.DataPlotControl = (yellowChartsContent as FrameworkElement).FindChild("LABDataPlot"); + selectedTab.YellowPlot.LinearizationPlotControl = (yellowChartsContent as FrameworkElement).FindChild("LinearizationPlot"); + selectedTab.BlackPlot.DataPlotControl = (blackChartsContent as FrameworkElement).FindChild("LABDataPlot"); + selectedTab.BlackPlot.LinearizationPlotControl = (blackChartsContent as FrameworkElement).FindChild("LinearizationPlot"); + + selectedTab.InitData(); + selectedTab.IsTabLoaded = true; + } + } } } diff --git a/Software/Visual_Studio/Tango.BL/Builders/RMLExtensionColorCalibrationBuilder.cs b/Software/Visual_Studio/Tango.BL/Builders/RMLExtensionColorCalibrationBuilder.cs new file mode 100644 index 000000000..17a3946b3 --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/Builders/RMLExtensionColorCalibrationBuilder.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using System.Data.Entity; + +namespace Tango.BL.Builders +{ + public class RMLExtensionColorCalibrationBuilder : EntityCollectionBuilderBase + { + public RMLExtensionColorCalibrationBuilder(ObservablesContext context) : base(context) + { + } + + public virtual RMLExtensionColorCalibrationBuilder ForRMLExtension(String rmlExtensionGUID) + { + return AddQueryStep(0, (query) => + { + if (rmlExtensionGUID != null) + { + return query.Where(x => x.RmlsExtensionsGuid == rmlExtensionGUID); + } + else + { + return query; + } + }); + } + public virtual RMLExtensionColorCalibrationBuilder ForMachine(String machineGUID) + { + return AddQueryStep(1, (query) => + { + if (machineGUID != null) + { + return query.Where(x => x.MachineGuid == machineGUID); + } + else + { + return query; + } + }); + } + public virtual RMLExtensionColorCalibrationBuilder WithTests() + { + return AddStep(2, () => + { + foreach (var result in Entities.ToList()) + { + var testsList = Context.RmlExtensionColorCalibrationsTests.Where(x => x.RmlExtensionColorCalibrationGuid == result.Guid).OrderBy(x => x.ID).ToList(); + foreach (var test in testsList) + { + var b = Context.RmlExtensionColorCalibrationsTestsLiquidData.Where(x => x.RmlExtensionColorCalibrationsTestGuid == test.Guid).Include(z=>z.LiquidType).Include(y => y.RmlExtensionColorCalibrationsTestsLiquidDataPoints).ToList(); + //RMLExtensionColorCalibrationTestsLiquidDataBuilder builder = new RMLExtensionColorCalibrationTestsLiquidDataBuilder(Context); + //builder.Set(test.Guid); + //var b = builder.ForRmlExtensionColorCalibrationsTest(test.Guid).WithPoints().Build(); + // test.RmlExtensionColorCalibrationsTestsLiquidData.Add(b); + } + } + }); + } + } +} diff --git a/Software/Visual_Studio/Tango.BL/Builders/RMLExtensionColorCalibrationTestsLiquidDataBuilder.cs b/Software/Visual_Studio/Tango.BL/Builders/RMLExtensionColorCalibrationTestsLiquidDataBuilder.cs new file mode 100644 index 000000000..cae435105 --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/Builders/RMLExtensionColorCalibrationTestsLiquidDataBuilder.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using System.Data.Entity; + +namespace Tango.BL.Builders +{ + public class RMLExtensionColorCalibrationTestsLiquidDataBuilder : EntityBuilderBase + { + public RMLExtensionColorCalibrationTestsLiquidDataBuilder(ObservablesContext context) : base(context) + { + } + protected override IQueryable OnSetQuery(IQueryable query) + { + return query.Include(x => x.LiquidType); + } + public virtual RMLExtensionColorCalibrationTestsLiquidDataBuilder ForRmlExtensionColorCalibrationsTest(String rmlExtensionColorCalibrationsTestGUID) + { + return AddQueryStep(0, (query) => + { + if (rmlExtensionColorCalibrationsTestGUID != null) + { + return query.Where(x => x.RmlExtensionColorCalibrationsTestGuid == rmlExtensionColorCalibrationsTestGUID); + } + else + { + return query; + } + }); + } + public virtual RMLExtensionColorCalibrationTestsLiquidDataBuilder WithPoints() + { + return AddStep(1, () => + { + Context.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Where(x => x.RmlExtensionColorCalibrationsTestsLiquidDataGuid == Entity.Guid).ToList(); + }); + } + } +} diff --git a/Software/Visual_Studio/Tango.BL/DTO/RmlExtensionColorCalibrationDTOBase.cs b/Software/Visual_Studio/Tango.BL/DTO/RmlExtensionColorCalibrationDTOBase.cs index fab576f25..f2ad42854 100644 --- a/Software/Visual_Studio/Tango.BL/DTO/RmlExtensionColorCalibrationDTOBase.cs +++ b/Software/Visual_Studio/Tango.BL/DTO/RmlExtensionColorCalibrationDTOBase.cs @@ -22,9 +22,9 @@ namespace Tango.BL.DTO { /// - /// rml extensions guid + /// rmls extensions guid /// - public String RmlExtensionsGuid + public String RmlsExtensionsGuid { get; set; } diff --git a/Software/Visual_Studio/Tango.BL/DTO/RmlExtensionColorShadeDTOBase.cs b/Software/Visual_Studio/Tango.BL/DTO/RmlExtensionColorShadeDTOBase.cs index f7fb8344a..50edfca30 100644 --- a/Software/Visual_Studio/Tango.BL/DTO/RmlExtensionColorShadeDTOBase.cs +++ b/Software/Visual_Studio/Tango.BL/DTO/RmlExtensionColorShadeDTOBase.cs @@ -22,9 +22,9 @@ namespace Tango.BL.DTO { /// - /// rml extensions guid + /// rmls extensions guid /// - public String RmlExtensionsGuid + public String RmlsExtensionsGuid { get; set; } diff --git a/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorCalibrationBase.cs b/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorCalibrationBase.cs index beb87f784..b858163d2 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorCalibrationBase.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorCalibrationBase.cs @@ -29,31 +29,31 @@ namespace Tango.BL.Entities public event EventHandler MachineChanged; - public event EventHandler RmlsExtensionChanged; + public event EventHandler RmlsExtensionsChanged; public event EventHandler> RmlExtensionColorCalibrationsTestsChanged; - protected String _rmlextensionsguid; + protected String _rmlsextensionsguid; /// - /// Gets or sets the rmlextensioncolorcalibrationbase rml extensions guid. + /// Gets or sets the rmlextensioncolorcalibrationbase rmls extensions guid. /// - [Column("RML_EXTENSIONS_GUID")] - [ForeignKey("RmlExtensions")] + [Column("RMLS_EXTENSIONS_GUID")] + [ForeignKey("RmlsExtensions")] - public String RmlExtensionsGuid + public String RmlsExtensionsGuid { get { - return _rmlextensionsguid; + return _rmlsextensionsguid; } set { - if (_rmlextensionsguid != value) + if (_rmlsextensionsguid != value) { - _rmlextensionsguid = value; + _rmlsextensionsguid = value; } } @@ -117,7 +117,7 @@ namespace Tango.BL.Entities } } - protected RmlsExtension _rmlsextension; + protected RmlsExtension _rmlsextensions; /// /// Gets or sets the rmlextensioncolorcalibrationbase rmls extensions. @@ -125,25 +125,25 @@ namespace Tango.BL.Entities [XmlIgnore] [JsonIgnore] - public virtual RmlsExtension RmlsExtension + public virtual RmlsExtension RmlsExtensions { get { - return _rmlsextension; + return _rmlsextensions; } set { - if (_rmlsextension != value) + if (_rmlsextensions != value) { - _rmlsextension = value; + _rmlsextensions = value; - if (RmlsExtension != null) + if (RmlsExtensions != null) { - RmlExtensionsGuid = RmlsExtension.Guid; + RmlsExtensionsGuid = RmlsExtensions.Guid; } - OnRmlsExtensionChanged(value); + OnRmlsExtensionsChanged(value); } } @@ -184,12 +184,12 @@ namespace Tango.BL.Entities } /// - /// Called when the RmlsExtension has changed. + /// Called when the RmlsExtensions has changed. /// - protected virtual void OnRmlsExtensionChanged(RmlsExtension rmlsextension) + protected virtual void OnRmlsExtensionsChanged(RmlsExtension rmlsextensions) { - RmlsExtensionChanged?.Invoke(this, rmlsextension); - RaisePropertyChanged(nameof(RmlsExtension)); + RmlsExtensionsChanged?.Invoke(this, rmlsextensions); + RaisePropertyChanged(nameof(RmlsExtensions)); } /// diff --git a/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorCalibrationsTestsLiquidData.cs b/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorCalibrationsTestsLiquidData.cs index 9cb724a2b..782a27963 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorCalibrationsTestsLiquidData.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorCalibrationsTestsLiquidData.cs @@ -8,9 +8,14 @@ // //------------------------------------------------------------------------------ +using Newtonsoft.Json; +using System.ComponentModel.DataAnnotations.Schema; +using Tango.BL.Enumerations; + namespace Tango.BL.Entities { public class RmlExtensionColorCalibrationsTestsLiquidData: RmlExtensionColorCalibrationsTestsLiquidDataBase { + } } \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorShadeBase.cs b/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorShadeBase.cs index 44e7fe521..b0386f13b 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorShadeBase.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorShadeBase.cs @@ -29,31 +29,31 @@ namespace Tango.BL.Entities public event EventHandler MachineChanged; - public event EventHandler RmlsExtensionChanged; + public event EventHandler RmlsExtensionsChanged; public event EventHandler> RmlExtensionColorShadesTestsChanged; - protected String _rmlextensionsguid; + protected String _rmlsextensionsguid; /// - /// Gets or sets the rmlextensioncolorshadebase rml extensions guid. + /// Gets or sets the rmlextensioncolorshadebase rmls extensions guid. /// - [Column("RML_EXTENSIONS_GUID")] - [ForeignKey("RmlExtensions")] + [Column("RMLS_EXTENSIONS_GUID")] + [ForeignKey("RmlsExtensions")] - public String RmlExtensionsGuid + public String RmlsExtensionsGuid { get { - return _rmlextensionsguid; + return _rmlsextensionsguid; } set { - if (_rmlextensionsguid != value) + if (_rmlsextensionsguid != value) { - _rmlextensionsguid = value; + _rmlsextensionsguid = value; } } @@ -117,7 +117,7 @@ namespace Tango.BL.Entities } } - protected RmlsExtension _rmlsextension; + protected RmlsExtension _rmlsextensions; /// /// Gets or sets the rmlextensioncolorshadebase rmls extensions. @@ -125,25 +125,25 @@ namespace Tango.BL.Entities [XmlIgnore] [JsonIgnore] - public virtual RmlsExtension RmlsExtension + public virtual RmlsExtension RmlsExtensions { get { - return _rmlsextension; + return _rmlsextensions; } set { - if (_rmlsextension != value) + if (_rmlsextensions != value) { - _rmlsextension = value; + _rmlsextensions = value; - if (RmlsExtension != null) + if (RmlsExtensions != null) { - RmlExtensionsGuid = RmlsExtension.Guid; + RmlsExtensionsGuid = RmlsExtensions.Guid; } - OnRmlsExtensionChanged(value); + OnRmlsExtensionsChanged(value); } } @@ -184,12 +184,12 @@ namespace Tango.BL.Entities } /// - /// Called when the RmlsExtension has changed. + /// Called when the RmlsExtensions has changed. /// - protected virtual void OnRmlsExtensionChanged(RmlsExtension rmlsextension) + protected virtual void OnRmlsExtensionsChanged(RmlsExtension rmlsextensions) { - RmlsExtensionChanged?.Invoke(this, rmlsextension); - RaisePropertyChanged(nameof(RmlsExtension)); + RmlsExtensionsChanged?.Invoke(this, rmlsextensions); + RaisePropertyChanged(nameof(RmlsExtensions)); } /// diff --git a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj index 4b6429b87..52dd7f68c 100644 --- a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj +++ b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj @@ -116,6 +116,8 @@ + + diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RML_EXTENSION_COLOR_CALIBRATIONS.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/RML_EXTENSION_COLOR_CALIBRATIONS.cs index f7aa3a9c4..7f25d41a2 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RML_EXTENSION_COLOR_CALIBRATIONS.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RML_EXTENSION_COLOR_CALIBRATIONS.cs @@ -23,7 +23,7 @@ namespace Tango.DAL.Remote.DB public int ID { get; set; } public string GUID { get; set; } public System.DateTime LAST_UPDATED { get; set; } - public string RML_EXTENSIONS_GUID { get; set; } + public string RMLS_EXTENSIONS_GUID { get; set; } public string MACHINE_GUID { get; set; } public virtual MACHINE MACHINE { get; set; } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RML_EXTENSION_COLOR_SHADES.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/RML_EXTENSION_COLOR_SHADES.cs index c662feb8f..55614d7a4 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RML_EXTENSION_COLOR_SHADES.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RML_EXTENSION_COLOR_SHADES.cs @@ -23,7 +23,7 @@ namespace Tango.DAL.Remote.DB public int ID { get; set; } public string GUID { get; set; } public System.DateTime LAST_UPDATED { get; set; } - public string RML_EXTENSIONS_GUID { get; set; } + public string RMLS_EXTENSIONS_GUID { get; set; } public string MACHINE_GUID { get; set; } public virtual MACHINE MACHINE { get; set; } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx index 17761bf6a..0619a2b9b 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx @@ -1100,7 +1100,7 @@ - + @@ -1143,7 +1143,7 @@ - + @@ -2649,7 +2649,7 @@ - + @@ -2659,7 +2659,7 @@ - + @@ -2743,7 +2743,7 @@ - + @@ -3748,7 +3748,7 @@ - + @@ -4494,7 +4494,7 @@ - + @@ -4727,7 +4727,7 @@ - + @@ -6238,10 +6238,10 @@ - + - + @@ -6290,7 +6290,7 @@ - + @@ -7883,7 +7883,7 @@ - + @@ -7893,7 +7893,7 @@ - + @@ -7949,7 +7949,7 @@ - + @@ -9558,7 +9558,7 @@ - + @@ -9605,7 +9605,7 @@ - + diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram index 61920906b..214d6c856 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram @@ -4,105 +4,105 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.3.1 From 981d893bcdd17e95f94859cb20cf413da6818df4 Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Sun, 16 Jan 2022 17:42:01 +0200 Subject: loading data from database --- .../Models/CalibrationPlotModel.cs | 4 +- .../ViewModels/ColorCalibrationTabVM.cs | 109 ++++++++++++++------- 2 files changed, 77 insertions(+), 36 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/CalibrationPlotModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/CalibrationPlotModel.cs index 0f844097d..49ca76d14 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/CalibrationPlotModel.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/CalibrationPlotModel.cs @@ -193,8 +193,8 @@ namespace Tango.MachineStudio.ThreadExtensions.Models LinearizationPoints.Add(new DataPoint(nw.Item1.InkPercentage, nw.Item2)); } - LinearizationMaxX = Math.Max(100, LinearizationPoints.Max(x => x.X)); - LinearizationMaxY = Math.Max(100, LinearizationPoints.Max(x => x.Y)); + LinearizationMaxX = Math.Max(100, LinearizationPoints.Count > 0? LinearizationPoints.Max(x => x.X) : 0); + LinearizationMaxY = Math.Max(100, LinearizationPoints.Count > 0 ? LinearizationPoints.Max(x => x.Y) : 0); if (LinearizationPlotControl != null) { diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationTabVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationTabVM.cs index 2727b44e5..0a27281ca 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationTabVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationTabVM.cs @@ -138,34 +138,60 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels } #region Methods - private void ImportCyanData(object obj) + private async void ImportCyanData(object obj) { List items; if (ImportDataFromFile(out items) && items.Count > 0) { - CreatePlots(PMR.ColorLab.LiquidType.Cyan, CyanPlot, items, CyanCalibrationData); + List calibrationPoints = new List(); + await Task.Factory.StartNew(() => + { + calibrationPoints = GetLinearizationMeasurements(items, PMR.ColorLab.LiquidType.Cyan); + }); + UpdatePlots(CyanPlot, items, calibrationPoints); + + CyanCalibrationData.CalibrationPoints.Clear(); + var index = 1; + foreach (var nw in items.Zip(calibrationPoints, Tuple.Create)) + { + CyanCalibrationData.CalibrationPoints.Add(new CalibrationDataPointVM() { Index = index++, X = nw.Item1.InkPercentage, Y = nw.Item2 }); + } + SynchronizedObservableCollection data = RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData; var liquidtype = _liquids.Where(l => l.Type == LiquidTypes.Cyan).FirstOrDefault(); var cyanliquidData = RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData.Where(x => x.LiquidTypeGuid == liquidtype.Guid).FirstOrDefault(); - if(cyanliquidData != null) + if (cyanliquidData != null) { - if(!RemovedPoints.ContainsKey(LiquidTypes.Cyan)) + if (!RemovedPoints.ContainsKey(LiquidTypes.Cyan)) { RemovedPoints[LiquidTypes.Cyan] = new List(cyanliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.ToList()); } cyanliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Clear(); - items.ForEach(x => cyanliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Add(new RmlExtensionColorCalibrationsTestsLiquidDataPoint() { Ink = x.InkPercentage, L = x.L, A = x.A, B = x.B, CalculatedPoint = CyanCalibrationData.CalibrationPoints.Where(y=> y.X == x.InkPercentage).Select(z=>z.Y ).FirstOrDefault()})); + items.ForEach(x => cyanliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Add(new RmlExtensionColorCalibrationsTestsLiquidDataPoint() { Ink = x.InkPercentage, L = x.L, A = x.A, B = x.B, CalculatedPoint = CyanCalibrationData.CalibrationPoints.Where(y => y.X == x.InkPercentage).Select(z => z.Y).FirstOrDefault() })); } } } - private void ImportMagentaData(object obj) + private async void ImportMagentaData(object obj) { List items; if (ImportDataFromFile(out items) && items.Count > 0) { - CreatePlots(PMR.ColorLab.LiquidType.Magenta, MagentaPlot, items, MagentaCalibrationData); + List calibrationPoints = new List(); + await Task.Factory.StartNew(() => + { + calibrationPoints = GetLinearizationMeasurements(items, PMR.ColorLab.LiquidType.Magenta); + }); + UpdatePlots(MagentaPlot, items, calibrationPoints); + + MagentaCalibrationData.CalibrationPoints.Clear(); + var index = 1; + foreach (var nw in items.Zip(calibrationPoints, Tuple.Create)) + { + MagentaCalibrationData.CalibrationPoints.Add(new CalibrationDataPointVM() { Index = index++, X = nw.Item1.InkPercentage, Y = nw.Item2 }); + } + SynchronizedObservableCollection data = RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData; var liquidtype = _liquids.Where(l => l.Type == LiquidTypes.Magenta).FirstOrDefault(); var magentaliquidData = RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData.Where(x => x.LiquidTypeGuid == liquidtype.Guid).FirstOrDefault(); @@ -176,17 +202,30 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels RemovedPoints[LiquidTypes.Magenta] = new List(magentaliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.ToList()); } magentaliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Clear(); - items.ForEach(x => magentaliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Add(new RmlExtensionColorCalibrationsTestsLiquidDataPoint() { Ink = x.InkPercentage, L = x.L, A = x.A, B = x.B, CalculatedPoint = CyanCalibrationData.CalibrationPoints.Where(y => y.X == x.InkPercentage).Select(z => z.Y).FirstOrDefault() })); + items.ForEach(x => magentaliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Add(new RmlExtensionColorCalibrationsTestsLiquidDataPoint() { Ink = x.InkPercentage, L = x.L, A = x.A, B = x.B, CalculatedPoint = MagentaCalibrationData.CalibrationPoints.Where(y => y.X == x.InkPercentage).Select(z => z.Y).FirstOrDefault() })); } } } - private void ImportYellowData(object obj) + private async void ImportYellowData(object obj) { List items; if (ImportDataFromFile(out items) && items.Count > 0) { - CreatePlots(PMR.ColorLab.LiquidType.Yellow, YellowPlot, items, YellowCalibrationData); + List calibrationPoints = new List(); + await Task.Factory.StartNew(() => + { + calibrationPoints = GetLinearizationMeasurements(items, PMR.ColorLab.LiquidType.Yellow); + }); + UpdatePlots(YellowPlot, items, calibrationPoints); + + YellowCalibrationData.CalibrationPoints.Clear(); + var index = 1; + foreach (var nw in items.Zip(calibrationPoints, Tuple.Create)) + { + YellowCalibrationData.CalibrationPoints.Add(new CalibrationDataPointVM() { Index = index++, X = nw.Item1.InkPercentage, Y = nw.Item2 }); + } + SynchronizedObservableCollection data = RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData; var liquidtype = _liquids.Where(l => l.Type == LiquidTypes.Yellow).FirstOrDefault(); var yellowliquidData = RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData.Where(x => x.LiquidTypeGuid == liquidtype.Guid).FirstOrDefault(); @@ -197,18 +236,30 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels RemovedPoints[LiquidTypes.Yellow] = new List(yellowliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.ToList()); } yellowliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Clear(); - items.ForEach(x => yellowliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Add(new RmlExtensionColorCalibrationsTestsLiquidDataPoint() { Ink = x.InkPercentage, L = x.L, A = x.A, B = x.B, CalculatedPoint = CyanCalibrationData.CalibrationPoints.Where(y => y.X == x.InkPercentage).Select(z => z.Y).FirstOrDefault() })); + items.ForEach(x => yellowliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Add(new RmlExtensionColorCalibrationsTestsLiquidDataPoint() { Ink = x.InkPercentage, L = x.L, A = x.A, B = x.B, CalculatedPoint = YellowCalibrationData.CalibrationPoints.Where(y => y.X == x.InkPercentage).Select(z => z.Y).FirstOrDefault() })); } } } - private void ImportBlackData(object obj) + private async void ImportBlackData(object obj) { - List items; if (ImportDataFromFile(out items) && items.Count > 0) { - CreatePlots(PMR.ColorLab.LiquidType.Black, BlackPlot, items, BlackCalibrationData); + List calibrationPoints = new List(); + await Task.Factory.StartNew(() => + { + calibrationPoints = GetLinearizationMeasurements(items, PMR.ColorLab.LiquidType.Black); + }); + UpdatePlots(BlackPlot, items, calibrationPoints); + + BlackCalibrationData.CalibrationPoints.Clear(); + var index = 1; + foreach (var nw in items.Zip(calibrationPoints, Tuple.Create)) + { + BlackCalibrationData.CalibrationPoints.Add(new CalibrationDataPointVM() { Index = index++, X = nw.Item1.InkPercentage, Y = nw.Item2 }); + } + SynchronizedObservableCollection data = RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData; var liquidtype = _liquids.Where(l => l.Type == LiquidTypes.Black).FirstOrDefault(); var blackliquidData = RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData.Where(x => x.LiquidTypeGuid == liquidtype.Guid).FirstOrDefault(); @@ -219,7 +270,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels RemovedPoints[LiquidTypes.Black] = new List(blackliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.ToList()); } blackliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Clear(); - items.ForEach(x => blackliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Add(new RmlExtensionColorCalibrationsTestsLiquidDataPoint() { Ink = x.InkPercentage, L = x.L, A = x.A, B = x.B, CalculatedPoint = CyanCalibrationData.CalibrationPoints.Where(y => y.X == x.InkPercentage).Select(z => z.Y).FirstOrDefault() })); + items.ForEach(x => blackliquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.Add(new RmlExtensionColorCalibrationsTestsLiquidDataPoint() { Ink = x.InkPercentage, L = x.L, A = x.A, B = x.B, CalculatedPoint = BlackCalibrationData.CalibrationPoints.Where(y => y.X == x.InkPercentage).Select(z => z.Y).FirstOrDefault() })); } } @@ -322,36 +373,26 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels return PMR.ColorLab.LiquidType.Black; } - private async void CreatePlots(PMR.ColorLab.LiquidType liquidtype, CalibrationPlotModel plot, List items, CalibrationDataVM calibrationTable) + private void UpdatePlots( CalibrationPlotModel plot, List items, List calibrationPoints) { plot.InitDataGraph(items); - - List outputPoints = new List(); - - await Task.Factory.StartNew(() => - { - outputPoints = GetLinearizationMeasurements(items, liquidtype); - }); - - plot.InitLinearizationGraph(items, outputPoints); - calibrationTable.CalibrationPoints.Clear(); - var index = 1; - foreach (var nw in items.Zip(outputPoints, Tuple.Create)) - { - calibrationTable.CalibrationPoints.Add(new CalibrationDataPointVM() { Index = index++, X = nw.Item1.InkPercentage, Y = nw.Item2 }); - } + plot.InitLinearizationGraph(items, calibrationPoints); } private void LoadDataPlots( List points, CalibrationPlotModel plot, CalibrationDataVM calibrationTable) { List items = new List(); points.ForEach(x => items.Add(new ColorLinearizationModel.LinearizationDataItem() { InkPercentage = x.Ink, L = x.L, A = x.A, B = x.B })); - plot.InitDataGraph(items); + + List calibrationPoints = new List(); calibrationTable.CalibrationPoints.Clear(); var index = 1; - points.ForEach(x => calibrationTable.CalibrationPoints.Add(new CalibrationDataPointVM() { Index = index++, X = x.Ink, Y = x.CalculatedPoint })); - + points.ForEach(x => { + calibrationTable.CalibrationPoints.Add(new CalibrationDataPointVM() { Index = index++, X = x.Ink, Y = x.CalculatedPoint }); + calibrationPoints.Add(x.CalculatedPoint); + }); + UpdatePlots(plot, items, calibrationPoints); } private void OnRmlExtensionColorCalibrationsTestChanged() -- cgit v1.3.1 From afdaadac0ddb76b5e905ef5eeda581ade4324f9b Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Wed, 19 Jan 2022 16:00:37 +0200 Subject: #5831 RML extension- Color shade window --- .../Models/ColorShadesModel.cs | 42 +++ .../Tango.MachineStudio.ThreadExtensions.csproj | 10 + .../ViewModels/ColorCalibrationTabVM.cs | 12 - .../ViewModels/ColorShadeTabVM.cs | 121 ++++++ .../ViewModels/ColorShadeViewVM.cs | 406 +++++++++++++++++++++ .../ViewModels/MainViewVM.cs | 22 +- .../Views/ColorShadeView.xaml | 162 ++++++++ .../Views/ColorShadeView.xaml.cs | 28 ++ .../Resources/ColorShadesTemplate.xlsx | Bin 0 -> 10366 bytes .../Builders/RMLExtensionColorShadeBuilder.cs | 61 ++++ .../Tango.BL/Calibration/CalibrationHelper.cs | 11 + .../Tango.BL/Calibration/ColorShadesTemplate.xlsx | Bin 0 -> 10366 bytes .../Entities/RmlExtensionColorShadesTestsData.cs | 22 ++ Software/Visual_Studio/Tango.BL/Tango.BL.csproj | 4 +- 14 files changed, 887 insertions(+), 14 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ColorShadesModel.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeTabVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorShadeView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorShadeView.xaml.cs create mode 100644 Software/Visual_Studio/Resources/ColorShadesTemplate.xlsx create mode 100644 Software/Visual_Studio/Tango.BL/Builders/RMLExtensionColorShadeBuilder.cs create mode 100644 Software/Visual_Studio/Tango.BL/Calibration/ColorShadesTemplate.xlsx (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ColorShadesModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ColorShadesModel.cs new file mode 100644 index 000000000..cc4351891 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ColorShadesModel.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Documents; + +namespace Tango.MachineStudio.ThreadExtensions.Models +{ + public class ColorShadesModel + { + public class ColorShadesDataItem + { + public double ColorNumber { get; set; } + public double L { get; set; } + public double A { get; set; } + public double B { get; set; } + public double C { get; set; } + public double M { get; set; } + public double Y { get; set; } + public double L2 { get; set; } + public double A2 { get; set; } + public double B2 { get; set; } + } + + public void GetDataFromFile(string fileName, out List items, ref string errors) + { + items = null; + try + { + using (ExcelReader reader = new ExcelReader(fileName)) + { + items = reader.GetDataByIndex("Sheet1", 2); + } + } + catch (Exception ex) + { + errors = ex.Message; + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj index 4af5d899b..065dec29e 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj @@ -99,6 +99,7 @@ + @@ -111,6 +112,7 @@ + @@ -123,6 +125,10 @@ ColorParametersView.xaml + + ColorShadeView.xaml + + ComboboxEditable.xaml @@ -161,6 +167,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationTabVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationTabVM.cs index 0a27281ca..a2a119e29 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationTabVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationTabVM.cs @@ -314,18 +314,6 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels var points = liquidData.RmlExtensionColorCalibrationsTestsLiquidDataPoints.OrderBy(y => y.Ink).ToList(); LoadDataPlots(points, GetPlot(liquidType), GetCalibrationDataVM(liquidType)); - //if (points.Count > 0) - //{ - // List items = new List(); - // points.ForEach(x => items.Add(new ColorLinearizationModel.LinearizationDataItem() { InkPercentage = x.Ink, L = x.L, A = x.A, B = x.B })); - // items.OrderBy(y => y.InkPercentage).ToList(); - // var index = 1; - // List calibrationPoints = new List(); - // points.ForEach(x => calibrationPoints.Add(new CalibrationDataPointVM() { Index = index++, X = x.Ink, Y = x.CalculatedPoint })); - - - // CreatePlots(ConvertLiquidTypeToPMR(liquidType), GetPlot(liquidType), items, GetCalibrationDataVM(liquidType)); - //} } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeTabVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeTabVM.cs new file mode 100644 index 000000000..df0ba521c --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeTabVM.cs @@ -0,0 +1,121 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.SharedUI; +using Tango.MachineStudio.ThreadExtensions.Models; +using Tango.BL.Enumerations; +using Tango.Core.Commands; +using Microsoft.Win32; +using Tango.MachineStudio.Common.Notifications; +using Tango.BL.ActionLogs; +using Tango.BL.Entities; +using Tango.Core; + +namespace Tango.MachineStudio.ThreadExtensions.ViewModels +{ + public class ColorShadeTabVM : ViewModel + { + private INotificationProvider _notification; + private IActionLogManager _actionLogManager; + + #region Properties + + private string _name; + /// + /// Gets or sets the name of the thread. Using in print + /// + public string Name + { + get { return _name; } + set + { + _name = value; + if (RmlExtensionColorShadesTest != null) + RmlExtensionColorShadesTest.Name = _name; + RaisePropertyChangedAuto(); + } + } + + private int _tabIndex; + + public int TabIndex + { + get { return _tabIndex; } + set + { + _tabIndex = value; + RaisePropertyChangedAuto(); + } + } + + + private bool _isSelected; + /// + /// Gets or sets a value indicating whether this instance is selected. + /// + public bool IsSelected + { + get { return _isSelected; } + set { _isSelected = value; RaisePropertyChangedAuto(); } + } + + private RmlExtensionColorShadesTest _rmlExtensionColorShadesTest; + + public RmlExtensionColorShadesTest RmlExtensionColorShadesTest + { + get { return _rmlExtensionColorShadesTest; } + set + { + _rmlExtensionColorShadesTest = value; + RaisePropertyChangedAuto(); + } + } + + /// + /// Gets or sets last points before save. Used in Save to remove points before save new. + /// + /// + /// The removed points. + /// + public List RemovedDataList { get; set; } + + #endregion + + RelayCommand ImportColorsCommand { get; set; } + + public ColorShadeTabVM(INotificationProvider notification, IActionLogManager actionLogManager) + { + _notification = notification; + _actionLogManager = actionLogManager; + ImportColorsCommand = new RelayCommand(ImportColors); + } + + private void ImportColors(object obj) + { + List items; + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Title = "Select data file"; + dlg.Filter = "Excel |*.xlsx"; + items = null; + if (dlg.ShowDialogCenter() && dlg.FileName.IsNotNullOrEmpty()) + { + ColorShadesModel model = new ColorShadesModel(); + string errors = ""; + model.GetDataFromFile(dlg.FileName, out items, ref errors); + if (false == String.IsNullOrEmpty(errors) || items == null || items.Count == 0) + { + _notification.ShowError("An error occurred while trying to import data form the selected excel file. Please check the file format if valid and is available to read."); + + } + else + { + //Settings data to object + } + + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeViewVM.cs new file mode 100644 index 000000000..b1dac5ce9 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeViewVM.cs @@ -0,0 +1,406 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.ActionLogs; +using Tango.BL.Builders; +using Tango.BL.Entities; +using Tango.Core; +using Tango.MachineStudio.Common.Notifications; +using Tango.SharedUI; +using Tango.AutoComplete.Editors; +using Tango.MachineStudio.ThreadExtensions.Models; +using Tango.Core.Commands; +using Microsoft.Win32; +using Tango.Logging; +using Tango.MachineStudio.ThreadExtensions.ViewModels; +using System.Collections.ObjectModel; +using Tango.BL.Calibration; + +namespace Tango.MachineStudio.ThreadExtensions.ViewModels +{ + public class ColorShadeViewVM : ViewModel + { + private INotificationProvider _notification; + private IActionLogManager _actionLogManager; + + private ObservablesContext _active_context; + public event EventHandler SaveColorShadesEvent; + + #region Properties + + + private RmlExtensionColorShade _colorShade; + + public RmlExtensionColorShade RmlExtensionColorShade + { + get { return _colorShade; } + set { _colorShade = value; + RaisePropertyChangedAuto(); + } + } + + private ObservableCollection _colorShadeTabs; + + public ObservableCollection ColorShadeTabs + { + get { return _colorShadeTabs; } + set { _colorShadeTabs = value; } + } + + private ColorShadeTabVM _selectedTab; + + public ColorShadeTabVM SelectedTab + { + get { return _selectedTab; } + set + { + _selectedTab = value; + RaisePropertyChangedAuto(); + + foreach (var tab in _colorShadeTabs.Where(x => x != _selectedTab)) + { + tab.IsSelected = false; + } + + if (_selectedTab != null) + { + _selectedTab.IsSelected = true; + } + } + } + + private string _RMLExtentionGUID; + + public string RMLExtentionGUID + { + get { return _RMLExtentionGUID; } + set + { + _RMLExtentionGUID = value; + } + } + + private string _RMLGUID; + + public string RMLGUID + { + get { return _RMLGUID; } + set + { + _RMLGUID = value; + } + } + + protected string _selectedMachineGuid; + /// + /// Gets or sets the selected machine. + /// + public String SelectedMachineGUID + { + get { return _selectedMachineGuid; } + set + { + if (value != null && _selectedMachineGuid != value) + { + _selectedMachineGuid = value; + SelectedMachineChanged(); + RaisePropertyChangedAuto(); + InvalidateRelayCommands(); + } + } + } + + + private bool _isViewLoaded; + /// + /// Gets or sets a value indicating whether this instance is view loaded. Used to update charts. + /// + public bool IsViewLoaded + { + get { return _isViewLoaded; } + set + { + if (_isViewLoaded != value) + { + _isViewLoaded = value; + } + } + } + + #endregion + + #region commands + public RelayCommand CreateColorDataImportExcelTemplateCommand { get; set; } + + public RelayCommand SaveCommand { get; set; } + + public RelayCommand AddTabCommand { get; set; } + + public RelayCommand RemoveTabCommand { get; set; } + + public RelayCommand RenameTabCommand { get; set; } + + #endregion + + public ColorShadeViewVM(INotificationProvider notification, IActionLogManager actionLogManager) + { + _notification = notification; + _actionLogManager = actionLogManager; + ColorShadeTabs = new ObservableCollection(); + + SaveCommand = new RelayCommand(Save, () => IsFree); + + AddTabCommand = new RelayCommand(() => AddNewTab()); + RemoveTabCommand = new RelayCommand(RemoveTab); + RenameTabCommand = new RelayCommand(RenameTab); + + CreateColorDataImportExcelTemplateCommand = new RelayCommand(CreateColorDataImportExcelTemplate); + } + + #region Loading + public async void LoadColorShades() + { + if (SelectedMachineGUID == null) + { + _notification.ShowWarning(LogManager.Log($"Please, select machine.", LogCategory.Warning)); + IsFree = false; + return; + } + if (RMLGUID == null) + { + IsFree = false; + return; + } + try + { + IsFree = false; + if (_active_context != null) + { + _active_context.Dispose(); + } + + _active_context = ObservablesContext.CreateDefault(); + + ColorShadeTabs.Clear(); + LogManager.Log("Loading color shade view ..."); + using (_notification.PushTaskItem("Loading Color Shade View ...")) + { + var testResults = await new RMLExtensionColorShadeBuilder(_active_context).SetAll().ForRMLExtension(RMLExtentionGUID).ForMachine(SelectedMachineGUID).WithTests().BuildAsync(); + RmlExtensionColorShade = testResults.OrderBy(x => x.ID).ToList().FirstOrDefault(); + if (RmlExtensionColorShade == null) + { + RmlExtensionColorShade = new RmlExtensionColorShade() { RmlsExtensionsGuid = RMLExtentionGUID, MachineGuid = SelectedMachineGUID }; + _active_context.RmlExtensionColorShades.Add(RmlExtensionColorShade); + _active_context.SaveChanges(); + } + + foreach (var test in RmlExtensionColorShade.RmlExtensionColorShadesTests) + { + ColorShadeTabs.Add(new ColorShadeTabVM(_notification, _actionLogManager) { RmlExtensionColorShadesTest = test, Name = test.Name }); + if (ColorShadeTabs.Count == 1) + SelectedTab = ColorShadeTabs[0]; + } + if (ColorShadeTabs.Count == 0) + { + SelectedTab = CreateNewColorShadeTabVM("Untitled", 1); + ColorShadeTabs.Add(SelectedTab); + _active_context.SaveChanges(); + } + if (IsViewLoaded) + { + // ColorShadeTabs.ToList().ForEach(x => x.InitData()); + } + } + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error loading Color Calibration tests.\n{ex.FlattenMessage()}"); + } + finally + { + IsFree = true; + } + } + + private ColorShadeTabVM CreateNewColorShadeTabVM(string name, int index) + { + ColorShadeTabVM newtab = new ColorShadeTabVM(_notification, _actionLogManager) { Name = name, TabIndex = index }; + + newtab.RmlExtensionColorShadesTest = new RmlExtensionColorShadesTest() + { + RmlExtensionColorShadesGuid = RMLExtentionGUID, + Name = name + }; + if (RmlExtensionColorShade != null) + { + RmlExtensionColorShade.RmlExtensionColorShadesTests.Add(newtab.RmlExtensionColorShadesTest); + } + + return newtab; + } + #endregion + + #region Methods + + private void OnRMLExtensionGUIDChanged() + { + } + + private void SelectedMachineChanged() + { + SelectedTab = null; + LoadColorShades(); + } + + private void CreateColorDataImportExcelTemplate() + { + SaveFileDialog dlg = new SaveFileDialog(); + try + { + dlg.Title = $"Create excel template file"; + dlg.Filter = "Excel Files|*.xlsx"; + dlg.DefaultExt = ".xlsx"; + dlg.FileName = "Color Shades File Template"; + if (dlg.ShowDialog().Value) + { + CalibrationHelper.CreateColorShadesInputExcelTemplate(dlg.FileName); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error generating excel color shades template file " + dlg.FileName); + _notification.ShowError("An error occurred while trying to generate the color shades file."); + } + } + + #endregion + + #region Tabs modification + + /// + /// Removes the specified tab. + /// + /// The tab. + private void RemoveTab(ColorShadeTabVM tab) + { + if (ColorShadeTabs.Count == 1) + return; + if (_notification.ShowQuestion("Are you sure you want to delete the selected tab?")) + { + _active_context.RmlExtensionColorShadesTestsData.RemoveRange(tab.RmlExtensionColorShadesTest.RmlExtensionColorShadesTestsData.ToList()); + + //_active_context.RmlExtensionColorCalibrationsTestsLiquidData.RemoveRange(tab.RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData); + tab.RmlExtensionColorShadesTest.RmlExtensionColorShadesTestsData = null; + + RmlExtensionColorShade.RmlExtensionColorShadesTests.Remove(tab.RmlExtensionColorShadesTest); + _active_context.RmlExtensionColorShadesTests.Remove(tab.RmlExtensionColorShadesTest); + + ColorShadeTabs.Remove(tab); + SelectedTab = ColorShadeTabs.LastOrDefault(); + _active_context.SaveChanges(); + } + } + + /// + /// Adds a new tab. + /// + private bool AddNewTab(String name = null) + { + if (ColorShadeTabs.Count > 7) + { + //_notification.ShowError("Cannot exceed the maximum number of 8 tabs. You can remove a tab, or create a new project."); + return false; + } + + if (name == null) + { + name = _notification.ShowTextInput("Enter tab name", "Tab Name", "Test"); + } + + if (!String.IsNullOrWhiteSpace(name)) + { + var tab = CreateNewColorShadeTabVM(name, (ColorShadeTabs.Count + 1)); + _active_context.SaveChanges(); + ColorShadeTabs.Add(tab); + SelectedTab = tab; + return true; + } + else + { + return false; + } + } + + /// + /// Renames the tab. + /// + /// The tab. + private void RenameTab() + { + if (SelectedTab != null) + { + var name = _notification.ShowTextInput("Enter tab name", "Tab Name", SelectedTab.Name); + + if (!String.IsNullOrWhiteSpace(name)) + { + SelectedTab.Name = name; + } + } + } + + #endregion + + #region Save + + public async void Save() + { + if (SelectedMachineGUID == null) + { + _notification.ShowWarning(LogManager.Log($"Could not save Color Shades. Please, select machine before save.", LogCategory.Warning)); + return; + } + + try + { + IsFree = false; + DateTime lastUpdated = DateTime.UtcNow; + RmlExtensionColorShade.LastUpdated = lastUpdated; + + foreach (var tab in ColorShadeTabs) + { + tab.RmlExtensionColorShadesTest.LastUpdated = lastUpdated; + //var removedPoints = tab.RemovedPoints; + //foreach (var liquidData in tab.RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData) + //{ + // var liquidtype = _liquids.Where(l => l.Guid == liquidData.LiquidTypeGuid).FirstOrDefault(); + // if (liquidtype != null && removedPoints.ContainsKey(liquidtype.Type)) + // { + // _active_context.RmlExtensionColorCalibrationsTestsLiquidDataPoints.RemoveRange(removedPoints[liquidtype.Type]); + // } + // liquidData.LastUpdated = lastUpdated; + //} + //tab.RemovedPoints.Clear(); + } + await _active_context.SaveChangesAsync(); + + // LoadColorParameters(); + } + catch (Exception ex) + { + LogManager.Log(ex, "Could not update color shades."); + _notification.ShowError($"An error occurred while trying to save color shades.\n{ex.Message}"); + } + finally + { + IsFree = true; + EventHandler handler = SaveColorShadesEvent; + handler?.Invoke(this, new EventArgs()); + } + } + + #endregion + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs index 1cc6e1dcc..47965deb4 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs @@ -264,6 +264,14 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels set { _colorCalibrationViewVM = value; RaisePropertyChangedAuto(); } } + private ColorShadeViewVM _solorShadeViewVM; + public ColorShadeViewVM ColorShadeViewVM + { + get { return _solorShadeViewVM; } + set { _solorShadeViewVM = value; RaisePropertyChangedAuto(); } + } + + protected MachineModel _selectedMachine; /// /// Gets or sets the selected machine. @@ -1051,7 +1059,12 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels ColorCalibrationViewVM.ActiveRML = ActiveRML; ColorCalibrationViewVM.RMLGUID = ActiveRML.Guid; ColorCalibrationViewVM.Machine = SelectedMachine; - + + ColorShadeViewVM = new ColorShadeViewVM(_notification, _actionLogManager); + ColorShadeViewVM.RMLExtentionGUID = guid; + ColorShadeViewVM.RMLGUID = ActiveRML.Guid; + ColorShadeViewVM.SelectedMachineGUID = SelectedMachine != null ? SelectedMachine.Guid : null; ; + if (ActiveRMLExtension.RMLStatus == RMLExtensionStatus.New) { ColorParametersVewVM.SaveColorParameters -= UpdateStatus; @@ -1060,6 +1073,8 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels TestResultsViewVM.SaveTestResults += UpdateStatus; ColorCalibrationViewVM.SaveColorCalibration -= UpdateStatus; ColorCalibrationViewVM.SaveColorCalibration += UpdateStatus; + ColorShadeViewVM.SaveColorShadesEvent -= UpdateStatus; + ColorShadeViewVM.SaveColorShadesEvent += UpdateStatus; } View.NavigateTo(RMLExtensionNavigationView.RMLExtentionView); @@ -1123,6 +1138,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels ColorParametersVewVM.SaveColorParameters -= UpdateStatus; TestResultsViewVM.SaveTestResults -= UpdateStatus; ColorCalibrationViewVM.SaveColorCalibration -= UpdateStatus; + ColorShadeViewVM.SaveColorShadesEvent -= UpdateStatus; ActiveRMLExtension.RMLStatus = RMLExtensionStatus.InProgress; ActiveRMLExtension.LastUpdated = DateTime.UtcNow; @@ -1153,6 +1169,10 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels { ColorCalibrationViewVM.Machine = SelectedMachine; } + if(ColorShadeViewVM != null) + { + ColorShadeViewVM.SelectedMachineGUID = SelectedMachine.Guid; + } } #endregion diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorShadeView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorShadeView.xaml new file mode 100644 index 000000000..70df4d6bf --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorShadeView.xaml @@ -0,0 +1,162 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorShadeView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorShadeView.xaml.cs new file mode 100644 index 000000000..2a8079cfe --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorShadeView.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.MachineStudio.ThreadExtensions.Views +{ + /// + /// Interaction logic for ColorShadeView.xaml + /// + public partial class ColorShadeView : UserControl + { + public ColorShadeView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/Resources/ColorShadesTemplate.xlsx b/Software/Visual_Studio/Resources/ColorShadesTemplate.xlsx new file mode 100644 index 000000000..cf98c2b1b Binary files /dev/null and b/Software/Visual_Studio/Resources/ColorShadesTemplate.xlsx differ diff --git a/Software/Visual_Studio/Tango.BL/Builders/RMLExtensionColorShadeBuilder.cs b/Software/Visual_Studio/Tango.BL/Builders/RMLExtensionColorShadeBuilder.cs new file mode 100644 index 000000000..0f1894b4a --- /dev/null +++ b/Software/Visual_Studio/Tango.BL/Builders/RMLExtensionColorShadeBuilder.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using System.Data.Entity; + +namespace Tango.BL.Builders +{ + public class RMLExtensionColorShadeBuilder : EntityCollectionBuilderBase + { + public RMLExtensionColorShadeBuilder(ObservablesContext context) : base(context) + { + } + + public virtual RMLExtensionColorShadeBuilder ForRMLExtension(String rmlExtensionGUID) + { + return AddQueryStep(0, (query) => + { + if (rmlExtensionGUID != null) + { + return query.Where(x => x.RmlsExtensionsGuid == rmlExtensionGUID); + } + else + { + return query; + } + }); + } + public virtual RMLExtensionColorShadeBuilder ForMachine(String machineGUID) + { + return AddQueryStep(1, (query) => + { + if (machineGUID != null) + { + return query.Where(x => x.MachineGuid == machineGUID); + } + else + { + return query; + } + }); + } + public virtual RMLExtensionColorShadeBuilder WithTests() + { + return AddStep(2, () => + { + foreach (var result in Entities.ToList()) + { + var testsList = Context.RmlExtensionColorShadesTests.Where(x => x.RmlExtensionColorShadesGuid == result.Guid).Include(y => y.RmlExtensionColorShadesTestsData).OrderBy(z => z.ID).ToList(); + + //foreach (var test in testsList) + //{ + // var b = Context.RmlExtensionColorShadesTestsData.Where(x => x.RmlExtensionColorShadesTestsGuid == test.Guid).ToList(); + //} + } + }); + } + } +} diff --git a/Software/Visual_Studio/Tango.BL/Calibration/CalibrationHelper.cs b/Software/Visual_Studio/Tango.BL/Calibration/CalibrationHelper.cs index b75a9751d..ced98dbff 100644 --- a/Software/Visual_Studio/Tango.BL/Calibration/CalibrationHelper.cs +++ b/Software/Visual_Studio/Tango.BL/Calibration/CalibrationHelper.cs @@ -72,5 +72,16 @@ namespace Tango.BL.Calibration stream.CopyTo(fs); } } + + public static void CreateColorShadesInputExcelTemplate(String fileName) + { + var stream = EmbeddedResourceHelper.GetEmbeddedResourceStream("Tango.BL.Calibration.ColorShadesTemplate.xlsx"); + + using (FileStream fs = new FileStream(fileName, FileMode.Create)) + { + stream.Seek(0, SeekOrigin.Begin); + stream.CopyTo(fs); + } + } } } diff --git a/Software/Visual_Studio/Tango.BL/Calibration/ColorShadesTemplate.xlsx b/Software/Visual_Studio/Tango.BL/Calibration/ColorShadesTemplate.xlsx new file mode 100644 index 000000000..cf98c2b1b Binary files /dev/null and b/Software/Visual_Studio/Tango.BL/Calibration/ColorShadesTemplate.xlsx differ diff --git a/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorShadesTestsData.cs b/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorShadesTestsData.cs index 3d9c77b11..ac2c44f15 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorShadesTestsData.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorShadesTestsData.cs @@ -7,10 +7,32 @@ // the code is regenerated. Do not modify! // //------------------------------------------------------------------------------ +using ColorMine.ColorSpaces; +using Newtonsoft.Json; +using System.Windows.Media; +using System.ComponentModel.DataAnnotations.Schema; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; namespace Tango.BL.Entities { public class RmlExtensionColorShadesTestsData : RmlExtensionColorShadesTestsDataBase { + public RmlExtensionColorShadesTestsData() : base() + { + } + + + [NotMapped] + [JsonIgnore] + public SolidColorBrush ColorBrush + { + get { + Lab lab = new Lab(L, A, B); + Rgb rgb = (Rgb)lab.ToRgb(); + return new SolidColorBrush(Color.FromRgb((byte)rgb.R, (byte)rgb.G, (byte)rgb.B)); + } + } } } \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj index e76aff050..bcc6e303e 100644 --- a/Software/Visual_Studio/Tango.BL/Tango.BL.csproj +++ b/Software/Visual_Studio/Tango.BL/Tango.BL.csproj @@ -117,6 +117,7 @@ + @@ -736,6 +737,7 @@ Designer + Designer @@ -801,7 +803,7 @@ - + \ No newline at end of file -- cgit v1.3.1 From 7baca4061db66b1c5fde1c200f0d9323ba1be23f Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Wed, 26 Jan 2022 19:29:26 +0200 Subject: Color shade window. GUI. Related Work Items: #5831 --- .../Models/ColorShadesModel.cs | 6 +- .../ViewModels/ColorCalibrationViewVM.cs | 2 +- .../ViewModels/ColorShadeTabVM.cs | 14 ++- .../ViewModels/ColorShadeViewVM.cs | 24 ++-- .../Views/ColorShadeView.xaml | 136 +++++++++++++-------- .../Views/MachineTestResultsView.xaml | 3 + .../Views/TestResultsView.xaml | 42 ++++--- .../Entities/RmlExtensionColorShadesTestsData.cs | 22 ++++ 8 files changed, 163 insertions(+), 86 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ColorShadesModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ColorShadesModel.cs index cc4351891..98d4afe07 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ColorShadesModel.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ColorShadesModel.cs @@ -11,16 +11,20 @@ namespace Tango.MachineStudio.ThreadExtensions.Models { public class ColorShadesDataItem { - public double ColorNumber { get; set; } + public int ColorNumber { get; set; } public double L { get; set; } public double A { get; set; } public double B { get; set; } public double C { get; set; } public double M { get; set; } public double Y { get; set; } + public double K { get; set; } + public double TI { get; set; } public double L2 { get; set; } public double A2 { get; set; } public double B2 { get; set; } + public double DelteE { get; set; } + } public void GetDataFromFile(string fileName, out List items, ref string errors) diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationViewVM.cs index fc15c8caf..3f4d8a415 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationViewVM.cs @@ -370,7 +370,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels newtab.RmlExtensionColorCalibrationsTest = new RmlExtensionColorCalibrationsTest() { - RmlExtensionColorCalibrationGuid = RMLExtentionGUID, + RmlExtensionColorCalibrationGuid = RmlExtensionColorCalibration.Guid, Name = name }; var liquidDataCollection = new SynchronizedObservableCollection(); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeTabVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeTabVM.cs index df0ba521c..eaaf7dc96 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeTabVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeTabVM.cs @@ -83,13 +83,14 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels #endregion - RelayCommand ImportColorsCommand { get; set; } + public RelayCommand ImportColorsCommand { get; set; } public ColorShadeTabVM(INotificationProvider notification, IActionLogManager actionLogManager) { _notification = notification; _actionLogManager = actionLogManager; ImportColorsCommand = new RelayCommand(ImportColors); + RemovedDataList = new List(); } private void ImportColors(object obj) @@ -108,11 +109,18 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels if (false == String.IsNullOrEmpty(errors) || items == null || items.Count == 0) { _notification.ShowError("An error occurred while trying to import data form the selected excel file. Please check the file format if valid and is available to read."); - + } else { - //Settings data to object + if (RemovedDataList.Count == 0 && RmlExtensionColorShadesTest.RmlExtensionColorShadesTestsData.Count > 0) + { + RemovedDataList = new List(RmlExtensionColorShadesTest.RmlExtensionColorShadesTestsData.ToList()); + } + RmlExtensionColorShadesTest.RmlExtensionColorShadesTestsData.Clear(); + items.ForEach(x => RmlExtensionColorShadesTest.RmlExtensionColorShadesTestsData.Add(new RmlExtensionColorShadesTestsData() { + ColorNum = x.ColorNumber, L = x.L, A = x.A, B = x.B, C = x.C, M = x.M, Y = x.Y, K = x.K, Ti = x.TI, LRes = x.L2, ARes = x.A2, BRes = x.B2, DeltaE = x.DelteE })); + } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeViewVM.cs index b1dac5ce9..f305d5139 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeViewVM.cs @@ -231,14 +231,14 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels newtab.RmlExtensionColorShadesTest = new RmlExtensionColorShadesTest() { - RmlExtensionColorShadesGuid = RMLExtentionGUID, + RmlExtensionColorShadesGuid = RmlExtensionColorShade.Guid, Name = name }; if (RmlExtensionColorShade != null) { RmlExtensionColorShade.RmlExtensionColorShadesTests.Add(newtab.RmlExtensionColorShadesTest); } - + return newtab; } #endregion @@ -372,21 +372,15 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels foreach (var tab in ColorShadeTabs) { tab.RmlExtensionColorShadesTest.LastUpdated = lastUpdated; - //var removedPoints = tab.RemovedPoints; - //foreach (var liquidData in tab.RmlExtensionColorCalibrationsTest.RmlExtensionColorCalibrationsTestsLiquidData) - //{ - // var liquidtype = _liquids.Where(l => l.Guid == liquidData.LiquidTypeGuid).FirstOrDefault(); - // if (liquidtype != null && removedPoints.ContainsKey(liquidtype.Type)) - // { - // _active_context.RmlExtensionColorCalibrationsTestsLiquidDataPoints.RemoveRange(removedPoints[liquidtype.Type]); - // } - // liquidData.LastUpdated = lastUpdated; - //} - //tab.RemovedPoints.Clear(); + var removedPoints = tab.RemovedDataList; + if (removedPoints.Count > 0) + { + _active_context.RmlExtensionColorShadesTestsData.RemoveRange(removedPoints); + } + tab.RemovedDataList.Clear(); } await _active_context.SaveChangesAsync(); - - // LoadColorParameters(); + } catch (Exception ex) { diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorShadeView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorShadeView.xaml index 70df4d6bf..f8aaa5e24 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorShadeView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorShadeView.xaml @@ -17,6 +17,7 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/MachineTestResultsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/MachineTestResultsView.xaml index b46cb4cf9..820c68715 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/MachineTestResultsView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/MachineTestResultsView.xaml @@ -61,6 +61,9 @@ + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/TestResultsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/TestResultsView.xaml index 50a2537e1..b8a4b7f28 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/TestResultsView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/TestResultsView.xaml @@ -265,20 +265,16 @@ - - - - Conclusion: - - - - - Comments: - - - - - + + + + + + + + + + @@ -631,7 +627,23 @@ - + + + + + + + + + + + Conclusion: + + + Comments: + + + diff --git a/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorShadesTestsData.cs b/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorShadesTestsData.cs index ac2c44f15..19dce1a0e 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorShadesTestsData.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/RmlExtensionColorShadesTestsData.cs @@ -23,7 +23,29 @@ namespace Tango.BL.Entities { } + protected override void OnLChanged(double L) + { + base.OnLChanged(L); + UpdateColorBrush(); + } + + protected override void OnAChanged(double L) + { + base.OnAChanged(L); + UpdateColorBrush(); + } + + protected override void OnBChanged(double L) + { + base.OnBChanged(L); + UpdateColorBrush(); + } + private void UpdateColorBrush() + { + RaisePropertyChanged(nameof(ColorBrush)); + } + [NotMapped] [JsonIgnore] public SolidColorBrush ColorBrush -- cgit v1.3.1