aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters
diff options
context:
space:
mode:
authorAvi Levkovich <avi@twine-s.com>2018-02-20 16:45:00 +0200
committerAvi Levkovich <avi@twine-s.com>2018-02-20 16:45:00 +0200
commit6c208c90bc45aff4a7fa214356a42fe7757c5e6f (patch)
tree0d77bc6a0ecfbb53cf42c5462ee19212197ee1bd /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters
parentb0823127f152fe97a6e8fce29e427c7f3db9cf5a (diff)
parent1a573aaa346ec4b8bd58a0e35ab9df571a09b855 (diff)
downloadTango-6c208c90bc45aff4a7fa214356a42fe7757c5e6f.tar.gz
Tango-6c208c90bc45aff4a7fa214356a42fe7757c5e6f.zip
MERGE
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/BrushStopToOffsetValueConverter.cs52
-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/JobProgressToPositionConverter.cs43
-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/ObjectsNotEqualToBooleanConveter.cs30
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/OneToPercentConverter.cs23
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentLengthToWidthConverter.cs53
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToBrushConverter.cs48
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToBrushConverterMulti.cs53
-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
15 files changed, 663 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..96c44a5a0
--- /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 (stop.IsLast)
+ {
+ return 100d;
+ }
+ else if (stop.IsFirst)
+ {
+ 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/BrushStopToOffsetValueConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/BrushStopToOffsetValueConverter.cs
new file mode 100644
index 000000000..d78ef0c8e
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/BrushStopToOffsetValueConverter.cs
@@ -0,0 +1,52 @@
+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 BrushStopToOffsetValueConverter : 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;
+
+ if (stop != null && segment != null)
+ {
+ if (stop.IsLast)
+ {
+ return 100d;
+ }
+ else if (stop.IsFirst)
+ {
+ return 0d;
+ }
+ else
+ {
+ return stop.OffsetPercent;
+ }
+ }
+ else
+ {
+ return 0d;
+ }
+ }
+ catch
+ {
+ return 0d;
+ }
+ }
+
+ 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/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/JobProgressToPositionConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/JobProgressToPositionConverter.cs
new file mode 100644
index 000000000..9865b26f8
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/JobProgressToPositionConverter.cs
@@ -0,0 +1,43 @@
+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 JobProgressToPositionConverter : IMultiValueConverter
+ {
+ public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
+ {
+ try
+ {
+ Job job = values[0] as Job;
+
+ if (job != null)
+ {
+ double progress = System.Convert.ToDouble(values[1]);
+ double parentElementWidth = System.Convert.ToDouble(values[2]);
+
+ return (progress / job.Length) * parentElementWidth;
+ }
+ else
+ {
+ return 0d;
+ }
+ }
+ catch
+ {
+ return 0d;
+ }
+ }
+
+ 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/ObjectsNotEqualToBooleanConveter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/ObjectsNotEqualToBooleanConveter.cs
new file mode 100644
index 000000000..15bfd6add
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/ObjectsNotEqualToBooleanConveter.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+
+namespace Tango.MachineStudio.Developer.Converters
+{
+ public class ObjectsNotEqualToBooleanConveter : IMultiValueConverter
+ {
+ public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
+ {
+ try
+ {
+ return (values[0] != values[1]);
+ }
+ catch
+ {
+ return true;
+ }
+ }
+
+ 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/OneToPercentConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/OneToPercentConverter.cs
new file mode 100644
index 000000000..292de5cb4
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/OneToPercentConverter.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+
+namespace Tango.MachineStudio.Developer.Converters
+{
+ public class OneToPercentConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return System.Convert.ToDouble(value) * 100d;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return System.Convert.ToDouble(value) / 100d;
+ }
+ }
+}
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..b632d9d12
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentLengthToWidthConverter.cs
@@ -0,0 +1,53 @@
+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;
+
+ if (job != null && values[1] is double)
+ {
+ 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 0d;
+ }
+ }
+ else
+ {
+ return 0d;
+ }
+ }
+ catch
+ {
+ return 0d;
+ }
+ }
+
+ 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/SegmentToBrushConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToBrushConverter.cs
new file mode 100644
index 000000000..1ac498070
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToBrushConverter.cs
@@ -0,0 +1,48 @@
+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 System.Windows.Media;
+using Tango.Integration.Observables;
+
+namespace Tango.MachineStudio.Developer.Converters
+{
+ public class SegmentToBrushConverter : 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.OrderBy(x => x.StopIndex))
+ {
+ stops.Add(new GradientStop(stop.Color, stop.OffsetPercent / 100d));
+ }
+
+ LinearGradientBrush brush = new LinearGradientBrush();
+ brush.StartPoint = new Point(0,0);
+ brush.EndPoint = new Point(1, 0);
+
+ brush.GradientStops = stops;
+
+ return brush;
+ }
+ 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/SegmentToBrushConverterMulti.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToBrushConverterMulti.cs
new file mode 100644
index 000000000..41c1dd4df
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToBrushConverterMulti.cs
@@ -0,0 +1,53 @@
+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 System.Windows.Media;
+using Tango.Integration.Observables;
+
+namespace Tango.MachineStudio.Developer.Converters
+{
+ public class SegmentToBrushConverterMulti : 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.OrderBy(x => x.StopIndex))
+ {
+ stops.Add(new GradientStop(stop.Color, stop.OffsetPercent / 100d));
+ }
+
+ LinearGradientBrush brush = new LinearGradientBrush();
+ brush.StartPoint = new Point(0, 0);
+ brush.EndPoint = new Point(1, 0);
+
+ brush.GradientStops = stops;
+
+ return brush;
+ }
+
+ return null;
+ }
+ catch
+ {
+ return null;
+ }
+ }
+
+ 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..f28a0b594
--- /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.OrderBy(x => x.StopIndex))
+ {
+ 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..c50fbb06c
--- /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.OrderBy(x => x.StopIndex))
+ {
+ 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();
+ }
+ }
+}