本文整理汇总了C#中Windows.UI.Xaml.Media.Animation.Storyboard.Stop方法的典型用法代码示例。如果您正苦于以下问题:C# Storyboard.Stop方法的具体用法?C# Storyboard.Stop怎么用?C# Storyboard.Stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Windows.UI.Xaml.Media.Animation.Storyboard
的用法示例。
在下文中一共展示了Storyboard.Stop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Show
public void Show()
{
//2s之内连续按2次,退出
if (clickCount > 0)
{
if (Completed != null)
{
Completed(true);
}
}
else
{
clickCount++;
if (Completed != null)
{
Completed(false);
}
var tips = new JMessboxControl();
tips.DataContext = this;
popup.Height = 65;
popup.Width = 200;
popup.Margin = new Thickness(140, 380, 0, 0);
popup.IsOpen = false;
popup.Child = tips;
//渐变效果:透明度200毫秒内从0->1
Storyboard story = new Storyboard();
DoubleAnimation topAnimation = new DoubleAnimation();
topAnimation.From = 0;
topAnimation.To = 1;
topAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(200));
Storyboard.SetTarget(topAnimation, tips);
Storyboard.SetTargetProperty(topAnimation, "(UIElement.Opacity)");
story.Children.Add(topAnimation);
popup.IsOpen = true;
story.Begin();
//动画延迟2秒
story.Duration = new Duration(new TimeSpan(0, 0, 2));
//story.BeginTime = new TimeSpan(0, 0, 0, 0, 1);
story.Completed += (s1, e1) =>
{
//2s后执行此方法
clickCount = 0;
popup.IsOpen = false;
story.Stop();
};
}
}
示例2: FadeOutCustom
/// <summary>
/// Fades the element out using a custom DoubleAnimation of the Opacity property.
/// </summary>
/// <param name="element"></param>
/// <param name="duration"></param>
/// <param name="easingFunction"> </param>
/// <returns></returns>
public static async Task FadeOutCustom(this UIElement element, TimeSpan? duration = null, EasingFunctionBase easingFunction = null)
{
CleanUpPreviousFadeStoryboard(element);
var fadeOutStoryboard = new Storyboard();
var fadeOutAnimation = new DoubleAnimation();
if (duration == null)
duration = TimeSpan.FromSeconds(0.4);
fadeOutAnimation.Duration = duration.Value;
fadeOutAnimation.To = 0.0;
fadeOutAnimation.EasingFunction = easingFunction;
Storyboard.SetTarget(fadeOutAnimation, element);
Storyboard.SetTargetProperty(fadeOutAnimation, "Opacity");
fadeOutStoryboard.Children.Add(fadeOutAnimation);
SetAttachedFadeStoryboard(element, fadeOutStoryboard);
await fadeOutStoryboard.BeginAsync();
element.Opacity = 0.0;
fadeOutStoryboard.Stop();
}
示例3: FadeIn
/// <summary>
/// Fades the element in using the FadeInThemeAnimation.
/// </summary>
/// <remarks>
/// Opacity property of the element is not affected.<br/>
/// The duration of the visible animation itself is not affected by the duration parameter. It merely indicates how long the Storyboard will run.<br/>
/// If FadeOutThemeAnimation was not used on the element before - nothing will happen.<br/>
/// </remarks>
/// <param name="element"></param>
/// <param name="duration"></param>
/// <returns></returns>
public static async Task FadeIn(this UIElement element, TimeSpan? duration = null)
{
// CleanUpPreviousFadeStoryboard(element);
((FrameworkElement)element).Visibility = Visibility.Visible;
var fadeInStoryboard = new Storyboard();
var fadeInAnimation = new FadeInThemeAnimation();
if (duration != null)
{
fadeInAnimation.Duration = duration.Value;
}
Storyboard.SetTarget(fadeInAnimation, element);
fadeInStoryboard.Children.Add(fadeInAnimation);
await fadeInStoryboard.BeginAsync();
fadeInStoryboard.Stop();
}
示例4: PopupWithAnim
private static void PopupWithAnim()
{
Storyboard story = new Storyboard();
DoubleAnimation popupUpAnim = CreateDoubleAnimation(_popup.RenderTransform, "Y", new BackEase() { Amplitude = 0.6, EasingMode = EasingMode.EaseOut }, PopupPosition, AnimDuration);
story.Children.Add(popupUpAnim);
story.Completed +=(s, e)=>
{
story = new Storyboard();
DoubleAnimation popupDownAnim = CreateDoubleAnimation(_popup.RenderTransform, "Y", new BackEase() { Amplitude = 0.6, EasingMode = EasingMode.EaseIn }, 0, AnimDuration);
popupDownAnim.BeginTime = TimeSpan.FromMilliseconds(PopupStayTime);
story.Children.Add(popupDownAnim);
story.Completed += (s1, e1) =>
{
story.Stop();
Interlocked.Decrement(ref _popupState);
Popup();
};
story.Begin();
};
story.Begin();
}
示例5: StaggeredStateChange
/// <summary>
/// Reveals data points using a storyboard.
/// </summary>
/// <param name="dataPoints">The data points to change the state of.
/// </param>
/// <param name="dataPointCount">The number of data points in the sequence.</param>
/// <param name="newState">The state to change to.</param>
private void StaggeredStateChange(IEnumerable<DataPoint> dataPoints, int dataPointCount, DataPointState newState)
{
if (PlotArea == null || dataPointCount == 0)
{
return;
}
Storyboard stateChangeStoryBoard = new Storyboard();
dataPoints.ForEachWithIndex((dataPoint, count) =>
{
// Create an Animation
ObjectAnimationUsingKeyFrames objectAnimationUsingKeyFrames = new ObjectAnimationUsingKeyFrames();
objectAnimationUsingKeyFrames.EnableDependentAnimation = true;
Storyboard.SetTarget(objectAnimationUsingKeyFrames, dataPoint);
Storyboard.SetTargetProperty(objectAnimationUsingKeyFrames, "State");
// Create a key frame
DiscreteObjectKeyFrame discreteObjectKeyFrame = new DiscreteObjectKeyFrame();
discreteObjectKeyFrame.Value = (object)((int)newState);
// Create the specified animation type
switch (AnimationSequence)
{
case AnimationSequence.Simultaneous:
discreteObjectKeyFrame.KeyTime = TimeSpan.Zero;
break;
case AnimationSequence.FirstToLast:
discreteObjectKeyFrame.KeyTime = TimeSpan.FromMilliseconds(1000 * ((double)count / dataPointCount));
break;
case AnimationSequence.LastToFirst:
discreteObjectKeyFrame.KeyTime = TimeSpan.FromMilliseconds(1000 * ((double)(dataPointCount - count - 1) / dataPointCount));
break;
}
// Add the Animation to the Storyboard
objectAnimationUsingKeyFrames.KeyFrames.Add(discreteObjectKeyFrame);
stateChangeStoryBoard.Children.Add(objectAnimationUsingKeyFrames);
});
//stateChangeStoryBoard.Duration = new Duration(AnimationSequence.Simultaneous == AnimationSequence ?
// TimeSpan.FromTicks(1) :
// TimeSpan.FromMilliseconds(1001));
_storyBoardQueue.Enqueue(
stateChangeStoryBoard,
(sender, args) =>
{
stateChangeStoryBoard.Stop();
});
}
示例6: PerformRotationChange
private void PerformRotationChange()
{
if (_mainButton == null)
{
return;
}
double from = LookupFromAngle();
double to = LookupToAngle();
DoubleAnimation d = new DoubleAnimation()
{
BeginTime = new TimeSpan(0),
Duration = new Duration(TimeSpan.FromMilliseconds(450)),
From = from,
To = to,
FillBehavior = FillBehavior.HoldEnd
};
Storyboard s = new Storyboard();
s.Children.Add(d);
Storyboard.SetTarget(d, _mainButton);
Storyboard.SetTargetProperty(d, "(UIElement.RenderTransform).(RotateTransform.Angle)");
s.Begin();
d.Completed += delegate
{
RotateTransform rTransform = _mainButton.RenderTransform as RotateTransform;
if (rTransform != null)
{
rTransform.Angle = to;
}
s.Stop();
};
}
示例7: SearchingFadeIn
private void SearchingFadeIn()
{
SearchingPanel.Visibility = Visibility.Visible;
Storyboard sb = new Storyboard() { Duration = new Duration(TimeSpan.FromSeconds(0.5)) };
FadeInThemeAnimation fadeAnim = new FadeInThemeAnimation() { Duration = new Duration(TimeSpan.FromSeconds(0.5)) };
Storyboard.SetTarget(fadeAnim, SearchingPanel);
sb.Children.Add(fadeAnim);
sb.Completed += delegate
{
sb.Stop();
};
sb.Begin();
}
示例8: PivotFadeOut
private void PivotFadeOut(bool searchFadeIn)
{
Storyboard sb = new Storyboard() { Duration = new Duration(TimeSpan.FromSeconds(0.5)) };
FadeOutThemeAnimation fadeAnim = new FadeOutThemeAnimation() { Duration = new Duration(TimeSpan.FromSeconds(0.5)) };
Storyboard.SetTarget(fadeAnim, PivotControl);
sb.Children.Add(fadeAnim);
sb.Completed += delegate
{
PivotControl.Visibility = Visibility.Collapsed;
sb.Stop();
if (searchFadeIn) SearchingFadeIn();
};
sb.Begin();
}
示例9: TypeToSearchFadeOut
private void TypeToSearchFadeOut()
{
Storyboard sb = new Storyboard() { Duration = new Duration(TimeSpan.FromSeconds(0.5)) };
FadeOutThemeAnimation fadeAnim = new FadeOutThemeAnimation() { Duration = new Duration(TimeSpan.FromSeconds(0.5)) };
Storyboard.SetTarget(fadeAnim, TypeToSearchPanel);
sb.Children.Add(fadeAnim);
DoubleAnimation doubleAnim = new DoubleAnimation() { To = 20, From = 0, Duration = new Duration(TimeSpan.FromSeconds(0.5)) };
TranslateTransform translate = new TranslateTransform();
doubleAnim.EnableDependentAnimation = true;
TypeToSearchPanel.RenderTransform = translate;
Storyboard.SetTarget(doubleAnim, translate);
Storyboard.SetTargetProperty(doubleAnim, "Y");
sb.Children.Add(doubleAnim);
sb.Completed += delegate
{
TypeToSearchPanel.Visibility = Visibility.Collapsed;
sb.Stop();
};
sb.Begin();
}
示例10: TransitionBackward
/// <summary>
/// Runs backward transition.
/// </summary>
/// <param name="previousPage">The previous page.</param>
/// <param name="newPage">The new page.</param>
/// <returns>The task that completes when the transition is complete.</returns>
/// <exception cref="System.ArgumentNullException"></exception>
public async Task TransitionBackward(DependencyObject previousPage, DependencyObject newPage)
{
if (previousPage == null && newPage == null)
{
throw new ArgumentNullException("newPage");
}
PrepareBackwardAnimations(previousPage, newPage);
UpdateTimelineAttributes();
if (previousPage == null)
{
await BackwardInAnimation.Animate(newPage);
}
else if (newPage == null)
{
await BackwardOutAnimation.Animate(previousPage);
}
else if (this.Mode == PageTransitionMode.Parallel)
{
var sb = new Storyboard();
Storyboard outSb = null;
Storyboard inSb = null;
if (this.BackwardOutAnimation != null)
{
outSb = this.BackwardOutAnimation.GetAnimation(previousPage);
sb.Children.Add(outSb);
}
if (this.BackwardInAnimation != null)
{
inSb = this.BackwardInAnimation.GetAnimation(newPage);
sb.Children.Add(inSb);
}
await sb.BeginAsync();
sb.Stop();
sb.Children.Clear();
if (this.BackwardOutAnimation != null)
{
this.BackwardOutAnimation.CleanupAnimation(previousPage, outSb);
}
if (this.BackwardInAnimation != null)
{
this.BackwardInAnimation.CleanupAnimation(newPage, inSb);
}
//await Task.WhenAll(
// BackwardOutAnimation.Animate(previousPage),
// BackwardInAnimation.Animate(newPage));
}
else
{
if (this.BackwardOutAnimation != null)
{
await this.BackwardOutAnimation.Animate(previousPage);
}
if (this.BackwardInAnimation != null)
{
await this.BackwardInAnimation.Animate(newPage);
}
}
CleanupBackwardAnimations(previousPage, newPage);
}
示例11: Cascade
//.........这里部分代码省略.........
brush.ImageSource = this.ImageSource;
rect.Fill = brush;
var transform = new CompositeTransform();
transform.TranslateX = -column;
transform.ScaleX = Columns;
transform.TranslateY = -row;
transform.ScaleY = Rows;
brush.RelativeTransform = transform;
var projection = new PlaneProjection();
projection.CenterOfRotationY = 0;
rect.Projection = projection;
projs.Add(projection);
_layoutGrid.Children.Add(rect);
}
var indices = new List<int>(Rows * Columns);
for (int i = 0; i < Rows * Columns; i++)
indices.Add(i);
if (direction == CascadeDirection.Shuffle)
{
indices = indices.Shuffle();
}
for (int ii = 0; ii < indices.Count; ii++)
{
var i = indices[ii];
var projection = projs[i];
var rect = rects[i];
var column = rectCoords[ii].Item1;
var row = rectCoords[ii].Item2;
//Debug.WriteLine("i: {0}, p: {1}, rect: {2}, c: {3}, r: {4}", i, projection.GetHashCode(), rect.GetHashCode(), column, row);
var rotationAnimation = new DoubleAnimationUsingKeyFrames();
Storyboard.SetTarget(rotationAnimation, projection);
Storyboard.SetTargetProperty(rotationAnimation, "RotationX");
var endKeyTime =
this.CascadeSequence == CascadeSequence.EndTogether
? TimeSpan.FromSeconds(totalDurationInSeconds)
: TimeSpan.FromSeconds(
(double)row * RowDelay.TotalSeconds +
(double)column * ColumnDelay.TotalSeconds +
TileDuration.TotalSeconds);
rotationAnimation.KeyFrames.Add(
new DiscreteDoubleKeyFrame
{
KeyTime = TimeSpan.Zero,
Value = 90
});
rotationAnimation.KeyFrames.Add(
new DiscreteDoubleKeyFrame
{
KeyTime = TimeSpan.FromSeconds((double)row * RowDelay.TotalSeconds + (double)column * ColumnDelay.TotalSeconds),
Value = 90
});
rotationAnimation.KeyFrames.Add(
new EasingDoubleKeyFrame
{
KeyTime = endKeyTime,
EasingFunction = CascadeInEasingFunction,
Value = 0
});
sb.Children.Add(rotationAnimation);
var opacityAnimation = new DoubleAnimationUsingKeyFrames();
Storyboard.SetTarget(opacityAnimation, rect);
Storyboard.SetTargetProperty(opacityAnimation, "Opacity");
opacityAnimation.KeyFrames.Add(
new DiscreteDoubleKeyFrame
{
KeyTime = TimeSpan.Zero,
Value = 0
});
opacityAnimation.KeyFrames.Add(
new DiscreteDoubleKeyFrame
{
KeyTime = TimeSpan.FromSeconds((double)row * RowDelay.TotalSeconds + (double)column * ColumnDelay.TotalSeconds),
Value = 0
});
opacityAnimation.KeyFrames.Add(
new EasingDoubleKeyFrame
{
KeyTime = endKeyTime,
EasingFunction = CascadeInEasingFunction,
Value = 1
});
sb.Children.Add(opacityAnimation);
}
sb.Begin();
sb.Completed += (s, e) => sb.Stop();
}
示例12: animateCard
//a dynamic story board that uses tasks to auto complete themselves when the duration is complete
private async Task animateCard(String imageNm, Player p)
{
Storyboard sb = new Storyboard();
DoubleAnimation da = new DoubleAnimation();
Storyboard.SetTargetProperty(da, "Opacity");
Storyboard.SetTarget(da, srchImg(imageNm, getImgArr(p)));
srchImg(imageNm, getImgArr(p)).Source = new BitmapImage(new Uri(base.BaseUri, "/Resources/CardBack.png"));
da.From = 0;
da.To = 2;
da.AutoReverse = true;
da.EnableDependentAnimation = true;
da.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 50));
sb.Children.Add(da);
sb.Begin();
await Task.Delay((int)da.Duration.TimeSpan.TotalMilliseconds);
sb.Stop();
}
示例13: ScrollToVerticalOffsetWithAnimation
internal async Task ScrollToVerticalOffsetWithAnimation(
double offset,
TimeSpan duration,
EasingFunctionBase easingFunction)
{
var sb = new Storyboard();
var da = new DoubleAnimation();
da.EnableDependentAnimation = true;
da.From = _scrollViewer.VerticalOffset;
da.To = offset;
da.EasingFunction = easingFunction;
da.Duration = duration;
sb.Children.Add(da);
Storyboard.SetTarget(sb, _sliderVertical);
Storyboard.SetTargetProperty(da, "Value");
await sb.BeginAsync();
sb.Stop();
if (_scrollViewer != null)
{
_scrollViewer.ScrollToVerticalOffset(offset);
}
}
示例14: Flip
private void Flip(Tile tile, Storyboard sb)
{
sb.Stop();
animating = true;
Storyboard.SetTargetName(sb, tile.Rect.Name);
if (tile.Faceup)
{
//getting a color animation from a storyboard *could* be easier...
sb.Children.OfType<ColorAnimation>().First().To = Tile.FaceDownColor;
}
else
{
sb.Children.OfType<ColorAnimation>().First().To = Tile.FaceUpColor;
}
//Override the stretch with an actual height to allow the storyboard to run
tile.Rect.Height = tile.Rect.ActualHeight;
tile.Rect.Width = tile.Rect.ActualWidth;
sb.Begin();
}
示例15: TransitionBackward
public async Task TransitionBackward(DependencyObject previousPage, DependencyObject newPage)
{
if (previousPage == null && newPage == null)
{
throw new InvalidOperationException();
}
if (previousPage == null)
{
await BackwardInAnimation.Animate(newPage);
}
else if (newPage == null)
{
await BackwardOutAnimation.Animate(previousPage);
}
else if (this.Mode == PageTransitionMode.Parallel)
{
var sb = new Storyboard();
var outSb = BackwardOutAnimation.GetAnimation(previousPage);
var inSb = BackwardInAnimation.GetAnimation(newPage);
sb.Children.Add(outSb);
sb.Children.Add(inSb);
await sb.BeginAsync();
sb.Stop();
sb.Children.Clear();
//await Task.WhenAll(
// BackwardOutAnimation.Animate(previousPage),
// BackwardInAnimation.Animate(newPage));
}
else
{
await BackwardOutAnimation.Animate(previousPage);
await BackwardInAnimation.Animate(newPage);
}
}