From 5cda8b0a3ab579dd6f33b1cb19a1d295dc661d28 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 29 Jan 2018 18:45:10 +0200 Subject: Added gradient display of color Brush Stops. --- .../Converters/SegmentToGradientStopsConverter.cs | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToGradientStopsConverter.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters') 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..1588b7740 --- /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.DAL.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(); + } + } +} -- cgit v1.3.1