Example #1
0
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string s1   = (string)value;
            double num1 = double.NaN;

            culture = CultureInfo.CurrentCulture;
            string timeSeparator = culture.DateTimeFormat.TimeSeparator;
            int    length        = s1.IndexOf(timeSeparator, StringComparison.CurrentCulture);

            if (length < 0)
            {
                double result;
                if (double.TryParse(s1, NumberStyles.AllowDecimalPoint, (IFormatProvider)culture, out result) && !double.IsNaN(result) && !double.IsInfinity(result))
                {
                    num1 = TimelineView.SnapSeconds(result, this.snapToTimelineResolution && TimelineView.IsTimelineSnapping);
                }
            }
            else if (s1.IndexOf(timeSeparator, length + timeSeparator.Length, StringComparison.CurrentCulture) == -1)
            {
                string s2 = s1.Substring(0, length);
                if (length + timeSeparator.Length < s1.Length)
                {
                    string s3 = s1.Substring(length + timeSeparator.Length);
                    int    result1;
                    double result2;
                    if (s2 != null && s3 != null && (int.TryParse(s2, NumberStyles.None, (IFormatProvider)culture, out result1) && double.TryParse(s3, NumberStyles.AllowDecimalPoint, (IFormatProvider)culture, out result2)))
                    {
                        double num2 = result2 + 60.0 * (double)result1;
                        if (!double.IsNaN(num2) && !double.IsInfinity(num2))
                        {
                            num1 = TimelineView.SnapSeconds(num2, this.snapToTimelineResolution);
                        }
                    }
                }
            }
            return((object)num1);
        }