void GenerateAnimation(PennerAnimationGeneratorDelegate pennerAnimator) { float startValue = 0; float stopValue = 300; float sec = 0; float completeDuration = 10; _animationBoard.ClearChildren(); List <double> calculatedValues = new List <double>(); while (sec < completeDuration) { double currentValue = pennerAnimator(sec, startValue, stopValue, completeDuration); //step 0.1 sec (100 ms), until complete at 5 sec sec += 0.1f; calculatedValues.Add(currentValue); //System.Console.WriteLine(currentValue.ToString()); } //create image box that present the results int j = calculatedValues.Count; for (int i = 0; i < j; ++i) { Box box = new Box(5, 5); box.SetLocation(5 * i, (int)calculatedValues[i]); _animationBoard.AddChild(box); } //----- //show animation Box sampleBox1 = new Box(600, 20); _animationBoard.AddChild(sampleBox1); sampleBox1.BackColor = PixelFarm.Drawing.Color.Red; int step = 0; UIPlatform.RegisterTimerTask(10, tim => { //animate the box sampleBox1.SetLocation(10, (int)calculatedValues[step]); if (step < j - 1) { step++; } else { //unregister and remove the task tim.Remove(); } }); }
public PennerAnimationInfo(string name, PennerAnimationGeneratorDelegate targetDel) { _name = name; _generatorDelegate = targetDel; }