Example #1
0
        void Explosion(TFExplosion exp)
        {
            TF2Net.Data.Vector origin = new TF2Net.Data.Vector(exp.Origin);
            exp = null;

            IconsGrid.Dispatcher.InvokeAsync(() =>
            {
                Viewbox vb = new Viewbox();

                DoubleAnimation a;
                {
                    System.Windows.Shapes.Path explosion = new System.Windows.Shapes.Path();
                    explosion.Data = (Geometry)FindResource("ExplosionPath");
                    explosion.Fill = Brushes.Orange;
                    vb.Child       = explosion;

                    a = new DoubleAnimation(0, new Duration(TimeSpan.FromSeconds(0.75)));
                    explosion.BeginAnimation(OpacityProperty, a);
                }

                vb.Width  = 35;
                vb.Height = 35;

                Random r           = new Random();
                vb.RenderTransform = new RotateTransform(r.NextDouble() * 360, vb.Width / 2, vb.Height / 2);

                SetPosition(new Point(origin.X, origin.Y), vb);

                IconsGrid.Children.Add(vb);

                // Automatically remove the control
                new DispatcherTimer(a.Duration.TimeSpan + TimeSpan.FromSeconds(1), DispatcherPriority.Normal,
                                    (s, e) => IconsGrid.Children.Remove(vb),
                                    IconsGrid.Dispatcher);
            });
        }
Example #2
0
        /// <summary>
        /// Hides path created from points p1 and p2
        /// </summary>
        /// <param name="p1">From</param>
        /// <param name="p2">To</param>
        private void runShortenTailAnimation(Point p1, Point p2)
        {
            string data = "M " + p1.X.ToString() + " " + p1.Y.ToString() + " " + "L " + p2.X.ToString() + " " + p2.Y.ToString();

            PathFigureCollection pfc = ((PathFigureCollection)new PathFigureCollectionConverter().ConvertFromString(data));

            PathGeometry pathGeometry = new PathGeometry();
            pathGeometry.Figures = pfc;

            Path path = new Path();
            path.Data = pathGeometry;
            path.StrokeLineJoin = this.strokeLineJoin;
            path.StrokeThickness = this.strokeThickness;
            path.Fill = this.solidColorBrush;
            path.Stroke = this.solidColorBrush;

            this.addToCanvas(path);

            // We want to hide the line segment
            DoubleAnimation doubleAnimation = new DoubleAnimation(0.0, new Duration(TimeSpan.FromSeconds(this.hidingLength)));
            path.BeginAnimation(Path.OpacityProperty, doubleAnimation);
        }