aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2018-01-31 10:11:27 +0200
committerShlomo Hecht <shlomo@twine-s.com>2018-01-31 10:11:27 +0200
commitb55483f9f095b699728e0b587ceebfdf6409a48a (patch)
tree1d424d3fc9f75154ecae30806b952fdfb029fce9 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters
parente027cb9fdd17fe3be7bb2c385dc37061a7eea8bb (diff)
parent2fa92ca3654ebb274482f9bad86231028d357e5a (diff)
downloadTango-b55483f9f095b699728e0b587ceebfdf6409a48a.tar.gz
Tango-b55483f9f095b699728e0b587ceebfdf6409a48a.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/BrushStopCMYKToColorConverter.cs53
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/BrushStopLabToColorConverter.cs52
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/BrushStopToColorConverter.cs44
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/BrushStopToOffsetLimitConverter.cs54
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/DbRmlViewToEntityConverter.cs38
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/InkVolumeToLiquidRmlFactor.cs34
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/JobToColumnDefinitionsConverter.cs37
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentLengthToWidthConverter.cs45
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToGradientStopsConverter.cs41
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToGradientStopsConverterMulti.cs46
10 files changed, 444 insertions, 0 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/BrushStopCMYKToColorConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/BrushStopCMYKToColorConverter.cs
new file mode 100644
index 000000000..5bc163b18
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/BrushStopCMYKToColorConverter.cs
@@ -0,0 +1,53 @@
+using ColorMine.ColorSpaces;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+using System.Windows.Media;
+using Tango.Integration.Observables;
+
+namespace Tango.MachineStudio.Developer.Converters
+{
+ public class BrushStopCMYKToColorConverter : IMultiValueConverter
+ {
+ public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
+ {
+ try
+ {
+ Cmyk cmyk = new Cmyk();
+
+ cmyk.C = System.Convert.ToDouble(values[0]) / 100d;
+ cmyk.M = System.Convert.ToDouble(values[1]) / 100d;
+ cmyk.Y = System.Convert.ToDouble(values[2]) / 100d;
+ cmyk.K = System.Convert.ToDouble(values[3]) / 100d;
+
+ IRgb rgb = cmyk.ToRgb();
+
+ return Color.FromRgb((byte)rgb.R, (byte)rgb.G, (byte)rgb.B);
+ }
+ catch
+ {
+ return null;
+ }
+ }
+
+ public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
+ {
+ try
+ {
+ Color color = (Color)value;
+ Rgb rgb = new Rgb(color.R, color.G, color.B);
+ Cmyk cmyk = rgb.To<Cmyk>();
+
+ return new object[] { cmyk.C * 100, cmyk.M * 100, cmyk.Y * 100, cmyk.K * 100 };
+ }
+ catch
+ {
+ return null;
+ }
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/BrushStopLabToColorConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/BrushStopLabToColorConverter.cs
new file mode 100644
index 000000000..f3dc07d3e
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/BrushStopLabToColorConverter.cs
@@ -0,0 +1,52 @@
+using ColorMine.ColorSpaces;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+using System.Windows.Media;
+using Tango.Integration.Observables;
+
+namespace Tango.MachineStudio.Developer.Converters
+{
+ public class BrushStopLabToColorConverter : IMultiValueConverter
+ {
+ public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
+ {
+ try
+ {
+ Lab lab = new Lab();
+
+ lab.L = System.Convert.ToDouble(values[0]);
+ lab.A = System.Convert.ToDouble(values[1]);
+ lab.B = System.Convert.ToDouble(values[2]);
+
+ IRgb rgb = lab.ToRgb();
+
+ return Color.FromRgb((byte)rgb.R, (byte)rgb.G, (byte)rgb.B);
+ }
+ catch
+ {
+ return null;
+ }
+ }
+
+ public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
+ {
+ try
+ {
+ Color color = (Color)value;
+ Rgb rgb = new Rgb(color.R, color.G, color.B);
+ Lab cmyk = rgb.To<Lab>();
+
+ return new object[] { cmyk.L, cmyk.A, cmyk.B };
+ }
+ catch
+ {
+ return null;
+ }
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/BrushStopToColorConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/BrushStopToColorConverter.cs
new file mode 100644
index 000000000..33cd8cc78
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/BrushStopToColorConverter.cs
@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+using System.Windows.Media;
+using Tango.Integration.Observables;
+
+namespace Tango.MachineStudio.Developer.Converters
+{
+ public class BrushStopToColorConverter : IMultiValueConverter
+ {
+ public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
+ {
+ try
+ {
+ double r = System.Convert.ToDouble(values[0]);
+ double g = System.Convert.ToDouble(values[1]);
+ double b = System.Convert.ToDouble(values[2]);
+
+ return Color.FromRgb((byte)r, (byte)g, (byte)b);
+ }
+ catch
+ {
+ return null;
+ }
+ }
+
+ public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
+ {
+ try
+ {
+ Color color = (Color)value;
+ return new object[] { color.R, color.G, color.B };
+ }
+ catch
+ {
+ return null;
+ }
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/BrushStopToOffsetLimitConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/BrushStopToOffsetLimitConverter.cs
new file mode 100644
index 000000000..62d678888
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/BrushStopToOffsetLimitConverter.cs
@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+using Tango.Integration.Observables;
+
+namespace Tango.MachineStudio.Developer.Converters
+{
+ public class BrushStopToOffsetLimitConverter : IMultiValueConverter
+ {
+ public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
+ {
+ try
+ {
+ BrushStop stop = values[0] as BrushStop;
+ Segment segment = values[1] as Segment;
+ String sign = parameter.ToString();
+
+ if (stop != null && segment != null)
+ {
+
+ if (segment.BrushStops.IndexOf(stop) == segment.BrushStops.Count - 1)
+ {
+ return 100d;
+ }
+ else if (segment.BrushStops.IndexOf(stop) == 0)
+ {
+ return 0d;
+ }
+ else
+ {
+ return sign == "min" ? 0 : 100d;
+ }
+ }
+ else
+ {
+ return 100d;
+ }
+ }
+ catch
+ {
+ return 100d;
+ }
+ }
+
+ public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/DbRmlViewToEntityConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/DbRmlViewToEntityConverter.cs
new file mode 100644
index 000000000..1fe3e5ab0
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/DbRmlViewToEntityConverter.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+using Tango.Integration.Observables;
+using Tango.MachineStudio.Developer.ViewModels;
+
+namespace Tango.MachineStudio.Developer.Converters
+{
+ public class DbRmlViewToEntityConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value != null)
+ {
+ DBViewContextWrapper<Rml> db = value as DBViewContextWrapper<Rml>;
+ return db;
+ }
+
+ return null;
+
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value != null)
+ {
+ Rml entity = value as Rml;
+ return new DBViewContextWrapper<Rml>(entity);
+ }
+
+ return null;
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/InkVolumeToLiquidRmlFactor.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/InkVolumeToLiquidRmlFactor.cs
new file mode 100644
index 000000000..3b675d23e
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/InkVolumeToLiquidRmlFactor.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+using Tango.Integration.Observables;
+using static Tango.Integration.Observables.BrushStop;
+
+namespace Tango.MachineStudio.Developer.Converters
+{
+ //public class InkVolumeToLiquidRmlFactor : IMultiValueConverter
+ //{
+ // public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
+ // {
+ // InkVolume inkVolume = values[0] as InkVolume;
+ // Rml selectedRml = values[1] as Rml;
+
+ // if (inkVolume != null && selectedRml != null)
+ // {
+ // return inkVolume.GetLiquidMaxNanoliterPerCentimeter().ToString();
+ // }
+
+ // return String.Empty;
+ // }
+
+ // public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
+ // {
+ // throw new NotImplementedException();
+ // }
+ //}
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/JobToColumnDefinitionsConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/JobToColumnDefinitionsConverter.cs
new file mode 100644
index 000000000..ac6e53be8
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/JobToColumnDefinitionsConverter.cs
@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using Tango.Integration.Observables;
+
+namespace Tango.MachineStudio.Developer.Converters
+{
+ public class JobToColumnDefinitionsConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ Job job = value as Job;
+
+ List<ColumnDefinition> columns = new List<ColumnDefinition>();
+
+ double totalLength = job.Segments.Sum(x => x.Length);
+
+ foreach (var segment in job.Segments)
+ {
+ columns.Add(new ColumnDefinition() { Width = new GridLength(segment.Length / totalLength, GridUnitType.Star) });
+ }
+
+ return columns;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentLengthToWidthConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentLengthToWidthConverter.cs
new file mode 100644
index 000000000..959fb6410
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentLengthToWidthConverter.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Data;
+using Tango.Integration.Observables;
+
+namespace Tango.MachineStudio.Developer.Converters
+{
+ public class SegmentLengthToWidthConverter : IMultiValueConverter
+ {
+ public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
+ {
+ try
+ {
+ if (values.Length == 4)
+ {
+ Job job = values[0] as Job;
+ double jobLength = System.Convert.ToDouble(values[1]);
+ double elementWidth = System.Convert.ToDouble(values[2]);
+ double segmentLength = System.Convert.ToDouble(values[3]);
+ double totalLength = job.Length;
+
+ return (segmentLength / totalLength) * elementWidth;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ catch
+ {
+ return 0;
+ }
+ }
+
+ public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToGradientStopsConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToGradientStopsConverter.cs
new file mode 100644
index 000000000..37908c940
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToGradientStopsConverter.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+using System.Windows.Media;
+using Tango.Integration.Observables;
+
+namespace Tango.MachineStudio.Developer.Converters
+{
+ public class SegmentToGradientStopsConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ try
+ {
+ Segment segment = value as Segment;
+
+ GradientStopCollection stops = new GradientStopCollection();
+
+ foreach (var stop in segment.BrushStops)
+ {
+ stops.Add(new GradientStop(stop.Color, stop.OffsetPercent / 100d));
+ }
+
+ return stops;
+ }
+ catch
+ {
+ return null;
+ }
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToGradientStopsConverterMulti.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToGradientStopsConverterMulti.cs
new file mode 100644
index 000000000..68ff95a9c
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToGradientStopsConverterMulti.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+using System.Windows.Media;
+using Tango.Integration.Observables;
+
+namespace Tango.MachineStudio.Developer.Converters
+{
+ public class SegmentToGradientStopsConverterMulti : IMultiValueConverter
+ {
+ public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
+ {
+ try
+ {
+ Segment segment = values[0] as Segment;
+
+ if (segment != null)
+ {
+ GradientStopCollection stops = new GradientStopCollection();
+
+ foreach (var stop in segment.BrushStops)
+ {
+ stops.Add(new GradientStop(stop.Color, stop.OffsetPercent / 100d));
+ }
+
+ return stops;
+ }
+
+ return null;
+ }
+ catch
+ {
+ return null;
+ }
+ }
+
+ public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}