Ejemplo n.º 1
0
 private void PointAway(out double xMax, out double yMax, out double xMin, out double yMin)
 {
     xMax = XRange.Max();
     yMax = YValues.Max();
     xMin = XRange.Min();
     yMin = YValues.Min();
 }
Ejemplo n.º 2
0
        private void CalcGridSize()
        {
            var xmax = XValues.Max();
            var ymax = YValues.Max();
            var xmin = XValues.Min();
            var ymin = YValues.Min();

            // Calculate axis range
            var xrange = Math.Abs(xmax - xmin);
            var yrange = Math.Abs(ymax - ymin);

            if (xrange > yrange)
            {
                // Determine spacing with nx points grid
                Nx = 200;
                Dx = xrange / (Nx - 1);

                // Determine number of y grid so that the space is equal
                Ny = Convert.ToInt32(Math.Ceiling(yrange / Dx));
                Dy = yrange / (Ny - 1);
            }
            else
            {
                Ny = 200;
                Dy = yrange / (Ny - 1);

                Nx = Convert.ToInt32(Math.Ceiling(xrange / Dy));
                Dx = xrange / (Nx - 1);
            }
        }
Ejemplo n.º 3
0
        /// <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();
        }