本文整理汇总了C#中System.Windows.Controls.Control.BeginAnimation方法的典型用法代码示例。如果您正苦于以下问题:C# Control.BeginAnimation方法的具体用法?C# Control.BeginAnimation怎么用?C# Control.BeginAnimation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.Control
的用法示例。
在下文中一共展示了Control.BeginAnimation方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: animateControlOpacity
/// <summary>
/// Animates a control and allows control of the duration and opacity
/// </summary>
/// <param name="control">The control to be animated</param>
/// <param name="opacity">The opacity value for the animation</param>
/// <param name="duration">The duration for the animation</param>
private void animateControlOpacity(Control control, double opacity, double duration)
{
control.BeginInit();
control.Dispatcher.BeginInvoke((Action)(() =>
{
DoubleAnimation controlAnimation = new DoubleAnimation(opacity, new Duration(TimeSpan.FromSeconds(duration)));
control.BeginAnimation(Label.OpacityProperty, controlAnimation);
}), null);
control.EndInit();
}
示例2: PlayAnimation
/// <summary>
/// 播放动画(DoubleAnimation)
/// </summary>
/// <param name="from">From</param>
/// <param name="to">To</param>
/// <param name="dp">依赖属性</param>
/// <param name="target">对象</param>
/// <param name="duration">时长</param>
public static void PlayAnimation(double from, double to, DependencyProperty dp, Control target, double duration = 1)
{
DoubleAnimation animation = new DoubleAnimation()
{
From = from,
To = to,
Duration = TimeSpan.FromSeconds(duration),
FillBehavior = FillBehavior.HoldEnd,
AccelerationRatio = .5,
EasingFunction = CAAnimation.be
};
target.BeginAnimation(dp, animation);
}
示例3: DoFadeInAnimation
// Plays the show animation for the given controls.
private void DoFadeInAnimation(Control control)
{
// Fade in Animation.
if (control.Opacity == 0)
{
DoubleAnimation da = new DoubleAnimation();
da.From = 0;
da.To = 1;
da.Duration = new Duration(TimeSpan.FromSeconds(0.25));
da.BeginTime = TimeSpan.FromMilliseconds(100);
control.BeginAnimation(OpacityProperty, da);
}
}
示例4: Transition
void Transition(Control outItem, Control inItem)
{
if (_transitionInProgress)
{
_transitionQueueOut.Enqueue(outItem);
_transitionQueueIn.Enqueue(inItem);
}
else
{
_transitionInProgress = true;
inItem.Opacity = 0;
inItem.Visibility = Visibility.Visible;
outItem.IsEnabled = false;
DoubleAnimation daFadeOut = new DoubleAnimation();
daFadeOut.To = 0;
daFadeOut.Duration = TimeSpan.FromMilliseconds(1000);
daFadeOut.Completed += delegate(object sender, EventArgs e)
{
inItem.IsEnabled = true;
outItem.Visibility = Visibility.Collapsed;
_transitionInProgress = false;
if (_transitionQueueIn.Count > 0)
{
Transition(_transitionQueueOut.Dequeue(), _transitionQueueIn.Dequeue());
}
};
DoubleAnimation daFadeIn = new DoubleAnimation();
daFadeIn.To = 1;
daFadeIn.Duration = TimeSpan.FromMilliseconds(1000);
outItem.BeginAnimation(FrameworkElement.OpacityProperty, daFadeOut);
inItem.BeginAnimation(FrameworkElement.OpacityProperty, daFadeIn);
}
}
示例5: Fade_Out_Control
public static void Fade_Out_Control(Control c, int seconds)
{
Duration dur = new Duration(new TimeSpan(0, 0, 0, 0, seconds));
fadeOut.Duration = dur;
c.BeginAnimation(Control.OpacityProperty, fadeOut);
}
示例6: FadeScrollElement
public static void FadeScrollElement(double fromValue, double toValue, Control control)
{
DoubleAnimation da = new DoubleAnimation(fromValue, toValue, time);
da.DecelerationRatio = acceleration;
control.BeginAnimation(Control.OpacityProperty, da);
}
示例7: SizeHeight
public static void SizeHeight(double fromValue, double toValue, Control control)
{
DoubleAnimation da = new DoubleAnimation(fromValue, toValue, time);
da.DecelerationRatio = acceleration;
control.BeginAnimation(Control.HeightProperty, da);
}
示例8: HideAnimation
private void HideAnimation(Control AnimationObject, double start, double end)
{
DoubleAnimation da = new DoubleAnimation(start, end, TimeSpan.FromMilliseconds(200));
AnimationObject.BeginAnimation(Control.WidthProperty, da);
}