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);
        }
예제 #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);
        }
예제 #3
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);
                }
            }

            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;
        }
예제 #4
0
        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;
        }