Ejemplo n.º 1
0
        private static void InfoActionHandler(Timecode.Timecode timecode, string[] opts)
        {
            switch (opts.Length)
            {
            case 0:
                break;

            case 1 when timecode.Version == TimecodeVersion.V1 && int.TryParse(opts[0], out var length):
                timecode.TotalFrames = length;
                break;

            default:
                PrintErrorAndHelp("Error: Too many arguments!");
                return;
            }

            Console.WriteLine(
                $" {"Total Length: ",-20}{timecode.TotalLength,-15:hh\\:mm\\:ss\\.fff}{"Total Frames: ",-20}{timecode.TotalFrames}");
            Console.WriteLine(
                $" {"Average Frame Rate: ",-20}{timecode.AverageFrameRate,-15:F3}{"Default Frame Rate: ",-20}{timecode.DefaultFrameRate:F3}");

            Console.WriteLine($"+{new string('-', 23)}+{new string('-', 23)}+{new string('-', 12)}+");
            Console.WriteLine($"| {"Start Frame / Time",21} | {"End Frame / Time",21} | {"Frame Rate",10} |");
            Console.WriteLine($"+{new string('-', 23)}+{new string('-', 23)}+{new string('-', 12)}+");
            foreach (var interval in timecode.IntervalList)
            {
                Console.WriteLine(
                    $"| {interval.StartFrame,6} / {timecode.GetTimeSpanFromFrameNumber(interval.StartFrame),-12:hh\\:mm\\:ss\\.fff} " +
                    $"| {interval.EndFrame,6} / {timecode.GetTimeSpanFromFrameNumber(interval.EndFrame),-12:hh\\:mm\\:ss\\.fff} " +
                    $"| {1e7 / interval.Interval,10:F6} |");
            }

            Console.WriteLine($"+{new string('-', 23)}+{new string('-', 23)}+{new string('-', 12)}+");
        }
Ejemplo n.º 2
0
        private static void QueryActionHandler(Timecode.Timecode timecode, string[] restOpts)
        {
            if (restOpts.Length == 0)
            {
                PrintErrorAndHelp("Error: Please provide at least one timespan/frame for querying!");
            }

            Console.WriteLine($"+{new string('-', 14)}+{new string('-', 14)}+");
            Console.WriteLine($"| {"Query",12} | {"Result",12} |");
            Console.WriteLine($"+{new string('-', 14)}+{new string('-', 14)}+");
            foreach (var opt in restOpts)
            {
                if (int.TryParse(opt, out var frame))
                {
                    Console.WriteLine(
                        $"| {frame,12} " +
                        $"| {timecode.GetTimeSpanFromFrameNumber(frame),12:hh\\:mm\\:ss\\.fff} |");
                }
                else if (TimeSpan.TryParse(opt, out var timeSpan))
                {
                    Console.WriteLine(
                        $"| {timeSpan,12:hh\\:mm\\:ss\\.fff} " +
                        $"| {timecode.GetFrameNumberFromTimeSpan(timeSpan),12} |");
                }
                else
                {
                    Console.WriteLine(
                        $"| {opt.Substring(0, Math.Min(opt.Length, 12)),12} " +
                        $"| {"Error!",12} |");
                }
            }

            Console.WriteLine($"+{new string('-', 14)}+{new string('-', 14)}+");
        }