예제 #1
0
파일: Log.cs 프로젝트: IvanSorokin/Tuto
        public static void Commit(MontageAction action)
        {

            var now = DateTime.Now;
           
            var time = (int)(now - recordStartTime).TotalMilliseconds;
            var cmd = new MontageCommand
            {
                Action = action,
                Time = time,
                Id = Log.Id,
            };


            MontageCommandIO.AppendCommand(cmd, FileName);
            Id++;

            if (action == MontageAction.Commit)
            {
                goodSplitTime += now - lastCommitTime;
            }

            if (action == MontageAction.CommitAndSplit)
            {
                goodStartTime += goodSplitTime;
                goodSplitTime = new TimeSpan();
            }

            lastCommitTime = now;

        }
예제 #2
0
 public static void AppendCommand(MontageCommand command, string filename)
 {
     using (var writer = new StreamWriter(filename, true))
     {
         WriteCommand(writer, command);
     }
 }
예제 #3
0
 static void WriteCommand(StreamWriter writer, MontageCommand command)
 {
     writer.WriteLine(command.Id.ToString());
     writer.WriteLine(command.Time.ToString());
     writer.WriteLine(command.Action.ToString());
     writer.WriteLine();
 }
예제 #4
0
 static void WriteCommand(StreamWriter writer, MontageCommand command)
 {
     writer.WriteLine(command.Id.ToString());
     writer.WriteLine(command.Time.ToString());
     writer.WriteLine(command.Action.ToString());
     writer.WriteLine();
 }
예제 #5
0
 public static void AppendCommand(MontageCommand command, string filename)
 {
     using (var writer = new StreamWriter(filename, true))
     {
         WriteCommand(writer, command);
     }
 }
예제 #6
0
파일: ModelIO.cs 프로젝트: IvanSorokin/Tuto
        static void ExportV0(DirectoryInfo rootFolder, DirectoryInfo videoFolder, MontageModelV4 model)
        {
            File.WriteAllLines(videoFolder.FullName+"\\titles.txt", model.Information.Episodes.Select(z => z.Name).Where(z => z != null).ToArray(), Encoding.UTF8);

            var file = videoFolder.FullName+"\\log.txt";
            MontageCommandIO.Clear(file);
            MontageCommandIO.AppendCommand(new MontageCommand { Action = MontageAction.StartFace, Id = 1, Time = 0 }, file);
            MontageCommandIO.AppendCommand(new MontageCommand { Action = MontageAction.StartScreen, Id = 2, Time = model.Shift }, file);
            int id = 3;

            var list = model.Chunks.ToList();
            list.Add(new ChunkDataV4
            {
                StartTime = list[list.Count - 1].StartTime + list[list.Count - 1].Length,
                Length = 0,
                Mode = Mode.Undefined
            });

            var oldMode = Mode.Drop;

            for (int i = 0; i < list.Count; i++)
            {
                var e = list[i];
                bool newEp = false;
                if (e.Mode != oldMode || e.StartsNewEpisode || i == list.Count - 1)
                {
                    var cmd = new MontageCommand();
                    cmd.Id = id++;
                    cmd.Time = e.StartTime;
                    switch (oldMode)
                    {
                        case Mode.Drop: cmd.Action = MontageAction.Delete; break;
                        case Mode.Face: cmd.Action = MontageAction.Commit; break;
                        case Mode.Screen: cmd.Action = MontageAction.Commit; break;
                        case Mode.Undefined: cmd.Action = MontageAction.Delete; break;
                    }
                    MontageCommandIO.AppendCommand(cmd, file);
                    oldMode = e.Mode;
                    newEp = true;
                }
                if (e.StartsNewEpisode)
                {
                    MontageCommandIO.AppendCommand(
                        new MontageCommand { Id = id++, Action = MontageAction.CommitAndSplit, Time = e.StartTime },
                        file
                        );
                    newEp = true;
                }
                if (newEp)
                {
                    if (e.Mode == Mode.Face || e.Mode == Mode.Screen)
                    {
                        var cmd = new MontageCommand();
                        cmd.Id = id++;
                        cmd.Time = e.StartTime;
                        switch (e.Mode)
                        {
                            case Mode.Face: cmd.Action = MontageAction.Face; break;
                            case Mode.Screen: cmd.Action = MontageAction.Screen; break;
                        }
                        MontageCommandIO.AppendCommand(cmd, file);
                    }

                }

            }
        }