Example #1
0
        private void UCImageBox_MouseLeave(object sender, MouseEventArgs e)
        {
            isMouseLeave = true;
            DoubleAnimation scale = new DoubleAnimation();

            scale.From     = 100;
            scale.To       = 0;
            scale.Duration = new Duration(TimeSpan.FromMilliseconds(100));
            myEllipseGeometry.BeginAnimation(EllipseGeometry.RadiusXProperty, scale);
            myEllipseGeometry.BeginAnimation(EllipseGeometry.RadiusYProperty, scale);
        }
Example #2
0
        //圆形展开******************************
        private void button1_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            EllipseGeometry ellipse = new EllipseGeometry(); //创建椭圆图形,但不显示
            double          cx      = this.image.Width / 2;  //image的宽、高不要设为自动
            double          cy      = this.image.Height / 2;

            ellipse.Center  = new Point(cx, cy);   //创建中心点,RadiusX默认为0
            this.image.Clip = ellipse;             //用ellipse对图片剪裁,开始的剪裁区域是0
            DoubleAnimation da = new DoubleAnimation();

            da.From     = 0;                                     //从中心点
            da.To       = Math.Max(cx * 2, cy * 2);
            da.Duration = new Duration(TimeSpan.Parse("0:0:6")); //动画时间
            ellipse.BeginAnimation(EllipseGeometry.RadiusXProperty, da);
            ellipse.BeginAnimation(EllipseGeometry.RadiusYProperty, da);
        }
Example #3
0
        private void Grid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            PointAnimation myPointAnimation = new PointAnimation(e.GetPosition(this), TimeSpan.FromSeconds(1));

            myEllipseGeometry.BeginAnimation(EllipseGeometry.CenterProperty, myPointAnimation);
            myPointAnimation.EasingFunction = new CircleEase();
        }
        protected void EventHandler(object sender, DependencyPropertyChangedEventArgs e)
        {
            //RegionManager при навигации сначала устанавливает содержимое в null, затем новое значение, поэтому событие может возникать 2 раза подряд
            if (e.NewValue == null)
            {
                return;
            }

            if (SkipFirstAnimation)
            {
                SkipFirstAnimation = false;
                return;
            }

            var elipseGeometry = new EllipseGeometry(Mouse.GetPosition(AnimatedElement), 0, 0);
            var point          = Mouse.GetPosition(AnimationParametersTargetElement);
            var x      = Math.Max(point.X, AnimationParametersTargetElement.ActualWidth - point.X);
            var y      = Math.Max(point.Y, AnimationParametersTargetElement.ActualHeight - point.Y);
            var radius = Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2));

            AnimatedElement.Clip = elipseGeometry;

            var duration = TimeSpan.FromMilliseconds(750);

            var ease = new ExponentialEase {
                EasingMode = EasingMode.EaseIn,
                Exponent   = 1.5
            };

            var animationOpacity = new DoubleAnimation(0, 1, duration);

            animationOpacity.EasingFunction = ease;
            AnimatedElement.BeginAnimation(UIElement.OpacityProperty, animationOpacity);

            var animationX = new DoubleAnimation(0, radius, duration);

            animationX.EasingFunction = ease;
            elipseGeometry.BeginAnimation(EllipseGeometry.RadiusXProperty, animationX);

            var animationY = new DoubleAnimation(0, radius, duration);

            animationY.EasingFunction = ease;
            animationY.Completed     += (sndr, args) => AnimatedElement.Clip = null;
            elipseGeometry.BeginAnimation(EllipseGeometry.RadiusYProperty, animationY);
        }
