diff options
| author | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2022-01-09 16:17:15 +0200 |
|---|---|---|
| committer | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2022-01-09 16:17:15 +0200 |
| commit | b6b16143304b50744e974ddaa9c71c49766be4dc (patch) | |
| tree | d773bd1c50b4241669a07cc6cb2e7f4cf936f86b /Software/Visual_Studio/MachineStudio | |
| parent | 506b18058821a3791b28c0296e54ef3bc5a3391a (diff) | |
| download | Tango-b6b16143304b50744e974ddaa9c71c49766be4dc.tar.gz Tango-b6b16143304b50744e974ddaa9c71c49766be4dc.zip | |
#5821 RML extension - Color calibration window
Diffstat (limited to 'Software/Visual_Studio/MachineStudio')
11 files changed, 1691 insertions, 28 deletions
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<DataPoint> _LPoints; + + public IList<DataPoint> LPoints + { + get { return _LPoints; } + set { _LPoints = value; } + } + + private IList<DataPoint> _APoints; + + public IList<DataPoint> APoints + { + get { return _APoints; } + set { _APoints = value; } + } + + private IList<DataPoint> _BPoints; + + public IList<DataPoint> BPoints + { + get { return _BPoints; } + set { _BPoints = value; } + } + + private IList<DataPoint> _points; + /// <summary> + /// Binding to ItemsSource of line chart. + /// </summary> + public IList<DataPoint> LinearizationPoints + { + get { return _points; } + set + { + _points = value; + RaisePropertyChangedAuto(); + } + } + + private int _step; + public int XStep + { + get { return _step; } + set { _step = value; RaisePropertyChangedAuto(); } + } + + private double _minY; + /// <summary> + /// From use to binding to left axis min value + /// </summary> + public double MinY + { + get { return _minY; } + set + { + _minY = value; RaisePropertyChangedAuto(); + } + } + + private double _maxY; + /// <summary> + /// To use to binding to left axis max value + /// </summary> + public double MaxY + { + get { return _maxY; } + set + { + _maxY = value; RaisePropertyChangedAuto(); + } + } + private int _maxX; + /// <summary> + /// Gets or sets the maximum lab plot X values for LinearizationGraph left part + /// </summary> + 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<DataPoint>(); + LPoints = new List<DataPoint>(); + APoints = new List<DataPoint>(); + BPoints = new List<DataPoint>(); + _color = color; + _title = title; + + } + public void ClearResults() + { + LPoints.Clear(); + APoints.Clear(); + BPoints.Clear(); + LinearizationPoints.Clear(); + } + + public void InitDataGraph(List<ColorLinearizationModel.LinearizationDataItem> 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<ColorLinearizationModel.LinearizationDataItem> items, List<double> 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<LinearizationDataItem> items, ref string errors) + { + items = null; + try + { + using (ExcelReader reader = new ExcelReader(fileName)) + { + items = reader.GetDataByIndex<LinearizationDataItem>("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<IdsPack> _idspacks; + public IEnumerable<IdsPack> IdsPacks + { + get { return _idspacks; } + set + { + _idspacks = value; + } + } + public MachineModel() { HasRMLTest = false; 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 9ea43ad0b..4af5d899b 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 @@ -97,6 +97,8 @@ <Compile Include="Converters\NumericFieldConverter.cs" /> <Compile Include="Excel\ColorDataExcelModel.cs" /> <Compile Include="Excel\ColorParametrsExcelModel.cs" /> + <Compile Include="Models\CalibrationPlotModel.cs" /> + <Compile Include="Models\ColorLinearizationModel.cs" /> <Compile Include="Models\FactorTarget.cs" /> <Compile Include="Models\MachineModel.cs" /> <Compile Include="Models\PlotProperties.cs" /> @@ -105,6 +107,9 @@ <Compile Include="Excel\ThreadCharacteristicsExelModel.cs" /> <Compile Include="ViewModelLocator.cs" /> <Compile Include="ViewModels\AddItemDialogVM.cs" /> + <Compile Include="ViewModels\CalibrationDataVM.cs" /> + <Compile Include="ViewModels\ColorCalibrationTabVM.cs" /> + <Compile Include="ViewModels\ColorCalibrationViewVM.cs" /> <Compile Include="ViewModels\ColorParametersVewVM.cs" /> <Compile Include="ViewModels\MainViewVM.cs" /> <Compile Include="ViewModels\TestResultsViewVM.cs" /> @@ -112,6 +117,9 @@ <Compile Include="Views\AddItemDialog.xaml.cs"> <DependentUpon>AddItemDialog.xaml</DependentUpon> </Compile> + <Compile Include="Views\ColorCalibrationView.xaml.cs"> + <DependentUpon>ColorCalibrationView.xaml</DependentUpon> + </Compile> <Compile Include="Views\ColorParametersView.xaml.cs"> <DependentUpon>ColorParametersView.xaml</DependentUpon> </Compile> @@ -145,6 +153,10 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="Views\ColorCalibrationView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="Views\ColorParametersView.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> @@ -208,6 +220,10 @@ <Resource Include="Images\threads.png" /> </ItemGroup> <ItemGroup> + <ProjectReference Include="..\..\..\SideChains\ColorMine\ColorMine.csproj"> + <Project>{37E4CEAB-B54B-451F-B535-04CF7DA9C459}</Project> + <Name>ColorMine</Name> + </ProjectReference> <ProjectReference Include="..\..\..\SideChains\Tango.AutoComplete\Tango.AutoComplete.csproj"> <Project>{bb2abb74-ba58-4812-83aa-ec8171f42df4}</Project> <Name>Tango.AutoComplete</Name> @@ -216,6 +232,10 @@ <Project>{f441feee-322a-4943-b566-110e12fd3b72}</Project> <Name>Tango.BL</Name> </ProjectReference> + <ProjectReference Include="..\..\..\Tango.ColorCalibration\Tango.ColorCalibration.csproj"> + <Project>{b60c695c-61e8-4091-b506-4c45349c04aa}</Project> + <Name>Tango.ColorCalibration</Name> + </ProjectReference> <ProjectReference Include="..\..\..\Tango.Core\Tango.Core.csproj"> <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project> <Name>Tango.Core</Name> @@ -228,6 +248,10 @@ <Project>{bc932dbd-7cdb-488c-99e4-f02cf441f55e}</Project> <Name>Tango.Logging</Name> </ProjectReference> + <ProjectReference Include="..\..\..\Tango.PMR\Tango.PMR.csproj"> + <Project>{e4927038-348d-4295-aaf4-861c58cb3943}</Project> + <Name>Tango.PMR</Name> + </ProjectReference> <ProjectReference Include="..\..\..\Tango.Settings\Tango.Settings.csproj"> <Project>{d8f1ad85-526a-4f50-b6dc-d437af63d8d8}</Project> <Name>Tango.Settings</Name> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/CalibrationDataVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/CalibrationDataVM.cs new file mode 100644 index 000000000..b8fab210c --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/CalibrationDataVM.cs @@ -0,0 +1,138 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Entities; +using Tango.Core; +using Tango.PMR.ColorLab; + +namespace Tango.MachineStudio.ThreadExtensions.ViewModels +{ + public class CalibrationDataPointVM : ExtendedObject + { + private double _x; + + public double X + { + get { return _x; } + set { _x = value; RaisePropertyChangedAuto(); } + } + + private double _y; + + public double Y + { + get { return _y; } + set { _y = value; RaisePropertyChangedAuto(); } + } + + private int _index; + + public int Index + { + get { return _index; } + set { _index = value; RaisePropertyChangedAuto(); } + } + + + public CalibrationDataPointVM() + { + + } + + public CalibrationDataPointVM(double x, double y) + { + X = x; + Y = y; + } + + public CalibrationDataPointVM(CalibrationPoint calibrationPoint) : this(calibrationPoint.X, calibrationPoint.Y) + { + + } + + public CalibrationPoint ToPMR() + { + return new CalibrationPoint() + { + X = X, + Y = Y, + }; + } + } + + public class CalibrationDataVM : ExtendedObject + { + private BL.Entities.LiquidType _liquidType; + + public BL.Entities.LiquidType LiquidType + { + get { return _liquidType; } + set { _liquidType = value; RaisePropertyChangedAuto(); } + } + + private IdsPack _idsPack; + + public IdsPack IdsPack + { + get { return _idsPack; } + set { _idsPack = value; RaisePropertyChangedAuto(); } + } + + private ObservableCollection<CalibrationDataPointVM> _calibrationPoints; + + public ObservableCollection<CalibrationDataPointVM> CalibrationPoints + { + get { return _calibrationPoints; } + set { _calibrationPoints = value; RaisePropertyChangedAuto(); OnCalibrationPointsChanged(); } + } + + private void OnCalibrationPointsChanged() + { + if (CalibrationPoints != null) + { + CalibrationPoints.CollectionChanged -= CalibrationPoints_CollectionChanged; + CalibrationPoints.CollectionChanged += CalibrationPoints_CollectionChanged; + + SetIndices(); + } + } + + private void CalibrationPoints_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) + { + SetIndices(); + } + + private void SetIndices() + { + if (CalibrationPoints != null) + { + int index = 1; + foreach (var p in CalibrationPoints) + { + p.Index = index++; + } + } + } + + private CalibrationDataVM() + { + CalibrationPoints = new ObservableCollection<CalibrationDataPointVM>(); + } + + public CalibrationDataVM(IdsPack pack) : this() + { + IdsPack = pack; + LiquidType = pack.LiquidType; + } + + public CalibrationDataVM(BL.Entities.LiquidType liquidType) : this() + { + LiquidType = liquidType; + CalibrationPoints = new ObservableCollection<CalibrationDataPointVM>(); + //CalibrationPoints.Add(new CalibrationDataPointVM() { Index = 1, X = 2, Y = 22 }); + } + } +}
\ No newline at end of file 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 new file mode 100644 index 000000000..103052b52 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationTabVM.cs @@ -0,0 +1,323 @@ +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.PMR.ColorLab; +using Tango.ColorCalibration; +using Tango.BL.ActionLogs; + +namespace Tango.MachineStudio.ThreadExtensions.ViewModels +{ + public class ColorCalibrationTabVM : ViewModel + { + private INotificationProvider _notification; + private IActionLogManager _actionLogManager; + private ILinearizationMeasurements _linearizationMeasurementscalibrator; + + #region Properties + + private string _name; + /// <summary> + /// Gets or sets the name of the thread. Using in print + /// </summary> + public string Name + { + get { return _name; } + set + { + _name = value; + RaisePropertyChangedAuto(); + } + } + + private int _tabIndex; + + public int TabIndex + { + get { return _tabIndex; } + set { _tabIndex = value; } + } + + + private bool _isSelected; + /// <summary> + /// Gets or sets a value indicating whether this instance is selected. + /// </summary> + public bool IsSelected + { + get { return _isSelected; } + set { _isSelected = value; RaisePropertyChangedAuto(); } + } + + private CalibrationPlotModel _cyanPlot; + + public CalibrationPlotModel CyanPlot + { + get { return _cyanPlot; } + set + { + _cyanPlot = value; + RaisePropertyChangedAuto(); + } + } + + 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(); } + } + + + #endregion + + #region Commands + + public RelayCommand ImportCyanDataCommand { get; set; } + public RelayCommand ImportMagentaDataCommand { get; set; } + public RelayCommand ImportYellowDataCommand { get; set; } + public RelayCommand ImportBlackDataCommand { get; set; } + + #endregion + + public ColorCalibrationTabVM(INotificationProvider notification, IActionLogManager actionLogManager) + { + _notification = notification; + _actionLogManager = actionLogManager; + _linearizationMeasurementscalibrator = new DefaultColorCalibrator(); + + CyanPlot = new CalibrationPlotModel(FactorColors.CYAN, "Cyan"); + YellowPlot = new CalibrationPlotModel(FactorColors.YELLOW, "Yellow"); + MagentaPlot = new CalibrationPlotModel(FactorColors.MAGENTA, "Magenta"); + BlackPlot = new CalibrationPlotModel(FactorColors.BLACK, "Black"); + + CyanCalibrationData = new CalibrationDataVM(new Tango.BL.Entities.LiquidType() { Code = (int)LiquidTypes.Cyan }); + MagentaCalibrationData = new CalibrationDataVM(new Tango.BL.Entities.LiquidType() { Code = (int)LiquidTypes.Magenta }); + YellowCalibrationData = new CalibrationDataVM(new Tango.BL.Entities.LiquidType() { Code = (int)LiquidTypes.Yellow }); + BlackCalibrationData = new CalibrationDataVM(new Tango.BL.Entities.LiquidType() { Code = (int)LiquidTypes.Black }); + + ImportCyanDataCommand = new RelayCommand(ImportCyanData); + ImportMagentaDataCommand = new RelayCommand(ImportMagentaData); + ImportYellowDataCommand = new RelayCommand(ImportYellowData); + ImportBlackDataCommand = new RelayCommand(ImportBlackData); + } + + #region Methods + private async void ImportCyanData(object obj) + { + + List<ColorLinearizationModel.LinearizationDataItem> items; + if (ImportDataFromFile(out items) && items.Count > 0) + { + CyanPlot.InitDataGraph(items); + + List<double> outputPoints = new List<double>(); + + await Task.Factory.StartNew(() => + { + 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 }); + } + } + + } + + private async void ImportMagentaData(object obj) + { + + List<ColorLinearizationModel.LinearizationDataItem> items; + if (ImportDataFromFile(out items) && items.Count > 0) + { + MagentaPlot.InitDataGraph(items); + + List<double> outputPoints = new List<double>(); + + await Task.Factory.StartNew(() => + { + 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}); + } + } + } + + private async void ImportYellowData(object obj) + { + + List<ColorLinearizationModel.LinearizationDataItem> items; + if (ImportDataFromFile(out items) && items.Count > 0) + { + YellowPlot.InitDataGraph(items); + + List<double> outputPoints = new List<double>(); + + await Task.Factory.StartNew(() => + { + 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 }); + } + } + } + + + private async void ImportBlackData(object obj) + { + + List<ColorLinearizationModel.LinearizationDataItem> items; + if (ImportDataFromFile(out items) && items.Count > 0) + { + BlackPlot.InitDataGraph(items); + + List<double> outputPoints = new List<double>(); + + await Task.Factory.StartNew(() => + { + 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 }); + } + } + + } + + /// <summary> + /// Open file dialog and get name of file + /// </summary> + /// <returns></returns> + private bool ImportDataFromFile(out List<ColorLinearizationModel.LinearizationDataItem> items) + { + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Title = "Select data file"; + dlg.Filter = "Excel |*.xlsx"; + items = null; + if (dlg.ShowDialogCenter() && dlg.FileName.IsNotNullOrEmpty()) + { + ColorLinearizationModel model = new ColorLinearizationModel(); + 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."); + return false; + } + return true; + } + + return false; + } + + #endregion + + #region CreateLinearizationGraph + + private List<double> GetLinearizationMeasurements(List<ColorLinearizationModel.LinearizationDataItem> items, PMR.ColorLab.LiquidType liquidType) + { + try + { + LinearizationInput linearizationInput = new LinearizationInput(); + items.ForEach(x => linearizationInput.Measurements.Add(new LinearizationMeasurement { L = x.L, A = x.A, B = x.B, InkPercentage = x.InkPercentage })); + linearizationInput.LiquidType = liquidType; + + LinearizationOutput result = _linearizationMeasurementscalibrator.GetLinearizationMeasurements(linearizationInput); + + if (!String.IsNullOrEmpty(result.ErrorMessage)) + { + LogManager.Log(result.ErrorMessage, "GetLinearizationMeasurements returns error." + result.ErrorMessage); + InvokeUI(() => + { + _notification.ShowError("Linearizion process failed. " + result.ErrorMessage); + }); + } + + return result.InkPercentage.ToList(); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error occurred while trying to call GetLinearizationMeasurements."); + } + return null; + } + + #endregion + } +} 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 new file mode 100644 index 000000000..99bb896d7 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationViewVM.cs @@ -0,0 +1,467 @@ + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Collections.Specialized; +using System.ComponentModel; +using System.Linq; +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.BL.Enumerations; +using Tango.PMR.ColorLab; +using Tango.BL.Calibration; + + +namespace Tango.MachineStudio.ThreadExtensions.ViewModels +{ + public class ColorCalibrationViewVM : ViewModel + { + private INotificationProvider _notification; + private IActionLogManager _actionLogManager; + + private ObservablesContext _active_context; + + public event EventHandler SaveColorCalibration; + + + #region Properties + + private ObservableCollection<ColorCalibrationTabVM> _calibrationTabs; + + public ObservableCollection<ColorCalibrationTabVM> CalibrationTabs + { + get { return _calibrationTabs; } + set { _calibrationTabs = value; } + } + + private ColorCalibrationTabVM _selectedTab; + + public ColorCalibrationTabVM SelectedTab + { + get { return _selectedTab; } + set + { + _selectedTab = value; + RaisePropertyChangedAuto(); + + foreach (var tab in _calibrationTabs.Where(x => x != _selectedTab)) + { + tab.IsSelected = false; + } + + if (_selectedTab != null) + { + _selectedTab.IsSelected = true; + } + } + } + + private string _RMLExtentionGUID; + + public string RMLExtemtionGUID + { + get { return _RMLExtentionGUID; } + set + { + _RMLExtentionGUID = value; + OnRMLExtensionGUIDChanged(); + } + } + + private string _RMLGUID; + + public string RMLGUID + { + get { return _RMLGUID; } + set + { + _RMLGUID = value; + OnRMLExtensionGUIDChanged(); + } + } + + private Rml _activeRML; + public Rml ActiveRML + { + get { return _activeRML; } + set + { + _activeRML = value; + RaisePropertyChangedAuto(); + } + } + + private MachineModel _machine; + public MachineModel Machine + { + get { return _machine; } + set { _machine = value; + SelectedMachineChanged(); + RaisePropertyChangedAuto(); + InvalidateRelayCommands(); + } + } + + + private bool _isViewLoaded; + /// <summary> + /// Gets or sets a value indicating whether this instance is view loaded. Used to update charts. + /// </summary> + public bool IsViewLoaded + { + get { return _isViewLoaded; } + set + { + if (_isViewLoaded != value) + { + _isViewLoaded = value; + } + } + } + + + #endregion + + #region commands + public RelayCommand CreateColorDataImportExcelTemplateCommand { get; set; } + public RelayCommand ApplyToRMLCommand { get; set; } + public RelayCommand ApplyToMachineCalibrationCommand { get; set; } + + public RelayCommand SaveCommand { get; set; } + + public RelayCommand AddTabCommand { get; set; } + + public RelayCommand<ColorCalibrationTabVM> RemoveTabCommand { get; set; } + + public RelayCommand RenameTabCommand { get; set; } + + #endregion + + public ColorCalibrationViewVM(INotificationProvider notification, IActionLogManager actionLogManager) + { + _notification = notification; + _actionLogManager = actionLogManager; + CalibrationTabs = new ObservableCollection<ColorCalibrationTabVM>(); + + ApplyToRMLCommand = new RelayCommand(ApplyToRML); + ApplyToMachineCalibrationCommand = new RelayCommand(ApplyToMachineCalibration); + SaveCommand = new RelayCommand(Save, () => IsFree); + + AddTabCommand = new RelayCommand(() => AddNewTab()); + RemoveTabCommand = new RelayCommand<ColorCalibrationTabVM>(RemoveTab); + RenameTabCommand = new RelayCommand(RenameTab); + + CreateColorDataImportExcelTemplateCommand = new RelayCommand(CreateColorDataImportExcelTemplate); + } + + + + #region Methods + + private void OnRMLExtensionGUIDChanged() + { + } + + private void SelectedMachineChanged() + { + LoadColorCalibrations(); + } + + 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 Data File Template"; + if (dlg.ShowDialog().Value) + { + CalibrationHelper.CreateColorDataInputExcelTemplate(dlg.FileName); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error generating excel calibration template file " + dlg.FileName); + _notification.ShowError("An error occurred while trying to generate the calibration file."); + } + } + /// <summary> + /// Applies calibration points to RML. + /// </summary> + private void ApplyToRML(object obj) + { + if(SelectedTab != null && ActiveRML != null) + { + var liquidTypesRmls = ActiveRML.LiquidTypesRmls; + var calibrationDataVM = SelectedTab.CyanCalibrationData; + ApplayCalibrationDataToliquidTypesRml(liquidTypesRmls, LiquidTypes.Cyan, SelectedTab.CyanCalibrationData); + ApplayCalibrationDataToliquidTypesRml(liquidTypesRmls, LiquidTypes.Magenta, SelectedTab.MagentaCalibrationData); + ApplayCalibrationDataToliquidTypesRml(liquidTypesRmls, LiquidTypes.Yellow, SelectedTab.YellowCalibrationData); + ApplayCalibrationDataToliquidTypesRml(liquidTypesRmls, LiquidTypes.Black, SelectedTab.BlackCalibrationData); + Save(); + } + } + + private void ApplayCalibrationDataToliquidTypesRml(SynchronizedObservableCollection<LiquidTypesRml> liquidTypesRmls, LiquidTypes type, CalibrationDataVM calibrationDataVM) + { + if (calibrationDataVM.CalibrationPoints.Count == 0) + return; + + var liquidTypeRml = liquidTypesRmls.SingleOrDefault(x => x.LiquidType.Type == type); + CalibrationData calData = new CalibrationData(); + calData.LiquidType = (PMR.ColorLab.LiquidType)liquidTypeRml.LiquidType.Code; + calData.CalibrationPoints.Clear(); + calData.CalibrationPoints.AddRange(calibrationDataVM.CalibrationPoints.Select(x => new CalibrationPoint() { X = x.X, Y = x.Y })); + liquidTypeRml.PutCalibrationData(calData); + } + /// <summary> + /// Applies calibration points to machine calibration. + /// </summary> + private void ApplyToMachineCalibration(object obj) + { + if (SelectedTab != null) + { + var idsPack = Machine.IdsPacks. + Where(x => ActiveRML.LiquidTypesRmls.ToList().Exists(y => x.LiquidType != null && y.LiquidType.Guid == x.LiquidType.Guid)) + .OrderBy(x => x.PackIndex).ToList(); + + ApplayCalibrationDataToToMachineRml(idsPack, LiquidTypes.Cyan, SelectedTab.CyanCalibrationData); + ApplayCalibrationDataToToMachineRml(idsPack, LiquidTypes.Magenta, SelectedTab.MagentaCalibrationData); + ApplayCalibrationDataToToMachineRml(idsPack, LiquidTypes.Yellow, SelectedTab.YellowCalibrationData); + ApplayCalibrationDataToToMachineRml(idsPack, LiquidTypes.Black, SelectedTab.BlackCalibrationData); + Save(); + } + } + + private void ApplayCalibrationDataToToMachineRml(List<IdsPack> idsPacks, LiquidTypes type, CalibrationDataVM calibrationDataVM) + { + if (calibrationDataVM.CalibrationPoints.Count == 0) + return; + + var idsPack = idsPacks.FirstOrDefault(x => x.LiquidType.Type == type); + + if (idsPack != null) + { + var cat = idsPack.LiquidType.Cats.FirstOrDefault(x => x.MachineGuid == Machine.Guid && x.RmlGuid == ActiveRML.Guid); ; + + if (cat == null) + { + cat = new Cat(); + cat.Name = "untitled"; + _active_context.Cats.Add(cat); + } + + cat.RmlGuid = ActiveRML.Guid; + cat.MachineGuid = Machine.Guid; + cat.LiquidType = idsPack.LiquidType; + + CalibrationData calData = new CalibrationData(); + calData.LiquidType = (PMR.ColorLab.LiquidType)idsPack.LiquidType.Code; + calData.CalibrationPoints.AddRange(calibrationDataVM.CalibrationPoints.Select(x => new CalibrationPoint() { X = x.X, Y = x.Y })); + + cat.PutCalibrationData(calData); + } + } + + #endregion + + #region Loading + + public async void LoadColorCalibrations() + { + if (Machine == null) + { + _notification.ShowWarning(LogManager.Log($"Please, select machine.", LogCategory.Warning)); + IsFree = false; + return; + } + if (ActiveRML == null) + { + IsFree = false; + return; + } + IsFree = false; + if (_active_context != null) + { + _active_context.Dispose(); + } + + _active_context = ObservablesContext.CreateDefault(); + + await Task.Factory.StartNew(() => + { + using (_notification.PushTaskItem("Loading Color Calibrations Tests ...")) + { + } + }); + if (CalibrationTabs.Count == 0) + { + SelectedTab = CreateNewColorCalibrationTabVM("Untitled", 1); + CalibrationTabs.Add(SelectedTab); + //_active_context.RmlExtensionCalibrationTests.Add(SelectedTab.TestResult); + // await _active_context.SaveChangesAsync(); + } + //LoadColorCalibarions(); + IsFree = true; + } + + public void UpdatePlots() + { + if (IsViewLoaded) + { + //CyanPlot.CreateGraph(CyanProcessData.ToList(), true); + //MagentaPlot.CreateGraph(MagentaProcessData.ToList(), true); + //YellowPlot.CreateGraph(YellowProcessData.ToList(), false); + //BlackPlot.CreateGraph(BlackProcessData.ToList(), true); + } + } + + private ColorCalibrationTabVM CreateNewColorCalibrationTabVM(string name, int index) + { + ColorCalibrationTabVM newtab = new ColorCalibrationTabVM(_notification, _actionLogManager) { Name = name , TabIndex = index}; + + return newtab; + } + + #endregion + + #region Tabs modification + + /// <summary> + /// Removes the specified tab. + /// </summary> + /// <param name="tab">The tab.</param> + private void RemoveTab(ColorCalibrationTabVM tab) + { + if (CalibrationTabs.Count == 1) + return; + if (_notification.ShowQuestion("Are you sure you want to delete the selected tab?")) + { + // _active_context.RmlExtensionTestResults.Remove(tab.TestResult); + + CalibrationTabs.Remove(tab); + SelectedTab = CalibrationTabs.LastOrDefault(); + _active_context.SaveChanges(); + } + } + + /// <summary> + /// Adds a new tab. + /// </summary> + private bool AddNewTab(String name = null) + { + if (CalibrationTabs.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 = CreateNewColorCalibrationTabVM(name, (CalibrationTabs.Count + 1)); + CalibrationTabs.Add(tab); + //_active_context.RmlExtensionTestResults.Add(tab.TestResult); + SelectedTab = tab; + return true; + } + else + { + return false; + } + } + + /// <summary> + /// Renames the tab. + /// </summary> + /// <param name="tab">The tab.</param> + 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 (Machine == null) + { + _notification.ShowWarning(LogManager.Log($"Could not save Color Calibrations. Please, select machine before save.", LogCategory.Warning)); + return; + } + + try + { + IsFree = false; + + //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; + //} + + await _active_context.SaveChangesAsync(); + + // LoadColorParameters(); + } + catch (Exception ex) + { + LogManager.Log(ex, "Could not update color calibrations."); + _notification.ShowError($"An error occurred while trying to save color calibrations.\n{ex.Message}"); + } + finally + { + IsFree = true; + EventHandler handler = SaveColorCalibration; + 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 4802e0af1..e8aafca9d 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 @@ -257,6 +257,13 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels set { _testResultsViewVM = value; RaisePropertyChangedAuto(); } } + private ColorCalibrationViewVM _colorCalibrationViewVM; + public ColorCalibrationViewVM ColorCalibrationViewVM + { + get { return _colorCalibrationViewVM; } + set { _colorCalibrationViewVM = value; RaisePropertyChangedAuto(); } + } + protected MachineModel _selectedMachine; /// <summary> /// Gets or sets the selected machine. @@ -294,20 +301,20 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels } - private MachineTestResultsTabs PreviosSelectedTab { get; set; } + //private MachineTestResultsTabs PreviosSelectedTab { get; set; } - private MachineTestResultsTabs _selectedTab; + //private MachineTestResultsTabs _selectedTab; - public MachineTestResultsTabs SelectedTab - { - get { return _selectedTab; } - set { - PreviosSelectedTab = _selectedTab; - _selectedTab = value; - OnSelectedMachineTestResultsTabChanged(); - RaisePropertyChangedAuto(); - } - } + //public MachineTestResultsTabs SelectedTab + //{ + // get { return _selectedTab; } + // set { + // PreviosSelectedTab = _selectedTab; + // _selectedTab = value; + // OnSelectedMachineTestResultsTabChanged(); + // RaisePropertyChangedAuto(); + // } + //} #endregion @@ -922,7 +929,8 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels { Guid = x.Guid, Name = x.Name, - SerialNumber = x.SerialNumber + SerialNumber = x.SerialNumber, + IdsPacks = x.Configuration.IdsPacks.Where(z => !z.IsEmpty) }).ToObservableCollection(); } @@ -994,9 +1002,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels .WithUser() .BuildAsync(); - ActiveRML = new RmlBuilder(_active_context) - .Set(SelectedRMLExtension.RMLGuid) - .Build(); + ActiveRML = new RmlBuilder(_active_context).Set(SelectedRMLExtension.RMLGuid).WithLiquidFactors().Build(); if (!String.IsNullOrEmpty(ActiveRML.Manufacturer) && false == Manufacturers.Any(x => x == ActiveRML.Manufacturer)) { @@ -1040,12 +1046,23 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels TestResultsViewVM.SelectedMachineGUID = SelectedMachine != null ? SelectedMachine.Guid : null; TestResultsViewVM.ThreadName = ActiveRML.Manufacturer; + ColorCalibrationViewVM = new ColorCalibrationViewVM(_notification, _actionLogManager); + ColorCalibrationViewVM.RMLExtemtionGUID = guid; + ColorCalibrationViewVM.ActiveRML = ActiveRML; + ColorCalibrationViewVM.RMLGUID = ActiveRML.Guid; + ColorCalibrationViewVM.Machine = SelectedMachine; + + + + if (ActiveRMLExtension.RMLStatus == RMLExtensionStatus.New) { ColorParametersVewVM.SaveColorParameters -= UpdateStatus; ColorParametersVewVM.SaveColorParameters += UpdateStatus; TestResultsViewVM.SaveTestResults -= UpdateStatus; TestResultsViewVM.SaveTestResults += UpdateStatus; + ColorCalibrationViewVM.SaveColorCalibration -= UpdateStatus; + ColorCalibrationViewVM.SaveColorCalibration += UpdateStatus; } View.NavigateTo(RMLExtensionNavigationView.RMLExtentionView); @@ -1108,6 +1125,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels { ColorParametersVewVM.SaveColorParameters -= UpdateStatus; TestResultsViewVM.SaveTestResults -= UpdateStatus; + ColorCalibrationViewVM.SaveColorCalibration -= UpdateStatus; ActiveRMLExtension.RMLStatus = RMLExtensionStatus.InProgress; ActiveRMLExtension.LastUpdated = DateTime.UtcNow; @@ -1134,6 +1152,10 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels { TestResultsViewVM.SelectedMachineGUID = SelectedMachine.Guid; } + if(ColorCalibrationViewVM != null) + { + ColorCalibrationViewVM.Machine = SelectedMachine; + } } #endregion @@ -1183,10 +1205,10 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels #region selections - private void OnSelectedMachineTestResultsTabChanged() - { - if(SelectedTab == MachineTestResultsTabs.ColorParameters) - { + //private void OnSelectedMachineTestResultsTabChanged() + // { + //if(SelectedTab == MachineTestResultsTabs.ColorParameters) + // { //if(PreviosSelectedTab == MachineTestResultsTabs.TestResults && TestResultsViewVM != null) //{ // TestResultsViewVM.Save(); @@ -1194,15 +1216,15 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels //save //if (_notification.ShowQuestion("Are you sure you want to exit this page without saving changes?")) - } - else if(SelectedTab == MachineTestResultsTabs.TestResults) - { + // } + // else if(SelectedTab == MachineTestResultsTabs.TestResults) + // { //if (PreviosSelectedTab == MachineTestResultsTabs.ColorParameters && ColorParametersVewVM != null) //{ // ColorParametersVewVM.Save(); //} - } - } + //} + // } #endregion @@ -1304,6 +1326,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels colorParametrsExcelList.Add(colorParametrsExcelModel); TestResultsViewVM.LoadTestResultsExcel(testResultsExcelModelList, machine.Guid, machine.SerialNumber); + //ColorCalibrationViewVM.WritetoExcel } } 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 new file mode 100644 index 000000000..278d58d02 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorCalibrationView.xaml @@ -0,0 +1,349 @@ +<UserControl x:Class="Tango.MachineStudio.ThreadExtensions.Views.ColorCalibrationView" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:local="clr-namespace:Tango.MachineStudio.ThreadExtensions.Views" + xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" + xmlns:enumerators="clr-namespace:Tango.BL.Enumerations;assembly=Tango.BL" + xmlns:global="clr-namespace:Tango.MachineStudio.ThreadExtensions" + xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:autoCompleteMachine="clr-namespace:Tango.MachineStudio.Common.AutoComplete;assembly=Tango.MachineStudio.Common" + xmlns:autoComplete="clr-namespace:Tango.AutoComplete.Editors;assembly=Tango.AutoComplete" + xmlns:oxy="http://oxyplot.org/wpf" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:vm="clr-namespace:Tango.MachineStudio.ThreadExtensions.ViewModels" + xmlns:fa="http://schemas.fontawesome.io/icons/" + + mc:Ignorable="d" + d:DesignHeight="450" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:ColorCalibrationViewVM, IsDesignTimeCreatable=False}" FontSize="16"> + <UserControl.Resources> + <autoCompleteMachine:MachinesProvider x:Key="MachinesProvider" /> + <converters:EnumToDescriptionConverter x:Key="EnumToDescriptionConverter" /> + <Style x:Key="CellNumericUpDown" TargetType="{x:Type mahapps:NumericUpDown}" BasedOn="{StaticResource {x:Type mahapps:NumericUpDown}}"> + <Setter Property="FrameworkElement.HorizontalAlignment" Value="Stretch"/> + <Setter Property="HorizontalContentAlignment" Value="Left"/> + <Setter Property="Background" Value="Transparent"/> + <Setter Property="BorderThickness" Value="0"/> + <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/> + <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled"/> + <Setter Property="Focusable" Value="false"/> + <Setter Property="IsHitTestVisible" Value="false"/> + <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled"/> + <Setter Property="FrameworkElement.VerticalAlignment" Value="Top"/> + <Setter Property="VerticalContentAlignment" Value="Center"/> + <Setter Property="FrameworkElement.MinHeight" Value="0"/> + <Setter Property="HideUpDownButtons" Value="true"/> + <Setter Property="FontSize" Value="14"/> + </Style> + + <Style x:Key="EditableCellNumericUpDown" TargetType="{x:Type mahapps:NumericUpDown}" BasedOn="{StaticResource {x:Type mahapps:NumericUpDown}}"> + <Setter Property="FrameworkElement.HorizontalAlignment" Value="Stretch"/> + <Setter Property="HorizontalContentAlignment" Value="Left"/> + <Setter Property="BorderThickness" Value="0"/> + <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/> + <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled"/> + <Setter Property="FrameworkElement.VerticalAlignment" Value="Center"/> + <Setter Property="VerticalContentAlignment" Value="Center"/> + <Setter Property="FrameworkElement.MinHeight" Value="0"/> + <Setter Property="FontSize" Value="14"/> + </Style> + + <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}"> + <Setter Property="BorderThickness" Value="0"/> + <Setter Property="FocusVisualStyle" Value="{x:Null}"/> + <Setter Property="VerticalContentAlignment" Value="Center"></Setter> + </Style> + + <DataTemplate x:Key="chartsPanel"> + <Grid Margin="10 20 0 10"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="1*"/> + <ColumnDefinition Width="1*"/> + </Grid.ColumnDefinitions> + + <Border Grid.Column="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderThickness="0" BorderBrush="{StaticResource DarkGrayBrush}" CornerRadius="5"> + <oxy:Plot TitleFontSize="14" x:Name="LABDataPlot" Margin="0 0 10 0" Background="Transparent" LegendPlacement="Inside" LegendPosition="TopRight" LegendOrientation="Vertical" LegendFontSize="9" LegendItemAlignment="Left" LegendLineSpacing="3" Foreground="{StaticResource Dialog.Foreground}"> + <oxy:Plot.Series > + <oxy:LineSeries ItemsSource="{Binding LPoints}" Color="LawnGreen" Title="L" StrokeThickness="1.5" MarkerType="Circle" MarkerFill="LawnGreen"/> + <oxy:LineSeries ItemsSource="{Binding APoints}" Color="#E14141" Title="A" StrokeThickness="1.5" MarkerType="Circle" MarkerFill="#E14141"/> + <oxy:LineSeries ItemsSource="{Binding BPoints}" Color="#73B6EC" Title="B" StrokeThickness="1.5" MarkerType="Circle" MarkerFill="#73B6EC"/> + </oxy:Plot.Series> + <oxy:Plot.Axes> + <oxy:LinearAxis Position="Bottom" Title = "Ink%" MajorGridlineStyle="Solid" MinorGridlineStyle="Dot" IsZoomEnabled="True" AxisTitleDistance ="12" Minimum="0" Maximum="{Binding MaxX}" /> + <oxy:LinearAxis Position="Left" Title = "LAB" MajorGridlineStyle="Solid" MinorGridlineStyle="Dot" IsZoomEnabled="True" Minimum="{Binding MinY}" Maximum="{Binding MaxY}" MinorStep="10" /> + </oxy:Plot.Axes> + </oxy:Plot> + </Border> + + <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="1" Grid.Row="0" Margin="10 0 0 0"> + <Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderThickness="0" BorderBrush="{StaticResource DarkGrayBrush}" CornerRadius="5"> + <oxy:Plot TitleFontSize="14" x:Name="LinearizationPlot" Margin="0 0 0 0" Background="Transparent" LegendPlacement="Inside" LegendPosition="RightTop" LegendOrientation="Vertical" > + <oxy:Plot.Series > + <oxy:LineSeries ItemsSource="{Binding LinearizationPoints}" Color="#73B6EC" MarkerFill="SteelBlue" MarkerType="Circle"/> + </oxy:Plot.Series> + <oxy:Plot.Axes> + <oxy:LinearAxis Position="Bottom" Title = "In Ink" MajorGridlineStyle="Solid" MinorGridlineStyle="Dot" IsZoomEnabled="True" Minimum="0" Maximum="{Binding LinearizationMaxX}"/> + <oxy:LinearAxis Position="Left" Title = "Out Ink" MajorGridlineStyle="Solid" MinorGridlineStyle="Dot" IsZoomEnabled="True" Minimum="0" Maximum="{Binding LinearizationMaxY}"/> + </oxy:Plot.Axes> + </oxy:Plot> + </Border> + </Grid> + </Grid> + </DataTemplate> + + <DataTemplate x:Key="calibrationDataGrid"> + <DockPanel Width="240" Margin="20 28 0 60"> + <Grid > + <DataGrid Background="{StaticResource TransparentBackgroundBrush400}" AlternatingRowBackground="{StaticResource Transparent200}" BorderThickness="1" BorderBrush="{StaticResource DarkGrayBrush}" Margin="0 0" ItemsSource="{Binding CalibrationPoints}" CanUserResizeColumns="False" CanUserReorderColumns="False" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="True" CanUserSortColumns="False"> + <DataGrid.CellStyle> + <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}"> + <Setter Property="BorderThickness" Value="0"/> + <Setter Property="HorizontalContentAlignment" Value="Left"></Setter> + <Setter Property="HorizontalAlignment" Value="Stretch"></Setter> + <Setter Property="Foreground" Value="{StaticResource BlackForegroundBrush}"></Setter> + </Style> + </DataGrid.CellStyle> + <DataGrid.Resources> + <Style x:Key="CellNumericUpDown" TargetType="{x:Type mahapps:NumericUpDown}" BasedOn="{StaticResource {x:Type mahapps:NumericUpDown}}"> + <Setter Property="FrameworkElement.HorizontalAlignment" Value="Stretch"/> + <Setter Property="HorizontalContentAlignment" Value="Left"/> + <Setter Property="Background" Value="Transparent"/> + <Setter Property="BorderThickness" Value="0"/> + <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/> + <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled"/> + <Setter Property="Focusable" Value="false"/> + <Setter Property="IsHitTestVisible" Value="false"/> + <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled"/> + <Setter Property="FrameworkElement.VerticalAlignment" Value="Top"/> + <Setter Property="VerticalContentAlignment" Value="Center"/> + <Setter Property="FrameworkElement.MinHeight" Value="0"/> + <Setter Property="HideUpDownButtons" Value="true"/> + </Style> + <Style x:Key="EditableCellNumericUpDown" TargetType="{x:Type mahapps:NumericUpDown}" BasedOn="{StaticResource {x:Type mahapps:NumericUpDown}}"> + <Setter Property="FrameworkElement.HorizontalAlignment" Value="Stretch"/> + <Setter Property="HorizontalContentAlignment" Value="Left"/> + <Setter Property="BorderThickness" Value="0"/> + <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/> + <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled"/> + <Setter Property="FrameworkElement.VerticalAlignment" Value="Top"/> + <Setter Property="VerticalContentAlignment" Value="Center"/> + <Setter Property="FrameworkElement.MinHeight" Value="0"/> + </Style> + </DataGrid.Resources> + <DataGrid.Columns> + <DataGridTextColumn Header="#" Binding="{Binding Index}" Width="Auto" IsReadOnly="True" Foreground="{StaticResource DimGrayBrush}" FontSize="11" /> + <mahapps:DataGridNumericUpDownColumn Header="X" Binding="{Binding X}" Minimum="0" Maximum="10000" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource CellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}"/> + <mahapps:DataGridNumericUpDownColumn Header="Y" Binding="{Binding Y}" StringFormat="0.00" Minimum="0" Maximum="10000" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource CellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}"/> + </DataGrid.Columns> + </DataGrid> + </Grid> + </DockPanel> + + </DataTemplate> + </UserControl.Resources> + + <Grid x:Name="contentGrid" DataContext="{Binding ColorCalibrationViewVM}" > + <Grid.RowDefinitions> + <RowDefinition Height="Auto"/> + <RowDefinition Height="1*"/> + </Grid.RowDefinitions> + + <DockPanel Grid.Row="0"> + <Button DockPanel.Dock="Right" HorizontalAlignment="Right" Width="170" Height="36" Margin="0 0 26 0" VerticalAlignment="Center" Command="{Binding SaveCommand}"> + <StackPanel Orientation="Horizontal"> + <materialDesign:PackIcon Kind="ContentSaveAll" Width="24" Height="24" /> + <TextBlock VerticalAlignment="Center" Margin="10 0 0 0">SAVE</TextBlock> + </StackPanel> + </Button> + <Button DockPanel.Dock="Right" HorizontalAlignment="Right" Width="170" Height="36" Margin="0 0 26 0" VerticalAlignment="Center" Command="{Binding ApplyToRMLCommand}"> + <StackPanel Orientation="Horizontal"> + <materialDesign:PackIcon Kind="ContentSaveAll" Width="24" Height="24" /> + <TextBlock VerticalAlignment="Center" Margin="10 0 0 0">Apply to RML</TextBlock> + </StackPanel> + </Button> + <Button DockPanel.Dock="Right" HorizontalAlignment="Right" Width="180" Height="36" Margin="0 0 26 0" VerticalAlignment="Center" Command="{Binding ApplyToMachineCalibrationCommand}" ToolTip="Apply to machine color calibration"> + <StackPanel Orientation="Horizontal"> + <materialDesign:PackIcon Kind="ContentSaveAll" Width="24" Height="24" /> + <TextBlock VerticalAlignment="Center" Margin="10 0 0 0" Text="Apply to Machine"></TextBlock> + </StackPanel> + </Button> + </DockPanel> + <Grid Grid.Row="1" > + <Grid.RowDefinitions> + <RowDefinition Height="30"/> + <RowDefinition Height="1*"/> + </Grid.RowDefinitions> + <StackPanel Orientation="Horizontal" Margin="35 0 0 0"> + <ListBox Style="{x:Null}" HorizontalAlignment="Left" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" ItemContainerStyle="{StaticResource basicListBoxItem}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled" Background="Transparent" BorderThickness="0" ItemsSource="{Binding CalibrationTabs}" SelectedItem="{Binding SelectedTab}"> + <ListBox.ItemsPanel> + <ItemsPanelTemplate> + <StackPanel HorizontalAlignment="Left" Orientation="Horizontal"></StackPanel> + </ItemsPanelTemplate> + </ListBox.ItemsPanel> + + <ListBox.ItemTemplate> + <DataTemplate> + <Border Padding="5 5" Width="160" CornerRadius="10 10 0 0" Margin="1 0" Tag="{Binding RelativeSource={RelativeSource AncestorType=ListBox},Path=DataContext}"> + <Border.ContextMenu> + <ContextMenu DataContext="{Binding Path=PlacementTarget.Tag, RelativeSource={RelativeSource Self}}" Style="{x:Null}" > + <MenuItem Header="Rename" Command="{Binding RenameTabCommand}" MinWidth="210" MaxHeight="40" > + <MenuItem.Icon> + <fa:ImageAwesome Icon="Pencil" Width="16" /> + </MenuItem.Icon> + </MenuItem> + </ContextMenu> + </Border.ContextMenu> + <Border.Style> + <Style TargetType="Border"> + <Setter Property="Background" Value="{StaticResource LightGrayBrush150}"></Setter> + <Setter Property="TextElement.Foreground" Value="{StaticResource DarkGrayBrush}"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding IsSelected}" Value="True"> + <Setter Property="Background" Value="{StaticResource AccentColorBrush}"></Setter> + <Setter Property="TextElement.Foreground" Value="{StaticResource WhiteTextBrush}"></Setter> + </DataTrigger> + <Trigger Property="IsMouseOver" Value="True"> + <Setter Property="Opacity" Value="0.8"></Setter> + </Trigger> + </Style.Triggers> + </Style> + </Border.Style> + <DockPanel VerticalAlignment="Center"> + <Button Cursor="Hand" Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListBox}, Path=DataContext.RemoveTabCommand}" CommandParameter="{Binding }" DockPanel.Dock="Right" Margin="5 0 0 0" Style="{StaticResource MaterialDesignFlatButton}" Padding="2" Height="Auto"> + <materialDesign:PackIcon Kind="Close"> + <materialDesign:PackIcon.Style> + <Style TargetType="materialDesign:PackIcon"> + <Setter Property="Foreground" Value="{StaticResource DarkGrayBrush}"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding IsSelected}" Value="True"> + <Setter Property="Foreground" Value="{StaticResource WhiteTextBrush}"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </materialDesign:PackIcon.Style> + </materialDesign:PackIcon> + </Button> + <TextBlock Text="{Binding Name}" VerticalAlignment="Center" TextAlignment="Center" TextTrimming="CharacterEllipsis" FontSize="11"></TextBlock> + </DockPanel> + </Border> + </DataTemplate> + </ListBox.ItemTemplate> + </ListBox> + <Button Margin="10 0 0 0" Style="{StaticResource MaterialDesignFlatButton}" Padding="2" Height="24" Cursor="Hand" Command="{Binding AddTabCommand}" ToolTip="New tab"> + <materialDesign:PackIcon Width="20" Height="20" Kind="Plus" Foreground="{StaticResource AccentColorBrush}" /> + </Button> + </StackPanel> + + <DockPanel Grid.Row="1" Margin="5 0 5 5"> + <UniformGrid Columns="2" FirstColumn="0" Name="uniformGrid1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Loaded="ContentGrid_Loaded"> + <DockPanel Grid.Column="0" Grid.Row="0" x:Name="CyanPanel"> + <Border DockPanel.Dock="Top" Background="LightCyan" Margin="20 0 0 0 " Padding="5" CornerRadius="5" Height="40" VerticalAlignment="Top"> + <Border.Effect> + <DropShadowEffect Opacity="0.4" /> + </Border.Effect> + <Grid> + <DockPanel> + <Button Height="Auto" DockPanel.Dock="Right" Style="{StaticResource MaterialDesignFlatButton}" Padding="0" FontSize="11" Foreground="{StaticResource DarkGrayBrush200}" HorizontalAlignment="Right" Command="{Binding CreateColorDataImportExcelTemplateCommand}" ToolTip="Create excel file template" Margin="0 0 5 0"> + <materialDesign:PackIcon Kind="FileExcel" Foreground="{StaticResource DimGrayBrush}" Width="16" Height="26" /> + </Button> + <Button DockPanel.Dock="Right" HorizontalAlignment="Left" Padding="2" Height="26" Width="140" Background="Transparent" Command="{Binding SelectedTab.ImportCyanDataCommand}" ToolTip="Import Cyan data " Margin="0 0 10 0" BorderBrush="{StaticResource TransparentBackgroundBrush200}" BorderThickness="1 1 0.8 2"> + <TextBlock FontSize="14" Foreground="{StaticResource MainWindow.Foreground}">IMPORT DATA</TextBlock> + </Button> + <TextBlock VerticalAlignment="Center" HorizontalAlignment="Left" Margin="20 4 0 0" FontSize="16" Padding="0">LIQUID TYPE CYAN</TextBlock> + </DockPanel> + </Grid> + </Border> + <Grid Grid.Row="1"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="1*"/> + <ColumnDefinition Width="Auto"/> + </Grid.ColumnDefinitions> + <ContentControl Name="cyanChartsContent" Grid.Row="1" ContentTemplate="{StaticResource chartsPanel}" Content="{Binding SelectedTab.CyanPlot}"/> + <ContentControl ContentTemplate="{StaticResource calibrationDataGrid}" Content="{Binding SelectedTab.CyanCalibrationData}" Grid.Column="1"/> + </Grid> + </DockPanel> + <DockPanel Grid.Column="1"> + <Border DockPanel.Dock="Top" Background="#FC63FC" Margin="20 0 0 0 " Padding="5" CornerRadius="5" Height="40" VerticalAlignment="Top"> + <Border.Effect> + <DropShadowEffect Opacity="0.4" /> + </Border.Effect> + <Grid> + <DockPanel> + <Button Height="Auto" DockPanel.Dock="Right" Style="{StaticResource MaterialDesignFlatButton}" Padding="0" FontSize="11" Foreground="{StaticResource DarkGrayBrush200}" HorizontalAlignment="Right" Command="{Binding CreateColorDataImportExcelTemplateCommand}" ToolTip="Create excel file template" Margin="0 0 5 0"> + <materialDesign:PackIcon Kind="FileExcel" Foreground="{StaticResource DimGrayBrush}" Width="16" Height="26" /> + </Button> + <Button DockPanel.Dock="Right" HorizontalAlignment="Left" Height="26" Padding="2" Width="140" Background="Transparent" Command="{Binding SelectedTab.ImportMagentaDataCommand}" ToolTip="Import Magenta data " Margin="0 0 10 0" BorderBrush="{StaticResource TransparentBackgroundBrush200}" BorderThickness="1 1 0.8 2"> + <TextBlock FontSize="14" Foreground="{StaticResource MainWindow.Foreground}">IMPORT DATA</TextBlock> + </Button> + <TextBlock VerticalAlignment="Center" HorizontalAlignment="Left" Margin="20 4 0 0" FontSize="16" Padding="0">LIQUID TYPE MAGENTA</TextBlock> + </DockPanel> + </Grid> + </Border> + <Grid Grid.Row="1"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="1*"/> + <ColumnDefinition Width="Auto"/> + </Grid.ColumnDefinitions> + <ContentControl Name="magentaChartsContent" ContentTemplate="{StaticResource chartsPanel}" Content="{Binding SelectedTab.MagentaPlot}"/> + <ContentControl ContentTemplate="{StaticResource calibrationDataGrid}" Content="{Binding SelectedTab.MagentaCalibrationData}" Grid.Column="1"/> + </Grid> + </DockPanel > + <DockPanel Grid.Column="0" Grid.Row="1" x:Name="YellowPanel"> + <Border DockPanel.Dock="Top" Background="LightYellow" Margin="20 0 0 0 " Padding="5" CornerRadius="5" Height="40" VerticalAlignment="Top"> + <Border.Effect> + <DropShadowEffect Opacity="0.4" /> + </Border.Effect> + <Grid> + <DockPanel> + <Button Height="Auto" DockPanel.Dock="Right" Style="{StaticResource MaterialDesignFlatButton}" Padding="0" FontSize="11" Foreground="{StaticResource DarkGrayBrush200}" HorizontalAlignment="Right" Command="{Binding CreateColorDataImportExcelTemplateCommand}" ToolTip="Create excel file template" Margin="0 0 5 0"> + <materialDesign:PackIcon Kind="FileExcel" Foreground="{StaticResource DimGrayBrush}" Width="16" Height="26" /> + </Button> + <Button DockPanel.Dock="Right" HorizontalAlignment="Left" Height="26" Padding="2" Width="140" Background="Transparent" Command="{Binding SelectedTab.ImportYellowDataCommand}" ToolTip="Import Yellow data " Margin="0 0 10 0" BorderBrush="{StaticResource TransparentBackgroundBrush200}" BorderThickness="1 1 0.8 2"> + <TextBlock FontSize="14" Foreground="{StaticResource MainWindow.Foreground}">IMPORT DATA</TextBlock> + </Button> + <TextBlock VerticalAlignment="Center" HorizontalAlignment="Left" Margin="20 4 0 0" FontSize="16" Padding="0">LIQUID TYPE YELLOW</TextBlock> + </DockPanel> + </Grid> + </Border> + <Grid Grid.Row="1"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="1*"/> + <ColumnDefinition Width="Auto"/> + </Grid.ColumnDefinitions> + <ContentControl Name="yellowChartsContent" ContentTemplate="{StaticResource chartsPanel}" Content="{Binding SelectedTab.YellowPlot}"/> + <ContentControl ContentTemplate="{StaticResource calibrationDataGrid}" Content="{Binding SelectedTab.YellowCalibrationData}" Grid.Column="1"/> + </Grid> + </DockPanel> + <DockPanel Grid.Column="1" Grid.Row="1"> + <Border DockPanel.Dock="Top" Background="DarkGray" Margin="20 0 0 0 " Padding="5" CornerRadius="5" Height="40" VerticalAlignment="Top"> + <Border.Effect> + <DropShadowEffect Opacity="0.4" /> + </Border.Effect> + <Grid> + <DockPanel> + <Button Height="Auto" DockPanel.Dock="Right" Style="{StaticResource MaterialDesignFlatButton}" Padding="0" FontSize="11" Foreground="{StaticResource DarkGrayBrush200}" HorizontalAlignment="Right" Command="{Binding CreateColorDataImportExcelTemplateCommand}" ToolTip="Create excel file template" Margin="0 0 5 0"> + <materialDesign:PackIcon Kind="FileExcel" Foreground="{StaticResource DimGrayBrush}" Width="16" Height="26" /> + </Button> + <Button DockPanel.Dock="Right" HorizontalAlignment="Left" Height="26" Padding="2" Width="140" Background="Transparent" Command="{Binding SelectedTab.ImportBlackDataCommand}" ToolTip="Import Black data " Margin="0 0 10 0" BorderBrush="{StaticResource TransparentBackgroundBrush200}" BorderThickness="1 1 0.8 2" > + <TextBlock FontSize="14" Foreground="{StaticResource MainWindow.Foreground}">IMPORT DATA</TextBlock> + </Button> + <TextBlock VerticalAlignment="Center" HorizontalAlignment="Left" Margin="20 4 0 0" FontSize="16" Padding="0">LIQUID TYPE BLACK</TextBlock> + </DockPanel> + </Grid> + + </Border> + <Grid Grid.Row="1"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="1*"/> + <ColumnDefinition Width="Auto"/> + </Grid.ColumnDefinitions> + <ContentControl Name="blackChartsContent" ContentTemplate="{StaticResource chartsPanel}" Content="{Binding SelectedTab.BlackPlot}"/> + <ContentControl ContentTemplate="{StaticResource calibrationDataGrid}" Content="{Binding SelectedTab.BlackCalibrationData}" Grid.Column="1"/> + </Grid> + </DockPanel> + </UniformGrid> + </DockPanel> + </Grid> + </Grid> +</UserControl> 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 new file mode 100644 index 000000000..06bd67231 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorCalibrationView.xaml.cs @@ -0,0 +1,77 @@ +using OxyPlot.Wpf; +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.Controls.Primitives; +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; +using Tango.MachineStudio.ThreadExtensions.ViewModels; + +namespace Tango.MachineStudio.ThreadExtensions.Views +{ + /// <summary> + /// Interaction logic for ColorCalibrationView.xaml + /// </summary> + public partial class ColorCalibrationView : UserControl + { + 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; + if (grid != null && ((UniformGrid)grid).DataContext is ColorCalibrationViewVM) + { + ColorCalibrationViewVM vm = (ColorCalibrationViewVM)((UniformGrid)grid).DataContext; + ColorCalibrationTabVM selectedTab = vm.SelectedTab; + // var Plot = (cyanChartsContent as FrameworkElement).FindChild<Plot>("LABDataPlot"); + if (selectedTab != null) + { + selectedTab.CyanPlot.DataPlotControl = (cyanChartsContent as FrameworkElement).FindChild<Plot>("LABDataPlot"); + selectedTab.CyanPlot.LinearizationPlotControl = (cyanChartsContent as FrameworkElement).FindChild<Plot>("LinearizationPlot"); + selectedTab.MagentaPlot.DataPlotControl = (magentaChartsContent as FrameworkElement).FindChild<Plot>("LABDataPlot"); + selectedTab.MagentaPlot.LinearizationPlotControl = (magentaChartsContent as FrameworkElement).FindChild<Plot>("LinearizationPlot"); + selectedTab.YellowPlot.DataPlotControl = (yellowChartsContent as FrameworkElement).FindChild<Plot>("LABDataPlot"); + selectedTab.YellowPlot.LinearizationPlotControl = (yellowChartsContent as FrameworkElement).FindChild<Plot>("LinearizationPlot"); + selectedTab.BlackPlot.DataPlotControl = (blackChartsContent as FrameworkElement).FindChild<Plot>("LABDataPlot"); + selectedTab.BlackPlot.LinearizationPlotControl = (blackChartsContent as FrameworkElement).FindChild<Plot>("LinearizationPlot"); + + vm.IsViewLoaded = true; + } + } + } + } +} 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 bfb8a58d0..b46cb4cf9 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 @@ -58,6 +58,9 @@ <TabItem Header="TEST RESULTS" Margin="20 0 0 0" mahapps:ControlsHelper.HeaderFontSize="20" > <local:TestResultsView /> </TabItem> + <TabItem Header="COLOR CALIBRATION" Margin="20 0 0 0" mahapps:ControlsHelper.HeaderFontSize="20"> + <local:ColorCalibrationView/> + </TabItem> </TabControl> </Grid> </DockPanel> |
