public ShapeFrameIdPair RetrieveShapeForFrame(uint shapeId, int frameId) { ShapeFrameIdPair shapePairToReturn = null; ShapeIterations iterations = null; if (ShapeData.TryGetValue(shapeId, out iterations)) { // find the most recent shape that was used for this frame id for (int i = 0; i < iterations.Iterations.Count; ++i) { if (iterations.Iterations[i].FrameId == frameId) { shapePairToReturn = iterations.Iterations[i]; break; } else if (iterations.Iterations[i].FrameId < frameId) { shapePairToReturn = iterations.Iterations[i]; } else { // the frame is now higher than the target frame id so we should've found it by now as the list is sorted! break; } } } return(shapePairToReturn); }
public ShapeFrameIdPair AddNewShape(int frameId, BaseShape addedShape) { ShapeIterations iterations = new ShapeIterations(); ShapeFrameIdPair newPair = new ShapeFrameIdPair(frameId, addedShape); iterations.Iterations.Add(newPair); iterations.Iterations.Sort(); ShapeData.Add(addedShape.Id, iterations); return(newPair); }