本文整理汇总了C#中Windows.UI.Xaml.Media.Animation.Storyboard.Begin方法的典型用法代码示例。如果您正苦于以下问题:C# Storyboard.Begin方法的具体用法?C# Storyboard.Begin怎么用?C# Storyboard.Begin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Windows.UI.Xaml.Media.Animation.Storyboard
的用法示例。
在下文中一共展示了Storyboard.Begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StartAnimation
private void StartAnimation(EasingFunctionBase easingFunction)
{
// show the chart
chartControl.Draw(easingFunction);
// animation
#if WPF
NameScope.SetNameScope(translate1, new NameScope());
#endif
var storyboard = new Storyboard();
var ellipseMove = new DoubleAnimation();
ellipseMove.EasingFunction = easingFunction;
ellipseMove.Duration = new Duration(TimeSpan.FromSeconds(AnimationTimeSeconds));
ellipseMove.From = 0;
ellipseMove.To = 460;
#if WPF
Storyboard.SetTargetName(ellipseMove, nameof(translate1));
Storyboard.SetTargetProperty(ellipseMove, new PropertyPath(TranslateTransform.XProperty));
#else
Storyboard.SetTarget(ellipseMove, translate1);
Storyboard.SetTargetProperty(ellipseMove, "X");
#endif
ellipseMove.BeginTime = TimeSpan.FromSeconds(0.5); // start animation in 0.5 seconds
ellipseMove.FillBehavior = FillBehavior.HoldEnd; // keep position after animation
storyboard.Children.Add(ellipseMove);
#if WPF
storyboard.Begin(this);
#else
storyboard.Begin();
#endif
}
示例2: BeginMenuAnimatie
/// <summary>
/// Begint een nieuw storyboard dat het menu grid uitschuift of inschuift naar een positieve (zichtbaar) of negatieve (onzichtbaar) margin.
/// </summary>
public void BeginMenuAnimatie()
{
Storyboard storyboard = new Storyboard();
TranslateTransform beweegTransformatie = new TranslateTransform();
menu.RenderTransform = beweegTransformatie;
DoubleAnimation verplaatsMenuAnimatie = new DoubleAnimation();
verplaatsMenuAnimatie.Duration = new Duration(TimeSpan.FromSeconds(0.15));
if (btnHideShow.Content.Equals(">"))
{
verplaatsMenuAnimatie.To = 303;
verplaatsMenuAnimatie.From = 0;
btnHideShow.Content = "<";
}
else
{
verplaatsMenuAnimatie.To = 0;
verplaatsMenuAnimatie.From = 303;
btnHideShow.Content = ">";
}
storyboard.Children.Add(verplaatsMenuAnimatie);
Storyboard.SetTarget(verplaatsMenuAnimatie, beweegTransformatie);
Storyboard.SetTargetProperty(verplaatsMenuAnimatie, "X");
storyboard.Begin();
}
示例3: AnimateVertexForward
public void AnimateVertexForward(VertexControl target)
{
var transform = CustomHelper.GetScaleTransform(target);
if (transform == null)
{
target.RenderTransform = new ScaleTransform();
transform = target.RenderTransform as ScaleTransform;
if (CenterScale)
target.RenderTransformOrigin = new Point(.5, .5);
else
target.RenderTransformOrigin = new Point(0, 0);
}
var sb = new Storyboard();
var scaleAnimation = new DoubleAnimation { Duration = new Duration(TimeSpan.FromSeconds(Duration)), From = 1, To = ScaleTo };
Storyboard.SetTarget(scaleAnimation, target);
Storyboard.SetTargetProperty(scaleAnimation, "(UIElement.RenderTransform).(CompositeTransform.ScaleX)");
sb.Children.Add(scaleAnimation);
scaleAnimation = new DoubleAnimation { Duration = new Duration(TimeSpan.FromSeconds(Duration)), From = 1, To = ScaleTo };
Storyboard.SetTarget(scaleAnimation, target);
Storyboard.SetTargetProperty(scaleAnimation, "(UIElement.RenderTransform).(CompositeTransform.ScaleY)");
sb.Children.Add(scaleAnimation);
//transform.BeginAnimation(ScaleTransform.ScaleXProperty, scaleAnimation);
//transform.BeginAnimation(ScaleTransform.ScaleYProperty, scaleAnimation);
sb.Begin();
}
示例4: UIElement_OnPointerEntered
private void UIElement_OnPointerEntered(object sender, PointerRoutedEventArgs e)
{
var border = (Border)sender;
// Somehow ZIndex doesn't work in the UniformGrid
// Perhaps if Jupiter had a method called Panel.GetVisualChild available to override...
// See: http://blog.pixelingene.com/2007/12/controlling-z-index-of-children-in-custom-controls/
//Canvas.SetZIndex(border, ++_maxZIndex);
var sb = new Storyboard();
var a1 = new DoubleAnimation();
a1.Duration = TimeSpan.FromSeconds(0.2);
a1.To = 0.9;
a1.EasingFunction = new PowerEase { Power = 2, EasingMode = EasingMode.EaseOut };
Storyboard.SetTarget(a1, border.RenderTransform);
Storyboard.SetTargetProperty(a1, "ScaleX");
sb.Children.Add(a1);
var a2 = new DoubleAnimation();
a2.Duration = TimeSpan.FromSeconds(0.2);
a2.To = 0.9;
a2.EasingFunction = new PowerEase { Power = 2, EasingMode = EasingMode.EaseOut };
Storyboard.SetTarget(a2, border.RenderTransform);
Storyboard.SetTargetProperty(a2, "ScaleY");
sb.Children.Add(a2);
sb.Begin();
}
示例5: MoveTo
public void MoveTo(Point from, Point to, EventHandler<object> completed = null)
{
TranslateTransform trans = new TranslateTransform();
_participant.Name = "MyTarget";
_participant.RenderTransform = trans;
DoubleAnimation anim1 = new DoubleAnimation() { From = from.X, To = to.X, Duration = TimeSpan.FromMilliseconds(Utility.GAME_TICK_MS - 1) };
DoubleAnimation anim2 = new DoubleAnimation() { From = from.Y, To = to.Y, Duration = TimeSpan.FromMilliseconds(Utility.GAME_TICK_MS - 1) };
Storyboard.SetTarget(anim1, _participant);
Storyboard.SetTargetName(anim1, _participant.Name);
Storyboard.SetTargetProperty(anim1, "(Canvas.Left)");
Storyboard.SetTarget(anim2, _participant);
Storyboard.SetTargetName(anim2, _participant.Name);
Storyboard.SetTargetProperty(anim2, "(Canvas.Top)");
Storyboard sb = new Storyboard();
sb.Children.Add(anim1);
sb.Children.Add(anim2);
if (completed == null)
sb.Completed += (object sender, object e) => { };
else
sb.Completed += completed;
sb.Begin();
}
示例6: StartAnimation
/// <summary>
/// Starts new animation from given images.
/// </summary>
/// <param name="imageNames">Names of images in assets folder</param>
/// <param name="interval">Interval between animation frames</param>
public void StartAnimation(IEnumerable<string> imageNames, TimeSpan interval)
{
Storyboard storyboard = new Storyboard();
ObjectAnimationUsingKeyFrames animation = new ObjectAnimationUsingKeyFrames();
// We're going to animate image inside our control.
Storyboard.SetTarget(animation, image);
// Animation relies on changing value of property source
Storyboard.SetTargetProperty(animation, nameof(image.Source));
TimeSpan currentInterval = TimeSpan.FromMilliseconds(0);
foreach (string imageName in imageNames)
{
// We're creating individual frames from given images
ObjectKeyFrame keyFrame = new DiscreteObjectKeyFrame();
keyFrame.Value = CreateImageFromAssets(imageName);
keyFrame.KeyTime = currentInterval;
animation.KeyFrames.Add(keyFrame);
currentInterval = currentInterval.Add(interval);
}
// We're configuring our storyboard which will play animations
storyboard.RepeatBehavior = RepeatBehavior.Forever;
storyboard.AutoReverse = true;
storyboard.Children.Add(animation);
storyboard.Begin();
}
示例7: AnimateOpacity
static public void AnimateOpacity(FrameworkElement element, double start, double end, double duration)
{
element.Opacity = 0;
Duration animationDuration = new Duration(TimeSpan.FromSeconds(duration));
DoubleAnimation opacityAnimation = new DoubleAnimation();
opacityAnimation.Duration = animationDuration;
opacityAnimation.From = start;
opacityAnimation.To = end;
Storyboard sb = new Storyboard();
sb.Duration = animationDuration;
sb.Children.Add(opacityAnimation);
Storyboard.SetTarget(opacityAnimation, element);
// Set the X and Y properties of the Transform to be the target properties
// of the two respective DoubleAnimations.
Storyboard.SetTargetProperty(opacityAnimation, "Opacity");
// Begin the animation.
sb.Begin();
}
示例8: FadeIn
private void FadeIn()
{
if (_Running)
{
DoubleAnimation fadeIn = new DoubleAnimation();
fadeIn.From = 0.0;
fadeIn.To = 1;
fadeIn.Duration = new Duration(TimeSpan.FromSeconds(2));
fadeIn.BeginTime = TimeSpan.FromSeconds(2);
Storyboard sb = new Storyboard();
Storyboard.SetTarget(fadeIn, _Control);
Storyboard.SetTargetProperty(fadeIn, "Opacity");
sb.Children.Add(fadeIn);
_Control.Resources.Clear();
_Control.Resources.Add("FaderEffect", sb);
sb.Completed += this.OnFadeInCompleted;
sb.Begin();
}
}
示例9: Animate
public static void Animate(this UIElement element, double from, double to, double fullDistance)
{
if (element == null)
{
throw new ArgumentNullException("element");
}
var transform = new TranslateTransform();
element.RenderTransform = transform;
var xAnimation = new DoubleAnimation
{
From = from,
Duration = TimeSpan.FromMilliseconds(GetAnimationSpeed(from, to, fullDistance)),
To = to,
EnableDependentAnimation = true,
EasingFunction = new SineEase() { EasingMode = EasingMode.EaseOut }
};
Storyboard.SetTarget(xAnimation, transform);
Storyboard.SetTargetProperty(xAnimation, "X");
var storyboard = new Storyboard();
storyboard.Children.Add(xAnimation);
storyboard.Begin();
}
示例10: BeginAnimation
private static void BeginAnimation(DependencyObject obj, string property, Timeline animation)
{
Storyboard.SetTargetProperty(animation, property);
Storyboard.SetTarget(animation, obj);
var storyboard = new Storyboard();
storyboard.Children.Add(animation);
storyboard.Begin();
}
示例11: BeginAnimation
public static void BeginAnimation(this DependencyObject target, Timeline animation, string path)
{
var sb = new Storyboard();
Storyboard.SetTarget(animation, target);
Storyboard.SetTargetProperty(animation, path);
sb.Children.Add(animation);
sb.Begin();
}
示例12: ShowUpAnimation
private static void ShowUpAnimation(UIElement element)
{
var animation = new PointerUpThemeAnimation();
Storyboard.SetTarget(animation, element);
var storyboard = new Storyboard();
storyboard.Children.Add(animation);
storyboard.Begin();
}
示例13: Flip
public static void Flip(UIElement ctrl, UIElement frontCtrl, UIElement backCtrl, TimeSpan duration, bool transitionToBack, Action completed = null)
{
duration = new TimeSpan(duration.Ticks / 2);
var proj = ctrl.Projection is PlaneProjection ? (PlaneProjection)ctrl.Projection : new PlaneProjection();
if (ctrl.Projection != proj)
ctrl.Projection = proj;
var animation = new DoubleAnimation();
animation.From = 0.0;
animation.To = 90.0 * (transitionToBack ? 1 : -1);
animation.Duration = new Duration(duration);
var story = new Storyboard();
story.Children.Add(animation);
Storyboard.SetTarget(animation, proj);
Storyboard.SetTargetProperty(animation, "RotationY");
story.Completed += delegate
{
animation = new DoubleAnimation();
animation.From = 270.0 * (transitionToBack ? 1 : -1);
animation.To = 360.0 * (transitionToBack ? 1 : -1);
animation.Duration = new Duration(duration);
story = new Storyboard();
story.Children.Add(animation);
Storyboard.SetTarget(animation, proj);
Storyboard.SetTargetProperty(animation, "RotationY");
frontCtrl.Visibility = transitionToBack ? Visibility.Collapsed : Visibility.Visible;
backCtrl.Visibility = !transitionToBack ? Visibility.Collapsed : Visibility.Visible;
story.Completed += delegate
{
proj.RotationY = 0.0;
if (completed != null)
completed();
};
story.Begin();
};
story.Begin();
}
示例14: FadeIn
public static void FadeIn(UIElement element)
{
element.Visibility = Visibility.Visible;
var fadeInStoryboard = new Storyboard();
var fadeInAnimation = new FadeInThemeAnimation();
Storyboard.SetTarget(fadeInAnimation, element);
fadeInStoryboard.Children.Add(fadeInAnimation);
fadeInStoryboard.Begin();
}
示例15: FadeOut
public static void FadeOut(UIElement element)
{
var fadeOutStoryboard = new Storyboard();
var fadeOutAnimation = new FadeOutThemeAnimation();
Storyboard.SetTarget(fadeOutAnimation, element);
fadeOutStoryboard.Children.Add(fadeOutAnimation);
fadeOutStoryboard.Completed += (sender, o) => element.Visibility = Visibility.Collapsed;
fadeOutStoryboard.Begin();
}