public void TestLocation() { var array = new StreamChunk[] { new StreamChunk(0000,1000, Editor.Mode.Drop, false), new StreamChunk(1000,2000, Editor.Mode.Face, false), new StreamChunk(2000,3000, Editor.Mode.Drop, false), new StreamChunk(3000,4000, Editor.Mode.Screen, false), }; Assert.AreEqual(1500, SrtMaker.FindFinalLocation(3500, array)); }
public void FormPreparedChunks() { //Collapse adjacent chunks of same type into one FileChunk Montage.PreparedChunks = new List <StreamChunk>(); var activeChunks = Tokens.ToList(); if (!activeChunks.Any()) { return; } activeChunks.Add(new StreamChunk(activeChunks.Last().EndTime, activeChunks.Last().EndTime, Mode.Undefined, true)); var oldChunk = activeChunks[0]; for (var i = 1; i < activeChunks.Count; i++) { var currentChunk = activeChunks[i]; var prevChunk = activeChunks[i - 1]; // collect adjacent chunks starting with oldChunk if (!currentChunk.StartsNewEpisode && currentChunk.Mode == oldChunk.Mode) { continue; } // or flush adjacent chunks into one and start new sequence if (oldChunk.Length != 0 || oldChunk.Mode == Mode.Drop) { var preparedChunk = new StreamChunk( oldChunk.StartTime, prevChunk.EndTime, oldChunk.Mode, oldChunk.StartsNewEpisode ); Montage.PreparedChunks.Add(preparedChunk); } oldChunk = currentChunk; } }
protected IEnumerable<Rect> GetRects(StreamChunk chunk) { double SWidth = ActualWidth / msInRow; var start = chunk.StartTime; var length = chunk.Length; int x = start % msInRow; int y = start / msInRow; while (true) { if (x + length <= msInRow) { yield return new Rect(x * SWidth, y * RowHeight, length * SWidth, RowHeight); yield break; } yield return new Rect(x * SWidth, y * RowHeight, (msInRow - x) * SWidth, RowHeight); length -= (msInRow - x); x = 0; y++; } }