Esempio n. 1
0
        public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
        {
            if (VectorConversion.CanConvertTo(context, destinationType))
            {
                return(true);
            }
            if (destinationType == typeof(string))
            {
                return(true);
            }

            return(base.CanConvertTo(context, destinationType));
        }
Esempio n. 2
0
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            var vec = (Vector3)value;

            if (VectorConversion.CanConvertTo(context, destinationType))
            {
                var vec4 = new Vector4(vec.X, vec.Y, vec.Z, 0f);
                return(VectorConversion.ConvertToFromVector4(context, culture, vec4, destinationType));
            }

            if (destinationType == typeof(string))
            {
                var terms = new string[3];
                terms[0] = vec.X.ToString("R", culture);
                terms[1] = vec.Y.ToString("R", culture);
                terms[2] = vec.Z.ToString("R", culture);

                return(string.Join(culture.TextInfo.ListSeparator + " ", terms));
            }

            return(base.ConvertTo(context, culture, value, destinationType));
        }