aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Converters/SegmentToGradientStopsConverter.cs
blob: e6206e268811e726df938068c1989dd2629694f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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.BL.Entities;

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();
        }
    }
}
n class="w"> ProtobufCMessage*)message, buffer); } ConnectResponse * connect_response__unpack (ProtobufCAllocator *allocator, size_t len, const uint8_t *data) { return (ConnectResponse *) protobuf_c_message_unpack (&connect_response__descriptor, allocator, len, data); } void connect_response__free_unpacked (ConnectResponse *message, ProtobufCAllocator *allocator) { if(!message) return; assert(message->base.descriptor == &connect_response__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } static const ProtobufCFieldDescriptor connect_response__field_descriptors[1] = { { "DeviceInformation", 1, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ offsetof(ConnectResponse, deviceinformation), &device_information__descriptor, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; static const unsigned connect_response__field_indices_by_name[] = { 0, /* field[0] = DeviceInformation */ }; static const ProtobufCIntRange connect_response__number_ranges[1 + 1] = { { 1, 0 }, { 0, 1 } }; const ProtobufCMessageDescriptor connect_response__descriptor = { PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "ConnectResponse", "ConnectResponse", "ConnectResponse", "", sizeof(ConnectResponse), 1, connect_response__field_descriptors, connect_response__field_indices_by_name, 1, connect_response__number_ranges, (ProtobufCMessageInit) connect_response__init, NULL,NULL,NULL /* reserved[123] */ };