1

How can we animate an arc segment in WPF. Below is the code attached.

PathGeometry pg = new PathGeometry();
PathFigure pf = new PathFigure();
LineSegment ls1 = new LineSegment();
LineSegment ls2 = new LineSegment();
ArcSegment arc = new ArcSegment();
double xc = canvas.Width / 2 - 50 + dx;
double yc = canvas.Height / 2 + dy;
double r = 0.7 * xc;   // To control the Explosion generally for all the slices 
pf.IsClosed = true;
pf.StartPoint = new Point(xc, yc);
pf.Segments.Add(ls1);
pf.Segments.Add(arc);
pf.Segments.Add(ls2);
pg.Figures.Add(pf);
path.Data = pg;
arc.IsLargeArc = isLargArc;

ls1.Point = new Point(xc + r * Math.Cos(startAngle), yc + r * Math.Sin(startAngle));
arc.SweepDirection = SweepDirection.Clockwise;

arc.Point = new Point(xc + r * Math.Cos(endAngle), yc + r * Math.Sin(endAngle));
arc.Size = new Size(r, r);
ls2.Point = new Point(xc + r * Math.Cos(endAngle), yc + r * Math.Sin(endAngle));

Duration duration = new Duration(TimeSpan.FromSeconds(5));

pau = new PointAnimationUsingPath();
pau.PathGeometry = pg;
pau.FillBehavior = FillBehavior.Stop;
pau.Duration = new Duration(TimeSpan.FromSeconds(5));

A sample image is attached

I am trying to get the arc segment to animate as in figure from one position to another. There are a list of arc segments which animate one after the other.

4

1 に答える 1

2

クラスを使用Storyboardしてアニメーション化できます。たとえば、位置をアニメーション化することができ、RenderTransformそれは機能するはずです

于 2012-11-10T19:21:59.730 に答える