private static bool Run(Storyboard storyboard, ChartSeries series, Action completed = null)
        {
            if (storyboard.Children.Count == 0)
            {
                return(false);
            }

            storyboard.Completed += (s, e) =>
            {
                storyboard.Stop();

                lock (locker)
                {
                    int count = (int)series.GetValue(ChartAnimationUtilities.RunningAnimationsCountProperty);
                    count--;
                    series.SetValue(ChartAnimationUtilities.RunningAnimationsCountProperty, count);
                }

                if (completed != null)
                {
                    completed();
                }
            };

            storyboard.Begin();
            lock (locker)
            {
                int count = (int)series.GetValue(ChartAnimationUtilities.RunningAnimationsCountProperty);
                count++;
                series.SetValue(ChartAnimationUtilities.RunningAnimationsCountProperty, count);
            }

            return(true);
        }
Example #2
0
        private static bool TryRunSeriesAnimation(ChartSeries series)
        {
            if (!HasDataPointsInPlotRange(series))
            {
                return(false);
            }

            int count = (int)series.GetValue(ChartAnimationUtilities.RunningAnimationsCountProperty);

            if (count > 0)
            {
                return(false);
            }

            bool started = false;

            CartesianSeries cartesianSeries = series as CartesianSeries;

            if (cartesianSeries != null)
            {
                CartesianAnimation animation = GetCartesianAnimation(cartesianSeries);
                if (animation == CartesianAnimation.Drop || animation == CartesianAnimation.DropWithDelay)
                {
                    bool useDelay = animation == CartesianAnimation.DropWithDelay;
                    started |= TryRunDropAnimtation(cartesianSeries, useDelay);
                }
                if (animation == CartesianAnimation.Rise || animation == CartesianAnimation.RiseWithDelay)
                {
                    bool useDelay = animation == CartesianAnimation.RiseWithDelay;
                    started |= TryRunRiseAnimtation(cartesianSeries, useDelay);
                }
                if (animation == CartesianAnimation.Stretch)
                {
                    started |= TryRunStretchAnimtation(cartesianSeries);
                }
                if (animation == CartesianAnimation.StackedBars)
                {
                    started |= TryRunStackedBarsAnimtation(cartesianSeries);
                }
            }


            return(started);
        }
        private static bool TryRunSeriesAnimation(ChartSeries series)
        {
            if (!HasDataPointsInPlotRange(series))
            {
                return false;
            }

            int count = (int)series.GetValue(ChartAnimationUtilities.RunningAnimationsCountProperty);
            if (count > 0)
            {
                return false;
            }

            bool started = false;

            CartesianSeries cartesianSeries = series as CartesianSeries;
            if (cartesianSeries != null)
            {
                CartesianAnimation animation = GetCartesianAnimation(cartesianSeries);
                if (animation == CartesianAnimation.Drop || animation == CartesianAnimation.DropWithDelay)
                {
                    bool useDelay = animation == CartesianAnimation.DropWithDelay;
                    started |= TryRunDropAnimtation(cartesianSeries, useDelay);
                }
                if (animation == CartesianAnimation.Rise || animation == CartesianAnimation.RiseWithDelay)
                {
                    bool useDelay = animation == CartesianAnimation.RiseWithDelay;
                    started |= TryRunRiseAnimtation(cartesianSeries, useDelay);
                }
                if (animation == CartesianAnimation.Stretch)
                {
                    started |= TryRunStretchAnimtation(cartesianSeries);
                }
            }

            PieSeries pieSeries = series as PieSeries;
            if (pieSeries != null)
            {
                PieAnimation animation = GetPieAnimation(pieSeries);
                if (animation.HasFlag(PieAnimation.RadiusFactor))
                {
                    started |= TryRunRadiusFactorAnimtation(pieSeries);
                }
                if (animation.HasFlag(PieAnimation.Slice))
                {
                    started |= TryRunSliceAnimtation(pieSeries);
                }
                if (animation.HasFlag(PieAnimation.StartAngle))
                {
                    started |= TryRunStartAngleAnimtation(pieSeries);
                }
                if (animation.HasFlag(PieAnimation.SweepAngle))
                {
                    started |= TryRunSweepAngleAnimtation(pieSeries);
                }
            }

            return started;
        }
        private static bool Run(Storyboard storyboard, ChartSeries series, Action completed = null)
        {
            if (storyboard.Children.Count == 0)
            {
                return false;
            }

            storyboard.Completed += (s, e) =>
            {
                storyboard.Stop();

                lock (locker)
                {
                    int count = (int)series.GetValue(ChartAnimationUtilities.RunningAnimationsCountProperty);
                    count--;
                    series.SetValue(ChartAnimationUtilities.RunningAnimationsCountProperty, count);
                }

                if (completed != null)
                {
                    completed();
                }
            };

            storyboard.Begin();
            lock (locker)
            {
                int count = (int)series.GetValue(ChartAnimationUtilities.RunningAnimationsCountProperty);
                count++;
                series.SetValue(ChartAnimationUtilities.RunningAnimationsCountProperty, count);
            }

            return true;
        }