private void fakePoint_PointDisplayedAction(object sender, RoutedEventArgs e) { // Animate from previous fake point to new real point var dbX = new DoubleAnimation(); dbX.From = fakePoint.Point.X - pointDiameter / 2; dbX.To = currentPoint.Point.X - pointDiameter / 2; dbX.Duration = TimeSpan.FromMilliseconds(PointTransitionDuration); dbX.AccelerationRatio = 0.4; dbX.DecelerationRatio = 0.4; var dbY = new DoubleAnimation(); dbY.From = fakePoint.Point.Y - pointDiameter / 2; dbY.To = currentPoint.Point.Y - pointDiameter / 2; dbY.Duration = TimeSpan.FromMilliseconds(PointTransitionDuration); dbY.AccelerationRatio = 0.4; dbY.DecelerationRatio = 0.4; dbY.Completed += fakePoint_Completed; // Start animations fakePoint.BeginAnimation(Canvas.LeftProperty, dbX); fakePoint.BeginAnimation(Canvas.TopProperty, dbY); fakePoint.RunScalePointAnimationReverse(); // At the same time, zoom out again.. }
private void AnimateBetweenPoints(object sender, RoutedEventArgs e) { // Get next point (to animate between) nextPoint = GetNextPoint(); if (nextPoint == null) { // All points displayed, raise event calibrationCompleted = true; var args1 = new RoutedEventArgs(); args1 = new RoutedEventArgs(CalibrationEndEvent, this); RaiseEvent(args1); } else { // Animate from previous to new point var calPointX = new DoubleAnimation(); calPointX.From = currentPoint.Point.X - pointDiameter / 2; calPointX.To = nextPoint.Point.X - pointDiameter / 2; calPointX.Duration = TimeSpan.FromMilliseconds(PointTransitionDuration); calPointX.AccelerationRatio = _acceleration; calPointX.DecelerationRatio = _deacceleration; var calPointY = new DoubleAnimation(); calPointY.From = currentPoint.Point.Y - pointDiameter / 2; calPointY.To = nextPoint.Point.Y - pointDiameter / 2; calPointY.Duration = TimeSpan.FromMilliseconds(PointTransitionDuration); calPointY.AccelerationRatio = _acceleration; calPointY.DecelerationRatio = _deacceleration; calPointX.Completed += AnimateBetweenPoints_Completed; // Start animations currentPoint.BeginAnimation(Canvas.LeftProperty, calPointX); currentPoint.BeginAnimation(Canvas.TopProperty, calPointY); currentPoint.RunScalePointAnimationReverse(); // At the same time, zoom out again.. } }