Example #5
0
        private static void AddPump(DrawingMapLayer animationLayer, Point pos, Brush stroke, Brush fill, double size, double strokeWidth, double pumpSize, double periord)
        {
            EllipseGeometry geometry = new EllipseGeometry(pos, size, size);
            GeometryDrawing drawing  = new GeometryDrawing(fill, new Pen(stroke, strokeWidth), geometry);

            //var mLayer = MapControl.Current.Layers.First(x => x.LayerData.Name == "城镇") as DrawingMapLayer;
            animationLayer.AddOverlayChildren(drawing);

            DoubleAnimationUsingKeyFrames animation = new DoubleAnimationUsingKeyFrames();

            animation.Duration       = new Duration(TimeSpan.FromMilliseconds(periord));
            animation.RepeatBehavior = RepeatBehavior.Forever;
            animation.KeyFrames.Add(new LinearDoubleKeyFrame(size, KeyTime.FromPercent(0)));
            animation.KeyFrames.Add(new LinearDoubleKeyFrame(pumpSize, KeyTime.FromPercent(0.1)));
            animation.KeyFrames.Add(new LinearDoubleKeyFrame(size, KeyTime.FromPercent(1)));

            geometry.BeginAnimation(EllipseGeometry.RadiusXProperty, animation);
            geometry.BeginAnimation(EllipseGeometry.RadiusYProperty, animation);
        }
        public void PointAnimationExample()
        {
            PointAnimation myPointAnimation = new PointAnimation
            {
                Duration = TimeSpan.FromSeconds(2),
                From     = new Point(200, 100),
                To       = new Point(450, 250)
            };

            myEllipseGeometry.BeginAnimation(EllipseGeometry.CenterProperty, myPointAnimation);
        }
        //圆形展开
        private void menuCircularDevelopment_Click(object sender, RoutedEventArgs e)
        {
            //创建椭圆图形,但不显示
            EllipseGeometry ellipse = new EllipseGeometry();
            //image的宽、高不要设为自动
            double cx = this.image.Width / 2;
            double cy = this.image.Height / 2;

            //创建中心点,RadiusX和radiusY默认为0,表示是一个圆形
            ellipse.Center = new Point(cx, cy);
            //用ellipse对图片剪裁,开始的剪裁区域是0
            this.image.Clip = ellipse;
            //在指定的时间内使用线性内插对两个目标值之间的double属性值进行动画处理
            DoubleAnimation da = new DoubleAnimation();

            da.From     = 0;                                     //从中心点
            da.To       = Math.Max(cx * 2, cy * 2);
            da.Duration = new Duration(TimeSpan.Parse("0:0:6")); //动画时间
            //将动画应用到指定的依赖属性,该动画在呈现下一帧时使用
            ellipse.BeginAnimation(EllipseGeometry.RadiusXProperty, da);
            ellipse.BeginAnimation(EllipseGeometry.RadiusYProperty, da);
        }
Example #8
0
        protected void Handler()
        {
            Application.Current.Dispatcher.Invoke(() =>
            {
                var center         = new Point(0, 0);
                var elipseGeometry = new EllipseGeometry(center, 0, 0);
                var x                = animationParametersTargetElement.ActualWidth;
                var y                = animationParametersTargetElement.ActualHeight;
                var radius           = Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2));
                animatedElement.Clip = elipseGeometry;

                var duration = TimeSpan.FromMilliseconds(1500);

                var ease = new ExponentialEase
                {
                    EasingMode = EasingMode.EaseIn,
                    Exponent   = 0.5
                };

                var animationOpacity            = new DoubleAnimation(0, 1, duration);
                animationOpacity.EasingFunction = ease;
                animatedElement.BeginAnimation(UIElement.OpacityProperty, animationOpacity);

                var ease2 = new ExponentialEase
                {
                    EasingMode = EasingMode.EaseIn,
                    Exponent   = 1.3
                };

                var animationX            = new DoubleAnimation(0, radius, duration);
                animationX.EasingFunction = ease2;
                elipseGeometry.BeginAnimation(EllipseGeometry.RadiusXProperty, animationX);

                var animationY            = new DoubleAnimation(0, radius, duration);
                animationY.EasingFunction = ease2;
                animationY.Completed     += (sndr, args) => animatedElement.Clip = null;
                elipseGeometry.BeginAnimation(EllipseGeometry.RadiusYProperty, animationY);
            });
        }
