private DoubleAnimationUsingKeyFrames CreateXFrames(double beginTime, object target, params double[] values) { var frames = new DoubleAnimationUsingKeyFrames { BeginTime = TimeSpan.FromMilliseconds(beginTime) }; frames.SetCurrentValue(Storyboard.TargetPropertyProperty, new PropertyPath("(Canvas.Left)")); frames.SetCurrentValue(Storyboard.TargetProperty, target); var progressBarEaseOut = new ExponentialEase { EasingMode = EasingMode.EaseOut, Exponent = 2d }; var progressBarEaseIn = new ExponentialEase { EasingMode = EasingMode.EaseIn, Exponent = 2d }; StoreKeyFrame(0, new LinearDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0)), Value = values[0] }, frames); StoreKeyFrame(1, new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(500)), Value = values[1], EasingFunction = progressBarEaseOut }, frames); StoreKeyFrame(2, new LinearDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(2000)), Value = values[2] }, frames); StoreKeyFrame(3, new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(2500)), Value = values[3], EasingFunction = progressBarEaseIn }, frames); return(frames); }
private DoubleAnimationUsingKeyFrames CreateOpacityFrames(double beginTime, object target) { var frames = new DoubleAnimationUsingKeyFrames { BeginTime = TimeSpan.FromMilliseconds(beginTime) }; frames.SetCurrentValue(Storyboard.TargetPropertyProperty, new PropertyPath(nameof(Opacity))); frames.SetCurrentValue(Storyboard.TargetProperty, target); StoreOpacityFrame(0, new DiscreteDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0)), Value = 1d }, frames); StoreOpacityFrame(1, new DiscreteDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(2500)), Value = 0d }, frames); return(frames); }