Ejemplo n.º 1
0
        public static BaseAngle TryParse(string s)
        {
            if (s[0] == 'd')
            {
                var b = new DegreeAngle();
                b.value = double.Parse(s.Substring(1), NumberFormatInfo.InvariantInfo);
                return(b);
            }

            return(null);
        }
Ejemplo n.º 2
0
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null)
            {
                return(DependencyProperty.UnsetValue);
            }

            string s = value as string;

            if (s == "")
            {
                return(DependencyProperty.UnsetValue);
            }

            BaseAngle val = null;

            val = DegreeAngle.TryParse(s);
            if (val == null)
            {
                val = RadAngle.TryParse(s);
            }
            if (val == null)
            {
                val = MilAngle.TryParse(s);
            }
            if (val == null)
            {
                double d;
                if (double.TryParse(s, NumberStyles.Float, NumberFormatInfo.InvariantInfo, out d))
                {
                    val = BaseAngle.Create <MilAngle>(double.Parse(s, NumberFormatInfo.InvariantInfo));
                }
            }

            if (val == null)
            {
                return(DependencyProperty.UnsetValue);
            }
            else
            {
                return(val);
            }
        }