本文整理汇总了C#中System.Windows.Shapes.Ellipse.BeginAnimation方法的典型用法代码示例。如果您正苦于以下问题:C# Ellipse.BeginAnimation方法的具体用法?C# Ellipse.BeginAnimation怎么用?C# Ellipse.BeginAnimation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Shapes.Ellipse
的用法示例。
在下文中一共展示了Ellipse.BeginAnimation方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Flush
public void Flush()
{
var thicknessAnimationUsingKeyFrames = new ThicknessAnimationUsingKeyFrames();
thicknessAnimationUsingKeyFrames.KeyFrames = new ThicknessKeyFrameCollection();
double delta = (Width - Height) / 2;
var thicknessAnimation = new ThicknessAnimation()
{
From = new Thickness(delta, 0, delta, 0),
To = new Thickness(delta - 500, -500, delta - 500, -500),
Duration = new Duration(TimeSpan.FromSeconds(1)),
AutoReverse = true
};
thicknessAnimation.Completed += new EventHandler(animation_Completed);
_flushEllipse = new Ellipse()
{
Fill = new SolidColorBrush(Colors.LightBlue),
Stroke = new SolidColorBrush(Colors.Orange),
StrokeThickness = 5,
Opacity = 0.5
};
Children.Add(_flushEllipse);
_flushEllipse.BeginAnimation(Ellipse.MarginProperty, thicknessAnimation);
}
示例2: Button_Click_1
private void Button_Click_1(object sender, RoutedEventArgs e)
{
Ellipse ellipse1 = new Ellipse();
ellipse1.Width = 50;
ellipse1.Height = 20;
ellipse1.ToolTip = "Touch Me / Потискай меня";
ellipse1.StrokeThickness = 2;
ellipse1.Stroke = Brushes.Black;
ellipse1.Fill = Brushes.Red;
Mygrid.Children.Add(ellipse1);
Ellipse ellipse2 = new Ellipse();
ellipse2.Width = 50;
ellipse2.Height = 20;
ellipse2.ToolTip = "Touch Me / Потискай меня";
ellipse2.StrokeThickness = 2;
ellipse2.Stroke = Brushes.Red;
ellipse2.Fill = Brushes.Green;
Mygrid.Children.Add(ellipse2);
Random rand1 = new Random((int)DateTime.Now.Ticks);
Random rand2 = new Random((int)DateTime.Now.Ticks);
ThicknessAnimation TA1 = new ThicknessAnimation(); //Анимация перемещения
TA1.From = ellipse1.Margin = new Thickness(10, 100, 0, 0); //Координаты начального положения
TA1.To = ellipse1.Margin = new Thickness(1400, 100, 0, 0); //Координаты конечного положения
TA1.Duration = TimeSpan.FromSeconds(rand1.Next(10, 20)); //Время анимации
ellipse1.BeginAnimation(MarginProperty, TA1); //Запуск анимации
ThicknessAnimation TA2 = new ThicknessAnimation(); //Анимация перемещения
TA2.From = ellipse2.Margin = new Thickness(10, 200, 0, 0); //Координаты начального положения
TA2.To = ellipse2.Margin = new Thickness(1400, 200, 0, 0); //Координаты конечного положения
TA2.Duration = TimeSpan.FromSeconds(rand2.Next(10, 20)); //Время анимации
ellipse2.BeginAnimation(MarginProperty, TA2); //Запуск анимации
}
示例3: Plot
public override void Plot(bool animate = true)
{
if (Visibility != Visibility.Visible) return;
var chart = Chart as RadarChart;
if (chart == null) return;
var alpha = 360 / chart.Max.X;
var pf = new PathFigure();
var segments = new PathSegmentCollection();
var l = 0d;
Point? p2 = null;
if (!Values.Points.Any()) return;
var lastPoint = Values.Points.Last();
var fisrtPoint = Values.Points.First();
foreach (var point in Values.Points)
{
var r1 = point != lastPoint
? chart.ToChartRadius(point.Y)
: chart.ToChartRadius(fisrtPoint.Y);
if (point == fisrtPoint)
pf.StartPoint = new Point(
chart.ActualWidth/2 + Math.Sin(alpha*point.X*(Math.PI/180))*r1,
chart.ActualHeight/2 - Math.Cos(alpha*point.X*(Math.PI/180))*r1);
else
segments.Add(new LineSegment
{
Point = new Point
{
X = chart.ActualWidth/2 + Math.Sin(alpha*point.X*(Math.PI/180))*r1,
Y = chart.ActualHeight/2 - Math.Cos(alpha*point.X*(Math.PI/180))*r1
}
});
var p1 = new Point(chart.ActualWidth/2 + Math.Sin(alpha*point.X*(Math.PI/180))*r1,
chart.ActualHeight/2 - Math.Cos(alpha*point.X*(Math.PI/180))*r1);
if (p2 != null)
{
l += Math.Sqrt(
Math.Pow(Math.Abs(p1.X - p2.Value.X), 2) +
Math.Pow(Math.Abs(p1.Y - p2.Value.Y), 2)
);
}
p2 = p1;
if (point == lastPoint) continue;
var r = new Rectangle
{
Fill = Brushes.Transparent,
Width = 40,
Height = 40
};
var e = new Ellipse
{
Width = PointRadius*2,
Height = PointRadius*2,
Fill = Stroke,
Stroke = new SolidColorBrush {Color = Chart.PointHoverColor},
StrokeThickness = 2
};
r.MouseEnter += chart.DataMouseEnter;
r.MouseLeave += chart.DataMouseLeave;
r.MouseDown += chart.DataMouseDown;
chart.Canvas.Children.Add(r);
Shapes.Add(r);
chart.HoverableShapes.Add(new HoverableShape
{
Series = this,
Shape = r,
Value = point,
Target = e
});
Shapes.Add(e);
chart.Canvas.Children.Add(e);
Panel.SetZIndex(r, int.MaxValue);
Canvas.SetLeft(e, p1.X - e.Width/2);
Canvas.SetTop(e, p1.Y - e.Height/2);
Panel.SetZIndex(e, 2);
Canvas.SetLeft(r, p1.X - r.Width/2);
Canvas.SetTop(r, p1.Y - r.Height/2);
Panel.SetZIndex(r, int.MaxValue);
if (!chart.DisableAnimation && animate)
{
var topAnim = new DoubleAnimation
{
From = chart.ActualHeight/2,
To = p1.Y - e.Height/2,
Duration = TimeSpan.FromMilliseconds(300)
};
e.BeginAnimation(Canvas.TopProperty, topAnim);
var leftAnim = new DoubleAnimation
{
From = chart.ActualWidth/2,
//.........这里部分代码省略.........
示例4: AnimVertex
/// <summary>
/// Animates a single vertex
/// </summary>
/// <param name="vertex">Vertex to be animated</param>
/// <param name="opacityAnim">Animation to be used</param>
private void AnimVertex(Ellipse vertex, DoubleAnimation opacityAnim)
{
vertex.BeginAnimation(Ellipse.OpacityProperty, opacityAnim);
}
示例5: CreateCircles
private void CreateCircles()
{
double centerX = this.MainCanvas.ActualWidth / 2.0;
double centerY = this.MainCanvas.ActualHeight / 2.0;
Color[] colors = new Color[] { Colors.White, Colors.Green, Colors.Green, Colors.Lime };
for (int i = 0; i < 24; ++i)
{
Ellipse e = new Ellipse();
byte alpha = (byte)rand.Next(96, 192);
int colorIndex = rand.Next(4);
e.Stroke = new SolidColorBrush(Color.FromArgb(alpha, colors[colorIndex].R, colors[colorIndex].G, colors[colorIndex].B));
e.StrokeThickness = rand.Next(1, 4);
e.Width = 0.0;
e.Height = 0.0;
double offsetX = 16 - rand.Next(32);
double offsetY = 16 - rand.Next(32);
this.MainCanvas.Children.Add(e);
e.SetValue(Canvas.LeftProperty, centerX + offsetX);
e.SetValue(Canvas.TopProperty, centerY + offsetY);
double duration = 6.0 + 10.0 * rand.NextDouble();
double delay = 16.0 * rand.NextDouble();
TranslateTransform offsetTransform = new TranslateTransform();
DoubleAnimation offsetXAnimation = new DoubleAnimation(0.0, -256.0, new Duration(TimeSpan.FromSeconds(duration)));
offsetXAnimation.RepeatBehavior = RepeatBehavior.Forever;
offsetXAnimation.BeginTime = TimeSpan.FromSeconds(delay);
offsetTransform.BeginAnimation(TranslateTransform.XProperty, offsetXAnimation);
offsetTransform.BeginAnimation(TranslateTransform.YProperty, offsetXAnimation);
e.RenderTransform = offsetTransform;
DoubleAnimation sizeAnimation = new DoubleAnimation(0.0, 512.0, new Duration(TimeSpan.FromSeconds(duration)));
sizeAnimation.RepeatBehavior = RepeatBehavior.Forever;
sizeAnimation.BeginTime = TimeSpan.FromSeconds(delay);
e.BeginAnimation(Ellipse.WidthProperty, sizeAnimation);
e.BeginAnimation(Ellipse.HeightProperty, sizeAnimation);
DoubleAnimation opacityAnimation = new DoubleAnimation(duration - 1.0, 0.0, new Duration(TimeSpan.FromSeconds(duration)));
opacityAnimation.BeginTime = TimeSpan.FromSeconds(delay);
opacityAnimation.RepeatBehavior = RepeatBehavior.Forever;
e.BeginAnimation(Ellipse.OpacityProperty, opacityAnimation);
}
}
示例6: CreateCircles
private void CreateCircles()
{
var centerX = MainCanvas.ActualWidth/2.0;
var centerY = MainCanvas.ActualHeight/2.0;
Color[] colors = {Colors.White, Colors.Green, Colors.Green, Colors.Lime};
for (var i = 0; i < 24; ++i)
{
var e = new Ellipse();
var alpha = (byte) _rand.Next(96, 192);
var colorIndex = _rand.Next(4);
e.Stroke =
new SolidColorBrush(Color.FromArgb(alpha, colors[colorIndex].R, colors[colorIndex].G,
colors[colorIndex].B));
e.StrokeThickness = _rand.Next(1, 4);
e.Width = 0.0;
e.Height = 0.0;
double offsetX = 16 - _rand.Next(32);
double offsetY = 16 - _rand.Next(32);
MainCanvas.Children.Add(e);
e.SetValue(Canvas.LeftProperty, centerX + offsetX);
e.SetValue(Canvas.TopProperty, centerY + offsetY);
var duration = 6.0 + 10.0*_rand.NextDouble();
var delay = 16.0*_rand.NextDouble();
var offsetTransform = new TranslateTransform();
var offsetXAnimation = new DoubleAnimation(0.0, -256.0, new Duration(TimeSpan.FromSeconds(duration)))
{
RepeatBehavior = RepeatBehavior.Forever,
BeginTime = TimeSpan.FromSeconds(delay)
};
offsetTransform.BeginAnimation(TranslateTransform.XProperty, offsetXAnimation);
offsetTransform.BeginAnimation(TranslateTransform.YProperty, offsetXAnimation);
e.RenderTransform = offsetTransform;
var sizeAnimation = new DoubleAnimation(0.0, 512.0, new Duration(TimeSpan.FromSeconds(duration)))
{
RepeatBehavior = RepeatBehavior.Forever,
BeginTime = TimeSpan.FromSeconds(delay)
};
e.BeginAnimation(WidthProperty, sizeAnimation);
e.BeginAnimation(HeightProperty, sizeAnimation);
var opacityAnimation = new DoubleAnimation(duration - 1.0, 0.0,
new Duration(TimeSpan.FromSeconds(duration)))
{
BeginTime = TimeSpan.FromSeconds(delay),
RepeatBehavior = RepeatBehavior.Forever
};
e.BeginAnimation(OpacityProperty, opacityAnimation);
}
}