aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-01-30 20:38:49 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-01-30 20:38:49 +0200
commit2fa92ca3654ebb274482f9bad86231028d357e5a (patch)
tree2d5bbce513317f05f82726b74b0ad6cf78db96f6 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters
parentd3ba251f01ae987a14b6379e733a06dbcd77f9e4 (diff)
downloadTango-2fa92ca3654ebb274482f9bad86231028d357e5a.tar.gz
Tango-2fa92ca3654ebb274482f9bad86231028d357e5a.zip
Started working on job brush display.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/BrushStopToOffsetLimitConverter.cs2
-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/SegmentToGradientStopsConverterMulti.cs46
4 files changed, 129 insertions, 1 deletions
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
index 53efd50b8..62d678888 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/BrushStopToOffsetLimitConverter.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/BrushStopToOffsetLimitConverter.cs
@@ -37,7 +37,7 @@ namespace Tango.MachineStudio.Developer.Converters
}
else
{
- return 100;
+ return 100d;
}
}
catch
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/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();
+ }
+ }
+}