本文整理汇总了C#中System.Windows.Media.EllipseGeometry.BeginAnimation方法的典型用法代码示例。如果您正苦于以下问题:C# EllipseGeometry.BeginAnimation方法的具体用法?C# EllipseGeometry.BeginAnimation怎么用?C# EllipseGeometry.BeginAnimation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.EllipseGeometry
的用法示例。
在下文中一共展示了EllipseGeometry.BeginAnimation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MakeCircleAnimation
public void MakeCircleAnimation(FrameworkElement animatedElement, double width, double height, TimeSpan timeSpan)
{
EllipseGeometry ellipseGeometry = new EllipseGeometry();
ellipseGeometry.RadiusX = 0;
ellipseGeometry.RadiusY = 0;
double centrex = width / 2;
double centrey = height / 2;
ellipseGeometry.Center = new Point(centrex, centrey);
animatedElement.Clip = ellipseGeometry; //The most important line
double halfWidth = width / 2;
double halfheight = height / 2;
DoubleAnimation a = new DoubleAnimation();
a.Completed += new EventHandler(a_Completed);
a.From = 0;
a.To = Math.Sqrt(halfWidth * halfWidth + halfheight * halfheight);
a.Duration = new Duration(timeSpan);
ellipseGeometry.BeginAnimation(EllipseGeometry.RadiusXProperty, a);
ellipseGeometry.BeginAnimation(EllipseGeometry.RadiusYProperty, a);
}
示例2: PrepareAnimation
/// <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);
}