/// <summary> /// Animates the <see cref="AreaSeries3D"/>. /// </summary> internal override void Animate() { // WPF-25124 Animation not working properly when resize the window. if (this.AnimationStoryboard != null) { AnimationStoryboard.Stop(); if (!this.canAnimate) { this.ResetAdornmentAnimationState(); return; } } this.AnimationStoryboard = new Storyboard(); foreach (AreaSegment3D segment in this.Segments) { var dblAnimationKeyFrames = new DoubleAnimationUsingKeyFrames(); var keyFrame = new SplineDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)), Value = this.ActualYAxis.VisibleRange.Start }; dblAnimationKeyFrames.KeyFrames.Add(keyFrame); keyFrame = new SplineDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(AnimationDuration), Value = this.Area.InternalSecondaryAxis.VisibleRange.End }; EasingDoubleKeyFrame ease = new EasingDoubleKeyFrame(); ease.Value = this.YValues.Max(); ease.KeyTime = this.AnimationDuration; ease.EasingFunction = new CircleEase(); var keySpline = new KeySpline { ControlPoint1 = new Point(0.64, 0.84), ControlPoint2 = new Point(0.67, 0.95) }; keyFrame.KeySpline = keySpline; dblAnimationKeyFrames.KeyFrames.Add(ease); dblAnimationKeyFrames.KeyFrames.Add(keyFrame); Storyboard.SetTargetProperty(dblAnimationKeyFrames, "AreaSegment3D.Y"); dblAnimationKeyFrames.EnableDependentAnimation = true; Storyboard.SetTarget(dblAnimationKeyFrames, segment); AnimationStoryboard.Children.Add(dblAnimationKeyFrames); } AnimationStoryboard.Begin(); }
/// <summary> /// Animates the series. /// </summary> internal override void Animate() { if (Segments.Count <= 0) { return; } // WPF-25124 Animation not working properly when resize the window. if (this.AnimationStoryboard != null) { AnimationStoryboard.Stop(); if (!this.canAnimate) { this.ResetAdornmentAnimationState(); return; } } this.AnimationStoryboard = new Storyboard(); ColumnSegment3D segment = null; var top = ActualYAxis.VisibleRange.End; foreach (ChartSegment columnsSegment in this.Segments) { if (columnsSegment is EmptyPointSegment) { continue; } segment = columnsSegment as ColumnSegment3D; var segmentTop = top < segment.Top ? top : segment.Top; if (double.IsNaN(segmentTop)) { continue; } var keyFrames = new DoubleAnimationUsingKeyFrames(); var keyFrame = new SplineDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)), Value = segment.Bottom }; keyFrames.KeyFrames.Add(keyFrame); keyFrame = new SplineDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(AnimationDuration), Value = segmentTop }; var keySpline = new KeySpline { ControlPoint1 = new Point(0.64, 0.84), ControlPoint2 = new Point(0.67, 0.95) }; keyFrame.KeySpline = keySpline; keyFrames.KeyFrames.Add(keyFrame); Storyboard.SetTargetProperty(keyFrames, "ColumnSegment3D.Top"); keyFrames.EnableDependentAnimation = true; Storyboard.SetTarget(keyFrames, segment); AnimationStoryboard.Children.Add(keyFrames); } AnimationStoryboard.Begin(); }
/// <summary> /// Gets the animation is active. /// </summary> /// <returns>Returns the animation state whether it is active or not.</returns> internal override bool GetAnimationIsActive() { return(this.AnimationStoryboard != null && AnimationStoryboard.GetCurrentState() == ClockState.Active); }
/// <summary> /// Animates the series. /// </summary> internal override void Animate() { int i = 0; // WPF-25124 Animation not working properly when resize the window. if (this.AnimationStoryboard != null) { AnimationStoryboard.Stop(); if (!this.canAnimate) { this.ResetAdornmentAnimationState(); return; } } this.AnimationStoryboard = new Storyboard(); foreach (LineSegment3D segment in this.Segments) { var dblAnimationKeyFrames = new DoubleAnimationUsingKeyFrames(); var min = YValues.Min(); var keyFrame = new SplineDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)), Value = double.IsNaN(min) ? YValues.Where(e => !double.IsNaN(e)).Min() : min }; dblAnimationKeyFrames.KeyFrames.Add(keyFrame); keyFrame = new SplineDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(AnimationDuration), Value = YValues.Max() }; var keySpline = new KeySpline { ControlPoint1 = new Point(0.64, 0.84), ControlPoint2 = new Point(0.67, 0.95) }; keyFrame.KeySpline = keySpline; dblAnimationKeyFrames.KeyFrames.Add(keyFrame); Storyboard.SetTargetProperty(dblAnimationKeyFrames, "LineSegment3D.Y"); dblAnimationKeyFrames.EnableDependentAnimation = true; Storyboard.SetTarget(dblAnimationKeyFrames, segment); AnimationStoryboard.Children.Add(dblAnimationKeyFrames); if (this.AdornmentsInfo != null) { double secondsPerPoint = AnimationDuration.TotalSeconds / YValues.Count; secondsPerPoint *= 2; foreach (FrameworkElement label in this.AdornmentsInfo.LabelPresenters) { DoubleAnimation keyFrames1 = new DoubleAnimation() { From = 0.5, To = 1, Duration = TimeSpan.FromSeconds(AnimationDuration.TotalSeconds / 2), BeginTime = TimeSpan.FromSeconds(i * secondsPerPoint) }; Storyboard.SetTargetProperty(keyFrames1, "(UIElement.Opacity)"); Storyboard.SetTarget(keyFrames1, label); AnimationStoryboard.Children.Add(keyFrames1); i++; } } } AnimationStoryboard.Begin(); }
/// <summary> /// Animates the series. /// </summary> internal override void Animate() { this.canAnimate = false; if (Segments.Count <= 0) { return; } // WPF-25124 Animation not working properly when resize the window. if (this.AnimationStoryboard != null) { AnimationStoryboard.Stop(); if (!this.canAnimate) { this.ResetAdornmentAnimationState(); return; } } this.AnimationStoryboard = new Storyboard(); StackingColumnSegment3D segment = null; int count = 0; var durationInSeconds = AnimationDuration.TotalSeconds; // stackingSeries.Count; foreach (ChartSegment stackingColumnSegment in this.Segments) { if (stackingColumnSegment is EmptyPointSegment) { continue; } segment = stackingColumnSegment as StackingColumnSegment3D; var segmentTop = segment.InternalTop; var segmentBottom = segment.InternalBottom; if (double.IsNaN(segmentTop) || double.IsNaN(segmentBottom)) { continue; } var keyFrames = new DoubleAnimationUsingKeyFrames { }; var keyFrame = new SplineDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)), Value = 0d }; keyFrames.KeyFrames.Add(keyFrame); keyFrame = new SplineDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(durationInSeconds)), Value = segmentTop }; var keySpline = new KeySpline { ControlPoint1 = new Point(0.64, 0.84), ControlPoint2 = new Point(0.67, 0.95) }; keyFrame.KeySpline = keySpline; keyFrames.KeyFrames.Add(keyFrame); Storyboard.SetTargetProperty(keyFrames, "ColumnSegment3D.Top"); keyFrames.EnableDependentAnimation = true; Storyboard.SetTarget(keyFrames, segment); AnimationStoryboard.Children.Add(keyFrames); keyFrames = new DoubleAnimationUsingKeyFrames { // BeginTime = TimeSpan.FromSeconds(beginTime) }; keyFrame = new SplineDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)), Value = 0d }; keyFrames.KeyFrames.Add(keyFrame); keyFrame = new SplineDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(durationInSeconds)), Value = segmentBottom }; keySpline = new KeySpline { ControlPoint1 = new Point(0.64, 0.84), ControlPoint2 = new Point(0.67, 0.95) }; keyFrame.KeySpline = keySpline; keyFrames.KeyFrames.Add(keyFrame); Storyboard.SetTargetProperty(keyFrames, "ColumnSegment3D.Bottom"); keyFrames.EnableDependentAnimation = true; Storyboard.SetTarget(keyFrames, segment); AnimationStoryboard.Children.Add(keyFrames); count++; } AnimationStoryboard.Begin(); }
/// <summary> /// Animates this instance. /// </summary> internal override void Animate() { PieSegment3D segment = null; // WPF-25124 Animation not working properly when resize the window. if (this.AnimationStoryboard != null && (this.animateCount <= Segments.Count)) { this.AnimationStoryboard = new Storyboard(); } else if (this.AnimationStoryboard != null) { AnimationStoryboard.Stop(); if (!this.canAnimate) { foreach (ChartSegment pieSegment in this.Segments) { segment = pieSegment as PieSegment3D; segment.ActualStartValue = (this.StartAngle < this.EndAngle) ? segment.StartValue : segment.EndValue; double value = (StartAngle < EndAngle) ? segment.EndValue - segment.StartValue : segment.StartValue - segment.EndValue; segment.ActualEndValue = value == 0 ? 0.1 : value; } return; } } else { this.AnimationStoryboard = new Storyboard(); } foreach (ChartSegment pieSegment in this.Segments) { this.animateCount++; if (pieSegment is EmptyPointSegment) { continue; } segment = pieSegment as PieSegment3D; var segmentStartAngle = segment.StartValue; var segmentEndAngle = segment.EndValue; var keyFrames = new DoubleAnimationUsingKeyFrames(); var keyFrame = new SplineDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)), Value = StartAngle }; keyFrames.KeyFrames.Add(keyFrame); keyFrame = new SplineDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(AnimationDuration), Value = (StartAngle < EndAngle) ? segmentStartAngle : segmentEndAngle }; var keySpline = new KeySpline { ControlPoint1 = new Point(0.64, 0.84), ControlPoint2 = new Point(0.67, 0.95) }; keyFrame.KeySpline = keySpline; keyFrames.KeyFrames.Add(keyFrame); Storyboard.SetTargetProperty(keyFrames, "PieSegment3D.ActualStartValue"); keyFrames.EnableDependentAnimation = true; Storyboard.SetTarget(keyFrames, segment); AnimationStoryboard.Children.Add(keyFrames); keyFrames = new DoubleAnimationUsingKeyFrames(); keyFrame = new SplineDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)), Value = 0 }; keyFrames.KeyFrames.Add(keyFrame); double value = (StartAngle < EndAngle) ? segmentEndAngle - segmentStartAngle : segmentStartAngle - segmentEndAngle; // rotate segment clocwise/counterclockwise; keyFrame = new SplineDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(AnimationDuration), Value = value == 0 ? 0.1 : value }; keySpline = new KeySpline { ControlPoint1 = new Point(0.64, 0.84), ControlPoint2 = new Point(0.67, 0.95) }; keyFrame.KeySpline = keySpline; keyFrames.KeyFrames.Add(keyFrame); Storyboard.SetTargetProperty(keyFrames, "PieSegment3D.ActualEndValue"); keyFrames.EnableDependentAnimation = true; Storyboard.SetTarget(keyFrames, segment); AnimationStoryboard.Children.Add(keyFrames); } AnimationStoryboard.Begin(); }
/// <summary> /// Animates the <see cref="ScatterSeries3D"/>. /// </summary> internal override void Animate() { int i = 0; Random rand = new Random(); // WPF-25124 Animation not working properly when resize the window. if (this.AnimationStoryboard != null) { AnimationStoryboard.Stop(); if (!this.canAnimate) { this.ResetAdornmentAnimationState(); return; } } this.AnimationStoryboard = new Storyboard(); ScatterSegment3D segment = null; foreach (ChartSegment scatterSegment in this.Segments) { if (scatterSegment is EmptyPointSegment) { continue; } segment = scatterSegment as ScatterSegment3D; if (double.IsNaN(segment.Y)) { continue; } int randomValue = Segments.IndexOf(segment) == 0 ? 0 : rand.Next(1, 20); TimeSpan beginTime = TimeSpan.FromMilliseconds(randomValue * 20); var dblAnimationKeyFrames = new DoubleAnimationUsingKeyFrames(); var keyFrame = new SplineDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)), Value = 0d }; dblAnimationKeyFrames.KeyFrames.Add(keyFrame); keyFrame = new SplineDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(AnimationDuration), Value = segment.ScatterHeight }; var keySpline = new KeySpline { ControlPoint1 = new Point(0.64, 0.84), ControlPoint2 = new Point(0.67, 0.95) }; keyFrame.KeySpline = keySpline; dblAnimationKeyFrames.KeyFrames.Add(keyFrame); Storyboard.SetTargetProperty(dblAnimationKeyFrames, "ScatterSegment3D.ScatterHeight"); dblAnimationKeyFrames.EnableDependentAnimation = true; Storyboard.SetTarget(dblAnimationKeyFrames, segment); AnimationStoryboard.Children.Add(dblAnimationKeyFrames); dblAnimationKeyFrames = new DoubleAnimationUsingKeyFrames(); keyFrame = new SplineDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)), Value = 0d }; dblAnimationKeyFrames.KeyFrames.Add(keyFrame); keyFrame = new SplineDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(AnimationDuration), Value = segment.ScatterWidth }; keySpline = new KeySpline { ControlPoint1 = new Point(0.64, 0.84), ControlPoint2 = new Point(0.67, 0.95) }; keyFrame.KeySpline = keySpline; dblAnimationKeyFrames.KeyFrames.Add(keyFrame); Storyboard.SetTargetProperty(dblAnimationKeyFrames, "ScatterSegment3D.ScatterWidth"); dblAnimationKeyFrames.EnableDependentAnimation = true; Storyboard.SetTarget(dblAnimationKeyFrames, segment); AnimationStoryboard.Children.Add(dblAnimationKeyFrames); if (this.AdornmentsInfo != null && AdornmentsInfo.ShowLabel) { UIElement label = this.AdornmentsInfo.LabelPresenters[i]; label.Opacity = 0; DoubleAnimation animation = new DoubleAnimation() { To = 1, From = 0, BeginTime = TimeSpan.FromSeconds(beginTime.TotalSeconds + (beginTime.Seconds * 90) / 100), Duration = TimeSpan.FromSeconds((AnimationDuration.TotalSeconds * 50) / 100) }; Storyboard.SetTargetProperty(animation, "FrameworkElement.Opacity"); Storyboard.SetTarget(animation, label); AnimationStoryboard.Children.Add(animation); } i++; } AnimationStoryboard.Begin(); }