public Dictionary <string, SpriteJson> GetCurrentSprite() { Dictionary <string, SpriteJson> currentSprite = new Dictionary <string, SpriteJson>(); int closestKeyframeTo = -1; int closestKeyframeDistance = -1; if (KeyFrames.Count > 0) { for (int i = 0; i < KeyFrames.Count; i++) { int scrubberPos = (int)Math.Floor(_currentMs / 16); KeyFrame currentFrame = KeyFrames.ElementAt(i); bool isValid = true; if (currentFrame.TimelineX > scrubberPos) { isValid = false; } if (isValid) { if (closestKeyframeDistance == -1) { closestKeyframeDistance = Math.Abs(scrubberPos - KeyFrames.ElementAt(i).TimelineX); closestKeyframeTo = i; } else { if (Math.Abs(scrubberPos - KeyFrames.ElementAt(i).TimelineX) < closestKeyframeDistance) { closestKeyframeDistance = Math.Abs(scrubberPos - KeyFrames.ElementAt(i).TimelineX); closestKeyframeTo = i; } } } } } if (closestKeyframeTo >= 0 && KeyFrames.Count > 0) { KeyFrame originalKeyframe = KeyFrames.ElementAt(closestKeyframeTo); return(originalKeyframe.SpriteBoxes); } else { return(null); } }