public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == null) { throw new ArgumentNullException("destinationType"); } if ((destinationType == typeof(string)) && (value is Vector4)) { Vector4 vector2 = (Vector4)value; return(MathTypeConverter.ConvertFromValues <float>(context, culture, new float[] { vector2.X, vector2.Y, vector2.Z, vector2.W })); } if ((destinationType == typeof(InstanceDescriptor)) && (value is Vector4)) { Vector4 vector = (Vector4)value; ConstructorInfo constructor = typeof(Vector4).GetConstructor(new Type[] { typeof(float), typeof(float), typeof(float), typeof(float) }); if (constructor != null) { return(new InstanceDescriptor(constructor, new object[] { vector.X, vector.Y, vector.Z, vector.W })); } } return(base.ConvertTo(context, culture, value, destinationType)); }
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == null) { throw new ArgumentNullException("destinationType"); } if ((destinationType == typeof(string)) && (value is Point)) { Point point2 = (Point)value; return(MathTypeConverter.ConvertFromValues <int>(context, culture, new int[] { point2.X, point2.Y })); } if ((destinationType == typeof(InstanceDescriptor)) && (value is Point)) { Point point = (Point)value; ConstructorInfo constructor = typeof(Point).GetConstructor(new Type[] { typeof(int), typeof(int) }); if (constructor != null) { return(new InstanceDescriptor(constructor, new object[] { point.X, point.Y })); } } return(base.ConvertTo(context, culture, value, destinationType)); }
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == null) { throw new ArgumentNullException("destinationType"); } if ((destinationType == typeof(string)) && (value is Color)) { Color color2 = (Color)value; return(MathTypeConverter.ConvertFromValues <byte>(context, culture, new byte[] { color2.R, color2.G, color2.B, color2.A })); } if ((destinationType == typeof(InstanceDescriptor)) && (value is Color)) { Color color = (Color)value; ConstructorInfo constructor = typeof(Color).GetConstructor(new Type[] { typeof(byte), typeof(byte), typeof(byte), typeof(byte) }); if (constructor != null) { return(new InstanceDescriptor(constructor, new object[] { color.R, color.G, color.B, color.A })); } } return(base.ConvertTo(context, culture, value, destinationType)); }