本文整理汇总了C#中System.Windows.Media.Animation.DoubleAnimation.Freeze方法的典型用法代码示例。如果您正苦于以下问题:C# DoubleAnimation.Freeze方法的具体用法?C# DoubleAnimation.Freeze怎么用?C# DoubleAnimation.Freeze使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.Animation.DoubleAnimation
的用法示例。
在下文中一共展示了DoubleAnimation.Freeze方法的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>
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);
}
示例2: 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);
}
示例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>
/// <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);
}
示例4: CreateAnimation
public static DoubleAnimation CreateAnimation(double from, double to, double beginTime, double time, IEasingFunction ease = null, EventHandler completed = null)
{
DoubleAnimation animation = new DoubleAnimation(from, to, new Duration(TimeSpan.FromSeconds(time)));
animation.BeginTime = TimeSpan.FromSeconds(beginTime);
if (ease != null) animation.EasingFunction = ease;
if (completed != null) animation.Completed += completed;
animation.Freeze();
return animation;
}
示例5: CreateAnimation
/// <summary>
/// Creates the animation that moves content in or out of view.
/// </summary>
/// <param name="from">The starting value of the animation.</param>
/// <param name="to">The end value of the animation.</param>
/// <param name="whenDone">(optional) A callback that will be called when the animation has completed.</param>
private AnimationTimeline CreateAnimation(double from, double to, EventHandler whenDone = null)
{
IEasingFunction ease = new BackEase { Amplitude = 0.5, EasingMode = EasingMode.EaseOut };
var duration = new Duration(TimeSpan.FromSeconds(0.5));
var anim = new DoubleAnimation(from, to, duration) { EasingFunction = ease };
if (whenDone != null)
anim.Completed += whenDone;
anim.Freeze();
return anim;
}
示例6: CreateAnimation
/// <summary>
/// Creates the animation that moves content in or out of view.
/// </summary>
/// <param name="from">The starting value of the animation.</param>
/// <param name="to">The end value of the animation.</param>
/// <param name="whenDone">(optional) A callback that will be called when the animation has completed.</param>
private static AnimationTimeline CreateAnimation(double from, double to, TimeSpan timeDuration, EventHandler whenDone = null)
{
var duration = new Duration(timeDuration);
var anim = new DoubleAnimation(from, to, duration);// { EasingFunction = ease };
if (whenDone != null)
anim.Completed += whenDone;
anim.Freeze();
return anim;
}
示例7: GetMoveCharacterPanAnimation
private static DoubleAnimation GetMoveCharacterPanAnimation(Double toValue)
{
//we add a slight delay onto the animation, so that if we have back-to-back animations, the handoff between them is smooth
var animation = new DoubleAnimation(toValue, TimerUtility.GetTickDelay(Constants.MAP_MOVE_CHARACTER_TICKS).Add(TimeSpan.FromMilliseconds(10)))
{
AccelerationRatio = 0, //keep the ratios at 0 so you're moving at a constant speed
DecelerationRatio = 0,
FillBehavior = FillBehavior.HoldEnd
};
animation.Freeze();
return animation;
}
示例8: StartAnimation
public static void StartAnimation (Transform 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);
}
示例9: CreateAnimation
/// <summary>
/// Create the animation and add it to the master timeline
/// </summary>
protected override void CreateAnimation()
{
var animationDuration = new Duration(this.AnimationConfiguration.Duration);
this.MasterStoryboard.Duration = animationDuration;
var animationX = new DoubleAnimation(this.StartX, this.EndX, animationDuration);
var animationY = new DoubleAnimation(this.StartY, this.EndY, animationDuration);
Storyboard.SetTargetProperty(animationX, new PropertyPath(Canvas.LeftProperty));
Storyboard.SetTargetProperty(animationY, new PropertyPath(Canvas.TopProperty));
animationX.Freeze();
animationY.Freeze();
this.MasterStoryboard.Children.Add(animationX);
this.MasterStoryboard.Children.Add(animationY);
}
示例10: DragAdorner
public DragAdorner(UIElement adorned)
: base(adorned)
{
var brush = new VisualBrush(adorned) {Stretch = Stretch.None, AlignmentX = AlignmentX.Left};
// HACK: this makes the markers work properly,
// even after adding 4+ markers and then removing to 3-,
// and then shift-dragging (in which case the size of the adorner is correct,
// but the VisualBrush tries to render the now invisible number.
_child = new Rectangle();
_child.BeginInit();
_child.Width = adorned.RenderSize.Width;
_child.Height = adorned.RenderSize.Height;
_child.Fill = brush;
_child.IsHitTestVisible = false;
_child.EndInit();
var animation = new DoubleAnimation(0.6, 0.85, new Duration(TimeSpan.FromMilliseconds(500)))
{AutoReverse = true, RepeatBehavior = RepeatBehavior.Forever};
animation.Freeze();
brush.BeginAnimation(Brush.OpacityProperty, animation);
}
示例11: CreateZoomAnimation
DoubleAnimation CreateZoomAnimation(double toValue)
{
var da = new DoubleAnimation(toValue, new Duration(TimeSpan.FromMilliseconds(555)));
da.AccelerationRatio = 0.1;
da.DecelerationRatio = 0.9;
da.FillBehavior = FillBehavior.HoldEnd;
da.Freeze();
return da;
}
示例12: Animate
void Animate(double to, DependencyProperty dp)
{
var animation = new DoubleAnimation();
animation.From = (double)GetValue(dp);
if (!double.IsNaN(to)) animation.To = Math.Max(0, to);
else animation.To = 0;
animation.Duration = new Duration(TimeSpan.FromMilliseconds(500));
animation.Freeze();
BeginAnimation(dp, animation);
}
示例13: FadeOutAdorner
/// <summary>
/// Fade the adorner out and make it visible.
/// </summary>
public void FadeOutAdorner()
{
if (adornerShowState == AdornerShowState.FadingOut)
{
//
// Already fading out.
//
return;
}
if (adornerShowState == AdornerShowState.Hidden)
{
//
// Adorner has already been hidden.
//
return;
}
DoubleAnimation fadeOutAnimation = new DoubleAnimation(0.0, new Duration(TimeSpan.FromSeconds(FadeOutTime)));
fadeOutAnimation.Completed += new EventHandler(fadeOutAnimation_Completed);
fadeOutAnimation.Freeze();
adorner.BeginAnimation(FrameworkElement.OpacityProperty, fadeOutAnimation);
adornerShowState = AdornerShowState.FadingOut;
}
示例14: FadeInAdorner
/// <summary>
/// Fade the adorner in and make it visible.
/// </summary>
public void FadeInAdorner()
{
if (adornerShowState == AdornerShowState.Visible ||
adornerShowState == AdornerShowState.FadingIn)
{
// Already visible or fading in.
return;
}
this.ShowAdorner();
if (adornerShowState != AdornerShowState.FadingOut)
{
adorner.Opacity = 0.0;
}
DoubleAnimation doubleAnimation = new DoubleAnimation(1.0, new Duration(TimeSpan.FromSeconds(FadeInTime)));
doubleAnimation.Completed += new EventHandler(fadeInAnimation_Completed);
doubleAnimation.Freeze();
adorner.BeginAnimation(FrameworkElement.OpacityProperty, doubleAnimation);
adornerShowState = AdornerShowState.FadingIn;
}
示例15: ProcessNewChild
protected override Point ProcessNewChild(UIElement child, Rect providedBounds)
{
var startLocation = providedBounds.Location;
if (m_arrangedOnce)
{
if (m_itemOpacityAnimation == null)
{
m_itemOpacityAnimation = new DoubleAnimation()
{
From = 0,
Duration = new Duration(TimeSpan.FromSeconds(.5))
};
m_itemOpacityAnimation.Freeze();
}
child.BeginAnimation(UIElement.OpacityProperty, m_itemOpacityAnimation);
startLocation -= new Vector(providedBounds.Width, 0);
}
return startLocation;
}