Ejemplo n.º 1
0
        public double SnapToFrameIfRequired(double time)
        {
            double result;

            if (window.FrameSnap)
            {
                result = TimeUtility.FromFrames(TimeUtility.ToFrames(time, (double)window.FrameRate), (double)window.FrameRate);
            }
            else
            {
                result = time;
            }
            return(result);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }