本文整理汇总了C#中System.Windows.Controls.TextBlock.BeginAnimation方法的典型用法代码示例。如果您正苦于以下问题:C# TextBlock.BeginAnimation方法的具体用法?C# TextBlock.BeginAnimation怎么用?C# TextBlock.BeginAnimation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.TextBlock
的用法示例。
在下文中一共展示了TextBlock.BeginAnimation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: animationFadeText
private void animationFadeText(TextBlock text, double from, double to, int duration)
{
DoubleAnimation animationFade = new DoubleAnimation();
animationFade.From = from;
animationFade.To = to;
animationFade.Duration = new Duration(TimeSpan.FromMilliseconds(duration));
text.BeginAnimation(Button.OpacityProperty, animationFade);
}
示例2: CreateMessagePanels
private void CreateMessagePanels()
{
Messages messages = new Messages(this.session);
MessageObjects allobjects = messages.GetAllMessage();
List<Message> msgs = allobjects.Messages;
int index = rand.Next(msgs.Count);
Message msg = msgs[index];
TextBlock tb = new TextBlock();
tb.Text = msg.Body.Plain;
tb.FontSize = 14;
this.MainCanvas.Children.Add(tb);
double centerX = this.MainCanvas.ActualWidth / 2.0;
double centerY = this.MainCanvas.ActualHeight / 2.0;
double offsetX = 16 - rand.Next(32);
double offsetY = 16 - rand.Next(32);
//tb.SetValue(Canvas.LeftProperty, centerX + offsetX);
//tb.SetValue(Canvas.TopProperty, centerY + offsetY);
tb.SetValue(Canvas.LeftProperty, centerX );
tb.SetValue(Canvas.TopProperty, centerY );
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);
//tb.RenderTransform = offsetTransform;
DoubleAnimation opacityAnimation = new DoubleAnimation(0.0, 1.0, new Duration(TimeSpan.FromSeconds(4.0)));
opacityAnimation.RepeatBehavior = RepeatBehavior.Forever;
tb.BeginAnimation(TextBlock.OpacityProperty, opacityAnimation);
}