diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-01-31 13:30:15 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-01-31 13:30:15 +0200 |
| commit | 80c023fa734d7788e155d4f311ab16220aa80650 (patch) | |
| tree | dc79c0689e00419c7f447d1b32716df99df8f278 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters | |
| parent | 2fa92ca3654ebb274482f9bad86231028d357e5a (diff) | |
| download | Tango-80c023fa734d7788e155d4f311ab16220aa80650.tar.gz Tango-80c023fa734d7788e155d4f311ab16220aa80650.zip | |
Job Brush working nicely.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters')
2 files changed, 101 insertions, 0 deletions
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..8aef260ff --- /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) + { + 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..0248fd730 --- /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) + { + 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(); + } + } +} |
