Пример #1
0
        public static string TimeAsFrames(double timeValue, double frameRate, string format = "F2")
        {
            string result;

            if (TimeUtility.OnFrameBoundary(timeValue, frameRate))
            {
                result = TimeUtility.ToFrames(timeValue, frameRate).ToString();
            }
            else
            {
                result = TimeUtility.ToExactFrames(timeValue, frameRate).ToString(format);
            }
            return(result);
        }
Пример #2
0
        public static string TimeAsTimeCode(double timeValue, double frameRate, string format = "F2")
        {
            TimeUtility.ValidateFrameRate(frameRate);
            int    num  = (int)Math.Abs(timeValue);
            int    num2 = num / 3600;
            int    num3 = num % 3600 / 60;
            int    num4 = num % 60;
            string str  = (timeValue >= 0.0) ? string.Empty : "-";
            string str2;

            if (num2 > 0)
            {
                str2 = string.Concat(new string[]
                {
                    num2.ToString(),
                    ":",
                    num3.ToString("D2"),
                    ":",
                    num4.ToString("D2")
                });
            }
            else
            {
                if (num3 > 0)
                {
                    str2 = num3.ToString() + ":" + num4.ToString("D2");
                }
                else
                {
                    str2 = num4.ToString();
                }
            }
            int    totalWidth = (int)Math.Floor(Math.Log10(frameRate) + 1.0);
            string text       = (TimeUtility.ToFrames(timeValue, frameRate) - TimeUtility.ToFrames((double)num, frameRate)).ToString().PadLeft(totalWidth, '0');

            if (!TimeUtility.OnFrameBoundary(timeValue, frameRate))
            {
                string text2 = TimeUtility.ToExactFrames(timeValue, frameRate).ToString(format);
                int    num5  = text2.IndexOf('.');
                if (num5 >= 0)
                {
                    text = text + " [" + text2.Substring(num5) + "]";
                }
            }
            return(str + str2 + ":" + text);
        }
Пример #3
0
 public static bool OnFrameBoundary(double time, double frameRate)
 {
     return(TimeUtility.OnFrameBoundary(time, frameRate, Math.Max(time, 1.0) * frameRate * TimeUtility.kTimeEpsilon));
 }