Example #9
0
        public override void ApplyFluidTheme(IDataFluidTheme theme)
        {
            if (LayerData.GeoType == VectorLayer.GEOTYPE_LINEAR)
            {
                foreach (var featurePair in Features)
                {
                    var    feature  = featurePair.Key;
                    var    geometry = featurePair.Value.Geometry as PathGeometry;
                    var    poly     = new Geometry.PointString(feature.GeoData);
                    double length   = poly.Length();
                    if (length < 10)
                    {
                        continue;
                    }

                    double velocity  = theme.GetVelocity(feature);
                    double time      = length / velocity;
                    double space     = 1 / theme.GetDensity(feature);
                    int    spotCount = (int)(length / space) + 1;
                    var    color     = theme.GetColor(feature);

                    for (int i = 0; i < spotCount; i++)
                    {
                        var pointAnimation = new PointAnimationUsingPath
                        {
                            PathGeometry   = geometry,
                            Duration       = new Duration(new TimeSpan(0, 0, 0, 0, (int)(time * 1000))),
                            RepeatBehavior = RepeatBehavior.Forever,
                            BeginTime      = new TimeSpan(0, 0, 0, 0, (int)(time / spotCount * i * 1000))
                        };

                        var colorAnimation = new ColorAnimation(
                            fromValue: color.Item1,
                            toValue: color.Item2,
                            duration: new Duration(new TimeSpan(0, 0, 0, 0, (int)(time * 1000))))
                        {
                            RepeatBehavior = RepeatBehavior.Forever,
                            BeginTime      = new TimeSpan(0, 0, 0, 0, (int)(time / spotCount * i * 1000))
                        };

                        double radius      = theme.GetDiameter(feature) / 2;
                        var    fill        = new SolidColorBrush(color.Item1);
                        var    spot        = new EllipseGeometry(new Point(), radius, radius);
                        var    spotDrawing = new GeometryDrawing(fill, null, spot);
                        this.AddOverlayChildren(spotDrawing);
                        spot.BeginAnimation(EllipseGeometry.CenterProperty, pointAnimation);
                        fill.BeginAnimation(SolidColorBrush.ColorProperty, colorAnimation);
                    }
                }
            }
        }
Example #10
0
        private static void AddFluid(DrawingMapLayer animationLayer, TongJi.Gis.Display.IDataFluidTheme theme, TongJi.Gis.IFeature f)
        {
            var    poly   = new TongJi.Geometry.Polyline(f.GeoData);
            double length = poly.Length;

            if (length < 10)
            {
                return;
            }

            // 生成PathGeometry
            var          points   = poly.Points.Select(p => new Point(p.x, p.y)).ToList();
            PathGeometry geometry = new PathGeometry();
            PathFigure   figure   = new PathFigure {
                StartPoint = points.First()
            };
            PolyLineSegment segment = new PolyLineSegment(points, true);

            figure.Segments.Add(segment);
            geometry.Figures.Add(figure);

            // 读取参数
            double velocity  = theme.GetVelocity(f);
            double time      = length / velocity;
            double space     = 1 / theme.GetDensity(f);
            int    spotCount = (int)(length / space) + 1;
            var    color     = theme.GetColor(f);

            // 应用动画
            for (int i = 0; i < spotCount; i++)
            {
                PointAnimationUsingPath paup = new PointAnimationUsingPath();
                paup.PathGeometry   = geometry;
                paup.Duration       = new Duration(new TimeSpan(0, 0, 0, 0, (int)(time * 1000)));
                paup.RepeatBehavior = RepeatBehavior.Forever;
                paup.BeginTime      = new TimeSpan(0, 0, 0, 0, (int)(time / spotCount * i * 1000));

                ColorAnimation ca = new ColorAnimation(color.Item1, color.Item2, new Duration(new TimeSpan(0, 0, 0, 0, (int)(time * 1000))));
                ca.RepeatBehavior = RepeatBehavior.Forever;
                ca.BeginTime      = new TimeSpan(0, 0, 0, 0, (int)(time / spotCount * i * 1000));

                double          radius      = theme.GetDiameter(f) / 2;
                var             fill        = new SolidColorBrush(color.Item1);
                EllipseGeometry spot        = new EllipseGeometry(new Point(), radius, radius);
                GeometryDrawing spotDrawing = new GeometryDrawing(fill, null, spot);
                animationLayer.AddOverlayChildren(spotDrawing);
                spot.BeginAnimation(EllipseGeometry.CenterProperty, paup);
                fill.BeginAnimation(SolidColorBrush.ColorProperty, ca);
            }
        }
