本文整理汇总了C#中System.Windows.Shapes.Ellipse.Reposition方法的典型用法代码示例。如果您正苦于以下问题:C# Ellipse.Reposition方法的具体用法?C# Ellipse.Reposition怎么用?C# Ellipse.Reposition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Shapes.Ellipse
的用法示例。
在下文中一共展示了Ellipse.Reposition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetupDrawBallsAsControls
///<summary>Handles making ellipse controls for each ball in the game, as while as showing their death animations.</summary>
public static void SetupDrawBallsAsControls(this Game game, PerishableCollection<UIElement> controls, TimeSpan deathFadeOutDuration, double deathFinalRadiusFactor) {
game.Balls.CurrentAndFutureItems().Subscribe(
e => {
// create an ellipse control to visually represent the ball
var ball = e.Value;
var color = ball.Hue.HueToApproximateColor(period: 3);
var ellipseControl = new Ellipse {
Width = ball.Radius * 2,
Height = ball.Radius * 2,
VerticalAlignment = VerticalAlignment.Top,
HorizontalAlignment = HorizontalAlignment.Left,
Fill = new SolidColorBrush(color)
};
// 'root' balls have a black border
if (ball.Generation == 1) {
ellipseControl.StrokeThickness = 3;
ellipseControl.Stroke = new SolidColorBrush(Colors.Black);
}
// reposition ellipse control during each game loop, until ball is dead
game.LoopActions.Add(
step => ellipseControl.Reposition(ball.Pos, ball.Radius),
e.Lifetime);
// once ball is dead, expand and fade out the ellipse
var controlLifetime = e.Lifetime.ThenResurrect(() =>
game.AnimateWith(
deathFadeOutDuration,
(step, portion, dt) => {
// fade out
ellipseControl.Fill = new SolidColorBrush(color.LerpToTransparent(portion));
// expand
var radius = ball.Radius * 1.LerpTo(deathFinalRadiusFactor, portion);
ellipseControl.Reposition(ball.Pos, radius);
}));
controls.Add(ellipseControl, controlLifetime);
},
game.Life);
}