本文整理汇总了C#中System.Windows.UIElement.BeginAnimation方法的典型用法代码示例。如果您正苦于以下问题:C# UIElement.BeginAnimation方法的具体用法?C# UIElement.BeginAnimation怎么用?C# UIElement.BeginAnimation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.UIElement
的用法示例。
在下文中一共展示了UIElement.BeginAnimation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StartAnimation
/// <summary>
/// Starts an animation to a particular value on the specified dependency property.
/// You can pass in an event handler to call when the animation has completed.
/// </summary>
/// <param name="pAnimatableElement">The gui element to animate.</param>
/// <param name="pDependencyProperty">The dependency property to animate.</param>
/// <param name="pToValue">The final value of the dependency property.</param>
/// <param name="pAnimationDurationSeconds">The animation duration.</param>
/// <param name="pCompletedEvent">The callback executed when the animation ended.</param>
public static void StartAnimation(UIElement pAnimatableElement, DependencyProperty pDependencyProperty, double pToValue, double pAnimationDurationSeconds, EventHandler pCompletedEvent)
{
double lFromValue = (double)pAnimatableElement.GetValue(pDependencyProperty);
DoubleAnimation lAnimation = new DoubleAnimation();
lAnimation.From = lFromValue;
lAnimation.To = pToValue;
lAnimation.Duration = TimeSpan.FromSeconds(pAnimationDurationSeconds);
lAnimation.Completed += delegate(object pSender, EventArgs pEventArgs)
{
//
// When the animation has completed bake final value of the animation
// into the property.
//
pAnimatableElement.SetValue(pDependencyProperty, pAnimatableElement.GetValue(pDependencyProperty));
CancelAnimation(pAnimatableElement, pDependencyProperty);
if (pCompletedEvent != null)
{
pCompletedEvent(pSender, pEventArgs);
}
};
lAnimation.Freeze();
pAnimatableElement.BeginAnimation(pDependencyProperty, lAnimation);
}
示例2: UIElementCome
/// <summary>
/// 控件窗口弹出动画
/// </summary>
public static void UIElementCome(UIElement uIElement, ScaleTransform _scale)
{
PennerDoubleAnimation da = new PennerDoubleAnimation()
{
From = 0.8,
To = 1,
Equation = Equations.BackEaseOut,
FillBehavior = FillBehavior.Stop,
Duration = TimeSpan.FromSeconds(0.5)
};
da.Completed += delegate
{
_scale.ScaleX = 1;
_scale.ScaleY = 1;
};
DoubleAnimation daO = new DoubleAnimation()
{
From = 0,
To = 1,
FillBehavior = FillBehavior.Stop,
Duration = TimeSpan.FromSeconds(0.7)
};
daO.Completed += delegate
{
uIElement.Opacity = 1;
};
_scale.BeginAnimation(ScaleTransform.ScaleXProperty, da);
_scale.BeginAnimation(ScaleTransform.ScaleYProperty, da);
uIElement.BeginAnimation(UIElement.OpacityProperty, daO);
}
示例3: StartAnimation
/// <summary>
/// Starts an animation to a particular value on the specified dependency property.
/// You can pass in an event handler to call when the animation has completed.
/// </summary>
public static void StartAnimation(UIElement animationElement, DependencyProperty dependencyProperty, double toValue, double animationDurationSeconds, EventHandler completedEvent)
{
if (animationElement == null)
{
throw new ArgumentNullResourceException("animationElement", Resources.General_Given_Parameter_Cannot_Be_Null);
}
var fromValue = (double)animationElement.GetValue(dependencyProperty);
var animation = new DoubleAnimation { From = fromValue, To = toValue, Duration = TimeSpan.FromSeconds(animationDurationSeconds) };
animation.Completed += (sender, e) =>
{
// When the animation has completed bake final value of the animation
// into the property.
animationElement.SetValue(dependencyProperty, animationElement.GetValue(dependencyProperty));
CancelAnimation(animationElement, dependencyProperty);
if (completedEvent != null)
{
completedEvent(sender, e);
}
};
animation.Freeze();
animationElement.BeginAnimation(dependencyProperty, animation);
}
示例4: StartAnimation
/// <summary>
/// Starts an animation to a particular value on the specified dependency property.
/// You can pass in an event handler to call when the animation has completed.
/// </summary>
public static void StartAnimation(UIElement animatableElement, DependencyProperty dependencyProperty, double toValue, double animationDurationSeconds, EventHandler completedEvent)
{
double fromValue = (double)animatableElement.GetValue(dependencyProperty);
DoubleAnimation animation = new DoubleAnimation();
animation.From = fromValue;
animation.To = toValue;
animation.Duration = TimeSpan.FromSeconds(animationDurationSeconds);
animation.Completed += delegate(object sender, EventArgs e)
{
//
// When the animation has completed bake final value of the animation
// into the property.
//
animatableElement.SetValue(dependencyProperty, animatableElement.GetValue(dependencyProperty));
CancelAnimation(animatableElement, dependencyProperty);
if (completedEvent != null)
{
completedEvent(sender, e);
}
};
animation.Freeze();
animatableElement.BeginAnimation(dependencyProperty, animation);
}
示例5: FadeUIElement
public static void FadeUIElement(double fromValue, double toValue, UIElement control)
{
DoubleAnimation da = new DoubleAnimation(fromValue, toValue, time);
da.DecelerationRatio = acceleration;
da.Completed += UIElementFadeCompleted;
control.BeginAnimation(UIElement.OpacityProperty, da);
}
示例6: Animate
public static void Animate(UIElement element, DependencyProperty property, double toValue, double duration)
{
DoubleAnimation Animation = new DoubleAnimation();
Animation.To = toValue;
Animation.Duration = new Duration(TimeSpan.FromSeconds(duration));
element.BeginAnimation(property, Animation);
}
示例7: fadeIn
public static void fadeIn(UIElement itemToBeAnimated, double animationTimeInSeconds)
{
DoubleAnimation da = new DoubleAnimation();
da.From = 0;
da.To = 1;
da.Duration = new Duration(TimeSpan.FromSeconds(animationTimeInSeconds));
itemToBeAnimated.BeginAnimation(OpacityProperty, da);
}
示例8: CancelAnimation
/// <summary>
/// Cancel any animations that are running on the specified dependency property.
/// </summary>
public static void CancelAnimation(UIElement animatedElement, DependencyProperty dependencyProperty)
{
if (animatedElement == null)
{
throw new ArgumentNullResourceException("animatedElement", Resources.General_Given_Parameter_Cannot_Be_Null);
}
animatedElement.BeginAnimation(dependencyProperty, null);
}
示例9: HideAndFadeOut
public static void HideAndFadeOut(UIElement control, double seconds)
{
DoubleAnimation fadeout = new DoubleAnimation(1.0, 0.0, new Duration(TimeSpan.FromSeconds(seconds)));
fadeout.Completed += delegate(object sender,EventArgs e)
{
control.Visibility = Visibility.Collapsed;
};
control.BeginAnimation(UIElement.OpacityProperty, fadeout);
}
示例10: fadeInOut
public static void fadeInOut(UIElement itemToBeAnimated, double animationTimeInSeconds, int timesRepeated)
{
DoubleAnimation da = new DoubleAnimation();
da.From = 1;
da.To = 0;
da.Duration = new Duration(TimeSpan.FromSeconds(animationTimeInSeconds));
da.AutoReverse = true;
da.RepeatBehavior = new RepeatBehavior(timesRepeated);
itemToBeAnimated.BeginAnimation(OpacityProperty, da);
}
示例11: Start
public void Start(object source)
{
//WPF objects MUST be created on the goddamn dispatcher thread, otherwise you run into trouble
makeVisible = new DoubleAnimation(0.0, 1.0, new Duration(TimeSpan.FromSeconds(Duration)));
makeInvisible = new DoubleAnimation(1.0, 0.0, new Duration(TimeSpan.FromSeconds(Duration)));
openingSource = source as UIElement;
if (openingSource == null) return;
openingSource.BeginAnimation(UIElement.OpacityProperty, makeVisible);
}
示例12: DoMove
public static void DoMove(UIElement uie, DependencyProperty dp, double to, double ar, double dr, double duration)
{
var doubleAnimation = new DoubleAnimation
{
To = to,
Duration = TimeSpan.FromSeconds(duration),
AccelerationRatio = ar,
DecelerationRatio = dr,
FillBehavior = FillBehavior.HoldEnd
};//创建双精度动画对象
uie.BeginAnimation(dp, doubleAnimation);//设置动画应用的属性并启动动画
}
示例13: StartAnimation
public static void StartAnimation (UIElement animatableElement, DependencyProperty dependencyProperty, double toValue, double durationMilliseconds, double accelerationRatio, double decelerationRatio)
{
DoubleAnimation animation = new DoubleAnimation();
animation.To = toValue;
animation.AccelerationRatio = accelerationRatio;
animation.DecelerationRatio = decelerationRatio;
animation.FillBehavior = FillBehavior.HoldEnd;
animation.Duration = TimeSpan.FromMilliseconds(durationMilliseconds);
animation.Freeze();
animatableElement.BeginAnimation(dependencyProperty, animation, HandoffBehavior.Compose);
}
示例14: AddChildSP
public static void AddChildSP(UIElement child, StackPanel sp, int start_time)
{
sp.Children.Add(child);
child.Opacity = 0.0;
DoubleAnimation an = new DoubleAnimation(0.0, 1.0, TimeSpan.FromMilliseconds(200));
an.BeginTime = TimeSpan.FromMilliseconds(start_time += 80);
child.BeginAnimation(btnDugmeTemp.OpacityProperty, an);
DoubleAnimation da = new DoubleAnimation(50, 0, new Duration(TimeSpan.FromMilliseconds(200)));
da.BeginTime = TimeSpan.FromMilliseconds(start_time);
da.DecelerationRatio = 0.7;
TranslateTransform rt = new TranslateTransform();
child.RenderTransform = rt;
rt.BeginAnimation(TranslateTransform.XProperty, da);
}
示例15: CancelAnimation
/// <summary>
/// Cancel any animations that are running on the specified dependency property.
/// </summary>
public static void CancelAnimation(UIElement animatableElement, DependencyProperty dependencyProperty)
{
animatableElement.BeginAnimation(dependencyProperty, null);
}