Example #11
0
        /// <summary>
        /// Funkja przygotowywująca animację na podstawie rozmiaru obiektu canvas
        /// </summary>
        /// <param name="geometry">Aktualny obiekt geometry</param>
        private void PrepareAnimation(EllipseGeometry geometry)
        {
            double space = playField.ActualWidth / baloons;

            j += (int)space + 50;
            if (j > playField.ActualWidth)
            {
                j = Convert.ToInt32(j % playField.ActualWidth);
            }

            geometry.Center = new Point(j, -50);
            up             = new PointAnimationUsingPath();
            pBezierSegment = new PolyBezierSegment();
            animationPath  = new PathGeometry();
            pFigure        = new PathFigure();

            pFigure.StartPoint = new Point(j, -50);
            for (int i = 0; (i < playField.ActualHeight); i += 25)
            {
                int randomSign = random.Next(1);
                if (randomSign == 0)
                {
                    pBezierSegment.Points.Add(new Point(j - random.Next(30), i));
                }
                else if (randomSign == 1)
                {
                    pBezierSegment.Points.Add(new Point(j + random.Next(30), i));
                }
            }
            pBezierSegment.Points.Add(new Point(j, playField.ActualHeight + 50));

            pFigure.Segments.Add(pBezierSegment);
            animationPath.Figures.Add(pFigure);
            up.PathGeometry = animationPath;
            if (timesIndex != times.Count)
            {
                up.BeginTime = TimeSpan.FromSeconds(Convert.ToInt32(times[timesIndex]));
                timesIndex++;
            }

            up.Duration       = TimeSpan.FromSeconds(10);
            up.SpeedRatio     = 0.5;
            up.RepeatBehavior = RepeatBehavior.Forever;
            animationPath.Freeze();
            geometry.BeginAnimation(EllipseGeometry.CenterProperty, up);
        }
Example #12
0
        public override void ApplyFluidTheme(IDataFluidTheme theme)
        {
            if (LayerData.GeoType == "2")
            {
                foreach (var feature in Features)
                {
                    var    f        = feature.Key;
                    var    geometry = feature.Value.Geometry as PathGeometry;
                    var    poly     = new Geometry.Polyline(f.GeoData);
                    double length   = poly.Length;
                    if (length < 10)
                    {
                        continue;
                    }
                    double velocity  = theme.GetVelocity(f);
                    double time      = length / velocity;
                    double space     = 1 / theme.GetDensity(f);
                    int    spotCount = (int)(length / space) + 1;
                    var    color     = theme.GetColor(f);

                    for (int i = 0; i < spotCount; i++)
                    {
                        PointAnimationUsingPath paup = new PointAnimationUsingPath();
                        paup.PathGeometry   = geometry;
                        paup.Duration       = new Duration(new TimeSpan(0, 0, 0, 0, (int)(time * 1000)));
                        paup.RepeatBehavior = RepeatBehavior.Forever;
                        paup.BeginTime      = new TimeSpan(0, 0, 0, 0, (int)(time / spotCount * i * 1000));

                        ColorAnimation ca = new ColorAnimation(color.Item1, color.Item2, new Duration(new TimeSpan(0, 0, 0, 0, (int)(time * 1000))));
                        ca.RepeatBehavior = RepeatBehavior.Forever;
                        ca.BeginTime      = new TimeSpan(0, 0, 0, 0, (int)(time / spotCount * i * 1000));

                        double          radius      = theme.GetDiameter(f) / 2;
                        var             fill        = new SolidColorBrush(color.Item1);
                        EllipseGeometry spot        = new EllipseGeometry(new Point(), radius, radius);
                        GeometryDrawing spotDrawing = new GeometryDrawing(fill, null, spot);
                        this.AddOverlayChildren(spotDrawing);
                        spot.BeginAnimation(EllipseGeometry.CenterProperty, paup);
                        fill.BeginAnimation(SolidColorBrush.ColorProperty, ca);
                    }
                }
            }
        }
Example #13
0
        private void myCanvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            PointAnimation myPointAnimation = new PointAnimation(e.GetPosition(this), TimeSpan.FromSeconds(666));

            myEllipseGeometry.BeginAnimation(EllipseGeometry.CenterProperty, myPointAnimation);
        }