aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2019-10-03 10:04:11 +0300
committerShlomo Hecht <shlomo@twine-s.com>2019-10-03 10:04:11 +0300
commit2ccc5a2e78f306d3c434c764e34509d4db92d8d8 (patch)
tree399f8c061fa698c36d06da9ebc101d65b02df26e /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels
parentb9e2c008322ce474ce6e0b18da9a786c128de8d9 (diff)
parenta6496a02892d653a70bc9e0d37856b1a7d3cd74b (diff)
downloadTango-2ccc5a2e78f306d3c434c764e34509d4db92d8d8.tar.gz
Tango-2ccc5a2e78f306d3c434c764e34509d4db92d8d8.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/ColorConversionViewVM.cs9
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs95
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/RgbVM.cs6
3 files changed, 103 insertions, 7 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/ColorConversionViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/ColorConversionViewVM.cs
index 735f75ab0..b68239b4b 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/ColorConversionViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/ColorConversionViewVM.cs
@@ -19,7 +19,7 @@ using Tango.SharedUI;
namespace Tango.MachineStudio.RML.ViewModels
{
- public class ColorConversionViewVM: ViewModel
+ public class ColorConversionViewVM : ViewModel
{
#region properties
@@ -265,7 +265,9 @@ namespace Tango.MachineStudio.RML.ViewModels
IColorConverter converter = new DefaultColorConverter();
- var output = converter.Convert(input);
+ input.GenerateHive = true;
+
+ var output = converter.Convert(input, RML.ColorConversionVersion);
IsOutOfGamut = output.OutOfGamut;
@@ -327,6 +329,7 @@ namespace Tango.MachineStudio.RML.ViewModels
ConversionInput input = new ConversionInput();
input.ColorSpace = PMR.ColorLab.ColorSpace.Volume;
input.ForwardData = ByteString.CopyFrom(CCT.Data);
+ input.GenerateHive = false;
input.InputCoordinates = new InputCoordinates();
input.ThreadL = RML.WhitePointL;
@@ -361,7 +364,7 @@ namespace Tango.MachineStudio.RML.ViewModels
IColorConverter converter = new DefaultColorConverter();
- var output = converter.Convert(input);
+ var output = converter.Convert(input, RML.ColorConversionVersion);
if (SourceColor.IsLab)
{
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs
index 361608ef6..a76799881 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs
@@ -20,6 +20,7 @@ using Tango.MachineStudio.RML.Models;
using Tango.MachineStudio.RML.Views;
using Tango.PMR.ColorLab;
using System.Data.Entity;
+using Tango.Core.ExtensionMethods;
namespace Tango.MachineStudio.RML.ViewModels
{
@@ -178,11 +179,14 @@ namespace Tango.MachineStudio.RML.ViewModels
public RelayCommand SaveCommand { get; set; }
+ public RelayCommand CloneRmlCommand { get; set; }
+
public MainViewVM(INotificationProvider notificationProvider)
{
_notification = notificationProvider;
ManageRmlCommand = new RelayCommand(() => LoadActiveRML(SelectedRML.Guid), () => SelectedRML != null);
- RemoveRmlCommand = new RelayCommand(RemoveSelectedRml);
+ RemoveRmlCommand = new RelayCommand(RemoveSelectedRml, () => SelectedRML != null);
+ CloneRmlCommand = new RelayCommand(CloneSelectedRml, () => SelectedRML != null);
AddRmlCommand = new RelayCommand(AddNewRml);
BackToRmlsCommand = new RelayCommand(BackToRmls, () => IsFree);
AddProcessParametersTableCommand = new RelayCommand(AddProcessParametersTable, () => IsFree);
@@ -208,6 +212,27 @@ namespace Tango.MachineStudio.RML.ViewModels
_rmls_context = ObservablesContext.CreateDefault();
Rmls = await new RmlsCollectionBuilder(_rmls_context).SetAll().WithLiquidFactors().WithMediaProperties().BuildAsync();
+
+ //Load CCT file names...
+ var ccts = await _rmls_context.Ccts.Select(x => new
+ {
+ x.Guid,
+ x.FileName
+ }).ToListAsync();
+
+ foreach (var rml in Rmls)
+ {
+ var cct = ccts.SingleOrDefault(x => x.Guid == rml.CctGuid);
+
+ if (cct != null)
+ {
+ rml.Cct = new Cct()
+ {
+ Guid = cct.Guid,
+ FileName = cct.FileName,
+ };
+ }
+ }
}
private async void LoadActiveRML(String guid)
@@ -422,6 +447,74 @@ namespace Tango.MachineStudio.RML.ViewModels
}
}
+ private async void CloneSelectedRml()
+ {
+ String name = _notification.ShowTextInput("Enter thread name", "thread name");
+
+ if (!String.IsNullOrWhiteSpace(name))
+ {
+ using (_notification.PushTaskItem("Cloning thread..."))
+ {
+ try
+ {
+ IsFree = false;
+
+ using (var context = ObservablesContext.CreateDefault())
+ {
+ var rml = await new RmlBuilder(context).Set(SelectedRML.Guid).WithActiveParametersGroup().WithLiquidFactors().BuildAsync();
+
+ Rml cloned = new Rml();
+ rml.MapPrimitivesWithStrings(cloned);
+
+ cloned.Code = Rmls.Max(x => x.Code) + 1;
+ cloned.Guid = Guid.NewGuid().ToString();
+ cloned.ID = 0;
+ cloned.Name = name;
+
+ ProcessParametersTablesGroup group = new ProcessParametersTablesGroup();
+ group.Name = rml.GetActiveProcessGroup().Name;
+ group.Active = true;
+
+ foreach (var p in rml.GetActiveProcessGroup().ProcessParametersTables)
+ {
+ var pc = new ProcessParametersTable();
+ p.MapPrimitivesTo(pc);
+ pc.Name = p.Name;
+
+ group.ProcessParametersTables.Add(pc);
+ }
+
+ cloned.ProcessParametersTablesGroups.Add(group);
+
+ foreach (var liquidFactor in rml.LiquidTypesRmls)
+ {
+ LiquidTypesRml l = new LiquidTypesRml();
+ l.DefaultCatData = liquidFactor.DefaultCatData;
+ l.LiquidType = liquidFactor.LiquidType;
+ l.MaxNlPerCm = liquidFactor.MaxNlPerCm;
+ cloned.LiquidTypesRmls.Add(l);
+ }
+
+ context.Rmls.Add(cloned);
+ await context.SaveChangesAsync();
+ }
+
+ LoadRmls();
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "Error cloning thread.");
+ _notification.ShowError($"An error occurred while trying to clone the selected thread\n{ex.Message}");
+ }
+ finally
+ {
+ IsFree = true;
+ }
+ }
+
+ }
+ }
+
private void AddProcessParametersTable()
{
var name = _notification.ShowTextInput("Enter table name", "Name");
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/RgbVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/RgbVM.cs
index 18e6d4fca..e8b8cbe86 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/RgbVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/RgbVM.cs
@@ -106,9 +106,9 @@ namespace Tango.MachineStudio.RML.ViewModels
{
Lab lab = new Lab(L, A, B);
Rgb rgb = lab.To<Rgb>();
- _red = rgb.R;
- _green = rgb.G;
- _blue = rgb.B;
+ _red = (int)rgb.R;
+ _green = (int)rgb.G;
+ _blue = (int)rgb.B;
}
_color = Color.FromRgb((byte)Red, (byte)Green, (byte)Blue);