Inheritance: Timeline, IPointAnimation
コード例 #1
0
        public static void BeginAnimation(this DependencyObject obj, DependencyProperty property, PointAnimation animation)
        {
            animation.EnableDependentAnimation = true;

            if (property == MapBase.CenterPointProperty)
            {
                BeginAnimation(obj, "CenterPoint", animation);
            }
        }
コード例 #2
0
ファイル: ViewModel.cs プロジェクト: Inferis/drash-win8
        private void VisualizeGraph(RainData rainData, bool animated = true)
        {
            List<int> pointValues;
            if (rainData == null || rainData.Points == null)
                pointValues = new List<int>();
            else
                pointValues = rainData.Points.Take(25).Select(p => p.AdjustedValue).ToList();

            while (pointValues.Count < 25)
                pointValues.Add(pointValues.LastOrDefault());

            var path = GraphView.Data as PathGeometry;
            var graphSize = new Size(GraphContainer.ActualWidth, GraphContainer.ActualHeight);
            var step = graphSize.Width / Model.Entries;
            Func<int, double> xForIndex = idx => idx == 0 ? -2 : idx * step;

            var x = 0;
            var max = (graphSize.Height / 12.0 * 11.0) - 10;
            var allZeros = pointValues.Take(Model.Entries + 1).All(p => p == 0);
            var points = pointValues.Select(v => {
                var y = allZeros ? max - 20 : Math.Max(1, max - (v * max / 100));
                var p = new Point(xForIndex(x), y);
                x++;
                return p;
            }).ToList();
            points.Add(new Point(graphSize.Width + 2, points.Last().Y));
            points.Add(new Point(graphSize.Width + 2, graphSize.Height + 2));

            PathFigure figure;
            var startPoint = new Point(-2.0, graphSize.Height + 2);
            if (path == null) {
                path = new PathGeometry();
                figure = new PathFigure() { StartPoint = startPoint, IsClosed = true };
                path.Figures.Add(figure);
                foreach (var p in points) {
                    figure.Segments.Add(new LineSegment() { Point = p });
                }
                GraphView.Data = path;
            }

            var entriesAnimated = graphEntries != Model.Entries && graphEntries > 0 && Model.Entries > 0;
            if (entriesAnimated)
                UpdateEntriesImage();

            var ms300 = TimeSpan.FromMilliseconds(entriesAnimated ? 450 / Math.Abs(Model.Entries - graphEntries) : animated ? 300 : 0);
            graphEntries = Model.Entries;
            var storyboard = new Storyboard() { Duration = ms300 };


            figure = path.Figures[0];
            var anim = new PointAnimation() { Duration = ms300, To = startPoint, FillBehavior = FillBehavior.HoldEnd, EnableDependentAnimation = true };
            Storyboard.SetTarget(anim, figure);
            Storyboard.SetTargetProperty(anim, "StartPoint");
            storyboard.Children.Add(anim);

            for (var i = 0; i < points.Count; ++i) {
                anim = new PointAnimation() { Duration = ms300, To = points[i], FillBehavior = FillBehavior.HoldEnd, EnableDependentAnimation = true };
                Storyboard.SetTarget(anim, figure.Segments[i]);
                Storyboard.SetTargetProperty(anim, "Point");
                storyboard.Children.Add(anim);
            }

            var strokeAnim = new ColorAnimation() { Duration = ms300, FillBehavior = FillBehavior.HoldEnd, To = allZeros ? Colors.Transparent : graphStrokeColor, EnableDependentAnimation = true };
            Storyboard.SetTarget(strokeAnim, GraphView.Stroke);
            Storyboard.SetTargetProperty(strokeAnim, "Color");
            storyboard.Children.Add(strokeAnim);

            var fillTopAnim = new ColorAnimation() { Duration = ms300, FillBehavior = FillBehavior.HoldEnd, To = allZeros ? Colors.Black : graphFillFrom, EnableDependentAnimation = true };
            Storyboard.SetTarget(fillTopAnim, ((LinearGradientBrush)GraphView.Fill).GradientStops[0]);
            Storyboard.SetTargetProperty(fillTopAnim, "Color");
            storyboard.Children.Add(fillTopAnim);

            storyboard.Begin(() => GraphView.Data = path);
        }
コード例 #3
0
        void EndUpdateUI()
        {
            _animation.Completed -= Animation_Completed;
            _animation = new PointAnimation
            {
                From = Effect.EndPoint,
                To = FROM,
                Duration = REVERSE_DURATION
            };

            Animate(Effect);
        }
コード例 #4
0
        void BeginUpdateUI()
        {
            _animation = new PointAnimation
            {
                From = FROM,
                To = TO,
                Duration = _duration
            };

            _animation.Completed += Animation_Completed;

            Animate(Effect);
        }
コード例 #5
0
 public static PointAnimation CreatePoint(Point to, Duration duration, string targetProperty)
 {
     var animation = new PointAnimation
     {
         To = to,
         Duration = duration,
         EnableDependentAnimation = true
     };
     Storyboard.SetTargetProperty(animation, targetProperty);
     return animation;
 }
コード例 #6
0
 public static PointAnimation CreatePoint(Point from, Point to, Duration duration, string targetProperty)
 {
     var animation = new PointAnimation
     {
         From = from,
         To = to,
         Duration = duration
     };
     Storyboard.SetTargetProperty(animation, targetProperty);
     return animation;
 }