Beispiel #1
0
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            var    sValue = value as string;
            object retVal = null;

            if (sValue != null)
            {
                sValue = sValue.Trim();

                if (sValue.Length != 0)
                {
                    if (null == culture)
                    {
                        culture = CultureInfo.CurrentCulture;
                    }

                    string[] parms = sValue.Split(new char[] { culture.TextInfo.ListSeparator[0] });

                    if (parms.Length == 1)
                    {
                        float x = float.Parse(parms[0]);
                        retVal = new VECTOR2D(x, x);
                    }
                    else if (parms.Length == 2)
                    {
                        float x = float.Parse(parms[0]);
                        float y = float.Parse(parms[1]);

                        retVal = new VECTOR2D(x, y);
                    }
                }
            }
            else
            {
                retVal = ConvertFrom(context, culture, value);
            }

            return(retVal);
        }
Beispiel #2
0
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            var sValue = value as string;
            object retVal = null;

            if (sValue != null)
            {
                sValue = sValue.Trim();

                if (sValue.Length != 0)
                {
                    if (null == culture)
                        culture = CultureInfo.CurrentCulture;

                    string[] parms = sValue.Split(new char[] {culture.TextInfo.ListSeparator[0]});

                    if (parms.Length == 1)
                    {
                        float x = float.Parse(parms[0]);
                        retVal = new VECTOR2D(x, x);
                    }
                    else if (parms.Length == 2)
                    {
                        float x = float.Parse(parms[0]);
                        float y = float.Parse(parms[1]);

                        retVal = new VECTOR2D(x, y);
                    }
                }
            }
            else
                retVal = ConvertFrom(context, culture, value);

            return retVal;
        }