public static AnimationFrameBase FrameForTimeAngle(int time,
                                                    AnimationFrameBase startKeyFrame,
                                                    AnimationFrameBase endKeyFrame)
 {
     Debug.WriteLine("Hey pal! You need to use a subclass of IFTTTAnimation.");
     return(startKeyFrame);
 }
        public void AddKeyFrame(AnimationFrameBase keyFrame)
        {
            Debug.WriteLine(string.Format("Add KeyFrame Time: {0}", keyFrame.Time));

            if (KeyFrames.Count() == 0)
            {
                KeyFrames.Add(keyFrame);
                return;
            }

            // because folks might add keyframes out of order, we have to sort here
            if (keyFrame.Time > ((AnimationFrameBase)KeyFrames.Last()).Time)
            {
                KeyFrames.Add(keyFrame);
            }
            else
            {
                for (int i = 0; i < KeyFrames.Count(); i++)
                {
                    if (keyFrame.Time < ((AnimationFrameBase)KeyFrames[i]).Time)
                    {
                        KeyFrames.Add(keyFrame);                        // TODO atIndex:i;
                        break;
                    }
                }
            }

            _timeline = new List <AnimationFrameBase>();
            for (int i = 0; i < KeyFrames.Count() - 1; i++)
            {
                AnimationFrameBase currentKeyFrame = KeyFrames[i];
                AnimationFrameBase nextKeyFrame    = KeyFrames[i + 1];

                for (int j = currentKeyFrame.Time + (i == 0 ? 0 : 1); j <= nextKeyFrame.Time; j++)
                {
                    var alphaFrame = FrameForTimeAlpha(j, currentKeyFrame, nextKeyFrame);
                    if (alphaFrame != null)
                    {
                        _timeline.Add(alphaFrame);
                    }

                    var angleFrame = FrameForTimeAngle(j, currentKeyFrame, nextKeyFrame);
                    if (angleFrame != null)
                    {
                        _timeline.Add(angleFrame);
                    }

                    var transform3DFrame = FrameForTime3D(j, currentKeyFrame, nextKeyFrame);
                    if (transform3DFrame != null)
                    {
                        _timeline.Add(transform3DFrame);
                    }

                    var colorFrame = FrameForTimeColor(j, currentKeyFrame, nextKeyFrame);
                    if (colorFrame != null)
                    {
                        _timeline.Add(colorFrame);
                    }

                    var transformFrame = FrameForTimeTransform(j, currentKeyFrame, nextKeyFrame);
                    if (transformFrame != null)
                    {
                        _timeline.Add(transformFrame);
                    }

                    var hideFrame = FrameForTimeHide(j, currentKeyFrame, nextKeyFrame);
                    if (hideFrame != null)
                    {
                        _timeline.Add(hideFrame);
                    }
                }
            }
            _startTime = ((AnimationFrameBase)KeyFrames[0]).Time;
        }
 public static AnimationFrameBase FrameForTimeHide(int time,
                                                   AnimationFrameBase startKeyFrame,
                                                   AnimationFrameBase endKeyFrame)
 {
     return(startKeyFrame);
 }