aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions
diff options
context:
space:
mode:
authorVictoria Plitt <Victoria.Plitt@twine-s.com>2022-01-19 16:00:37 +0200
committerVictoria Plitt <Victoria.Plitt@twine-s.com>2022-01-19 16:00:37 +0200
commitafdaadac0ddb76b5e905ef5eeda581ade4324f9b (patch)
treee19d3781fd639c721c8d40e9fa05886c1eb4b811 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions
parent981d893bcdd17e95f94859cb20cf413da6818df4 (diff)
downloadTango-afdaadac0ddb76b5e905ef5eeda581ade4324f9b.tar.gz
Tango-afdaadac0ddb76b5e905ef5eeda581ade4324f9b.zip
#5831 RML extension- Color shade window
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ColorShadesModel.cs42
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj10
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorCalibrationTabVM.cs12
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeTabVM.cs121
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorShadeViewVM.cs406
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs22
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorShadeView.xaml162
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorShadeView.xaml.cs28
8 files changed, 790 insertions, 13 deletions
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<ColorShadesDataItem> items, ref string errors)
+ {
+ items = null;
+ try
+ {
+ using (ExcelReader reader = new ExcelReader(fileName))
+ {
+ items = reader.GetDataByIndex<ColorShadesDataItem>("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 @@
<Compile Include="Excel\ColorParametrsExcelModel.cs" />
<Compile Include="Models\CalibrationPlotModel.cs" />
<Compile Include="Models\ColorLinearizationModel.cs" />
+ <Compile Include="Models\ColorShadesModel.cs" />
<Compile Include="Models\FactorTarget.cs" />
<Compile Include="Models\MachineModel.cs" />
<Compile Include="Models\PlotProperties.cs" />
@@ -111,6 +112,7 @@
<Compile Include="ViewModels\ColorCalibrationTabVM.cs" />
<Compile Include="ViewModels\ColorCalibrationViewVM.cs" />
<Compile Include="ViewModels\ColorParametersVewVM.cs" />
+ <Compile Include="ViewModels\ColorShadeTabVM.cs" />
<Compile Include="ViewModels\MainViewVM.cs" />
<Compile Include="ViewModels\TestResultsViewVM.cs" />
<Compile Include="ViewModels\TestResultViewVM.cs" />
@@ -123,6 +125,10 @@
<Compile Include="Views\ColorParametersView.xaml.cs">
<DependentUpon>ColorParametersView.xaml</DependentUpon>
</Compile>
+ <Compile Include="Views\ColorShadeView.xaml.cs">
+ <DependentUpon>ColorShadeView.xaml</DependentUpon>
+ </Compile>
+ <Compile Include="ViewModels\ColorShadeViewVM.cs" />
<Compile Include="Views\ComboboxEditable.xaml.cs">
<DependentUpon>ComboboxEditable.xaml</DependentUpon>
</Compile>
@@ -161,6 +167,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
+ <Page Include="Views\ColorShadeView.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
<Page Include="Views\ComboboxEditable.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
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<ColorLinearizationModel.LinearizationDataItem> items = new List<ColorLinearizationModel.LinearizationDataItem>();
- // 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<CalibrationDataPointVM> calibrationPoints = new List<CalibrationDataPointVM>();
- // 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;
+ /// <summary>
+ /// Gets or sets the name of the thread. Using in print
+ /// </summary>
+ 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;
+ /// <summary>
+ /// Gets or sets a value indicating whether this instance is selected.
+ /// </summary>
+ public bool IsSelected
+ {
+ get { return _isSelected; }
+ set { _isSelected = value; RaisePropertyChangedAuto(); }
+ }
+
+ private RmlExtensionColorShadesTest _rmlExtensionColorShadesTest;
+
+ public RmlExtensionColorShadesTest RmlExtensionColorShadesTest
+ {
+ get { return _rmlExtensionColorShadesTest; }
+ set
+ {
+ _rmlExtensionColorShadesTest = value;
+ RaisePropertyChangedAuto();
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets last points before save. Used in Save to remove points before save new.
+ /// </summary>
+ /// <value>
+ /// The removed points.
+ /// </value>
+ public List<RmlExtensionColorShadesTestsData> 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<ColorShadesModel.ColorShadesDataItem> 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<ColorShadeTabVM> _colorShadeTabs;
+
+ public ObservableCollection<ColorShadeTabVM> 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;
+ /// <summary>
+ /// Gets or sets the selected machine.
+ /// </summary>
+ public String SelectedMachineGUID
+ {
+ get { return _selectedMachineGuid; }
+ set
+ {
+ if (value != null && _selectedMachineGuid != value)
+ {
+ _selectedMachineGuid = 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 SaveCommand { get; set; }
+
+ public RelayCommand AddTabCommand { get; set; }
+
+ public RelayCommand<ColorShadeTabVM> RemoveTabCommand { get; set; }
+
+ public RelayCommand RenameTabCommand { get; set; }
+
+ #endregion
+
+ public ColorShadeViewVM(INotificationProvider notification, IActionLogManager actionLogManager)
+ {
+ _notification = notification;
+ _actionLogManager = actionLogManager;
+ ColorShadeTabs = new ObservableCollection<ColorShadeTabVM>();
+
+ SaveCommand = new RelayCommand(Save, () => IsFree);
+
+ AddTabCommand = new RelayCommand(() => AddNewTab());
+ RemoveTabCommand = new RelayCommand<ColorShadeTabVM>(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
+
+ /// <summary>
+ /// Removes the specified tab.
+ /// </summary>
+ /// <param name="tab">The tab.</param>
+ 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();
+ }
+ }
+
+ /// <summary>
+ /// Adds a new tab.
+ /// </summary>
+ 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;
+ }
+ }
+
+ /// <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 (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;
/// <summary>
/// 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 @@
+<UserControl x:Class="Tango.MachineStudio.ThreadExtensions.Views.ColorShadeView"
+ 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:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI"
+ xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls"
+ xmlns:autoCompleteMachine="clr-namespace:Tango.MachineStudio.Common.AutoComplete;assembly=Tango.MachineStudio.Common"
+ xmlns:local="clr-namespace:Tango.MachineStudio.ThreadExtensions.Views"
+ 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" Background="Transparent" d:DataContext="{d:DesignInstance Type=vm:ColorShadeViewVM, IsDesignTimeCreatable=False}" FontSize="16">
+
+ <UserControl.Resources>
+ <autoCompleteMachine:MachinesProvider x:Key="MachinesProvider" />
+ <converters:EnumToDescriptionConverter x:Key="EnumToDescriptionConverter" />
+
+ <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>
+
+ </UserControl.Resources>
+
+ <Grid x:Name="contentGrid" DataContext="{Binding ColorShadeViewVM}" >
+ <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>
+ </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">
+ <Border DockPanel.Dock="Top" Background="Transparent" 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.ImportColorsCommand}" 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 COLORS</TextBlock>
+ </Button>
+
+ </DockPanel>
+ </Grid>
+ </Border>
+ <DataGrid Margin="0 0 0 10" BorderBrush="Silver" BorderThickness="1" RowHeight="60" Background="{StaticResource TransparentBackgroundBrush}" AlternatingRowBackground="{StaticResource Transparent200}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" ItemsSource="{Binding SelectedTab.RmlExtensionColorShadesTest.RmlExtensionColorShadesTestsData}" IsReadOnly="False" >
+ <DataGrid.CellStyle>
+ <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>
+ <Setter Property="Padding" Value="4"></Setter>
+ <Setter Property="Margin" Value="0 0 0 0"></Setter>
+ </Style>
+ </DataGrid.CellStyle>
+ <DataGrid.Columns>
+ <DataGridTextColumn Header="Number" Binding="{Binding ColorNum}" Width="Auto" />
+ <DataGridTemplateColumn Header="Shade">
+ <DataGridTemplateColumn.CellTemplate>
+ <DataTemplate>
+ <Rectangle Fill="{Binding ColorBrush}"/>
+ </DataTemplate>
+ </DataGridTemplateColumn.CellTemplate>
+ </DataGridTemplateColumn>
+
+ <DataGridTextColumn Header="L" Binding="{Binding L}" Width="Auto" />
+ <DataGridTextColumn Header="A" Binding="{Binding A}" Width="140"/>
+ <DataGridTextColumn Header="B" Binding="{Binding B}" Width="Auto"/>
+ <DataGridTextColumn Header="C" Binding="{Binding C}" Width="Auto" />
+ <DataGridTextColumn Header="M" Binding="{Binding M}" Width="140"/>
+ <DataGridTextColumn Header="Y" Binding="{Binding Y}" Width="Auto"/>
+ <DataGridTextColumn Header="K" Binding="{Binding K}" Width="Auto" />
+ <DataGridTextColumn Header="TI" Binding="{Binding TI}" Width="140"/>
+ <DataGridTextColumn Header="L" Binding="{Binding LRes}" Width="Auto"/>
+ <DataGridTextColumn Header="A" Binding="{Binding ARes}" Width="Auto" />
+ <DataGridTextColumn Header="B" Binding="{Binding BRes}" Width="140"/>
+ <DataGridTextColumn Header="Delta E" Binding="{Binding DeltaE}" Width="Auto"/>
+ </DataGrid.Columns>
+ </DataGrid>
+ </DockPanel>
+ </Grid>
+ </Grid>
+</UserControl>
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
+{
+ /// <summary>
+ /// Interaction logic for ColorShadeView.xaml
+ /// </summary>
+ public partial class ColorShadeView : UserControl
+ {
+ public ColorShadeView()
+ {
+ InitializeComponent();
+ }
+ }
+}