本文整理汇总了C#中Visual.StartAnimation方法的典型用法代码示例。如果您正苦于以下问题:C# Visual.StartAnimation方法的具体用法?C# Visual.StartAnimation怎么用?C# Visual.StartAnimation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Visual
的用法示例。
在下文中一共展示了Visual.StartAnimation方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AnimateFromCurrentByValue
// Creates and defines the Keyframe animation using a current value of target Visual and animating by a value
private void AnimateFromCurrentByValue(Visual targetVisual, Vector3 delta)
{
var animation = _compositor.CreateVector3KeyFrameAnimation();
// Utilize a current value of the target visual in Expression KeyFrame and modify by a value
animation.InsertExpressionKeyFrame(1.00f, "this.StartingValue + delta");
// Define the value variable
animation.SetVector3Parameter("delta", delta);
animation.Duration = TimeSpan.FromMilliseconds(1000);
targetVisual.StartAnimation("Offset", animation);
}
示例2: Animate
private void Animate(Visual visual)
{
var easing = this.compositor.CreateCubicBezierEasingFunction(new Vector2(.5f, .1f), new Vector2(.5f, .75f));
var animation = this.compositor.CreateScalarKeyFrameAnimation();
animation.InsertKeyFrame(0.00f, 0.00f, easing);
animation.InsertKeyFrame(1.00f, 360.0f, easing);
animation.Duration = TimeSpan.FromMilliseconds(2000);
animation.IterationBehavior = AnimationIterationBehavior.Forever;
visual.StartAnimation("RotationAngleinDegrees", animation);
}
示例3: AnimateFromCurrentValue
// Creates and defines the Keyframe animation using a current value of target Visual
private void AnimateFromCurrentValue(Visual targetVisual, Vector3 finalOffset)
{
var animation = _compositor.CreateVector3KeyFrameAnimation();
// Utilize a current value of the target visual in Expression KeyFrame
// Note: If a keyframe at 0.0f not defined, we will auto define it using this.StartingValue.
animation.InsertExpressionKeyFrame(0.00f, "this.StartingValue");
animation.InsertKeyFrame(1.00f, finalOffset);
animation.Duration = TimeSpan.FromMilliseconds(3000);
targetVisual.StartAnimation("Offset", animation);
}
示例4: Parallax_Animation
// Creates and Defines Expression Animation for basic Parallax principle
private void Parallax_Animation(Visual foreground, Visual background)
{
var animation = _compositor.CreateExpressionAnimation("background.Offset.x * (foreground.Size.X / background.Size.X)");
animation.SetReferenceParameter("foreground", foreground);
animation.SetReferenceParameter("background", background);
background.StartAnimation("Offset.x", animation);
}
示例5: OnSizeChanged
private void OnSizeChanged(object sender, Windows.UI.Xaml.SizeChangedEventArgs e)
{
Vector2 size = new System.Numerics.Vector2((float)this.ActualWidth, (float)this.ActualHeight);
if (m_interactionTracker != null)
{
m_interactionTracker.MinPosition = new Vector3(-size.X, 0, 0);
m_interactionTracker.MaxPosition = new Vector3(size.X, 0, 0);
if (Content != null)
{
var positionExpression = m_compositor.CreateExpressionAnimation("-tracker.Position");
positionExpression.SetReferenceParameter("tracker", m_interactionTracker);
m_contentVisual = ElementCompositionPreview.GetElementVisual(Content);
m_contentVisual.StartAnimation("Offset", positionExpression);
m_contentVisual.Size = size;
if (m_setUpExpressions && m_progressAnimation == null)
{
m_progressAnimation = m_compositor.CreateExpressionAnimation(
"clamp(visual.Offset.X / visual.Size.X, -1, 1)");
m_progressAnimation.SetReferenceParameter("visual", m_contentVisual);
m_rootVisual.Properties.StartAnimation("NormalizedProgress", m_progressAnimation);
}
}
}
}
示例6: ScrollViewer_Loaded
private void ScrollViewer_Loaded(object sender, RoutedEventArgs e)
{
_scrollViewer.DirectManipulationStarted += ScrollViewer_DirectManipulationStarted;
_scrollViewer.DirectManipulationCompleted += ScrollViewer_DirectManipulationCompleted;
var border = (Border)VisualTreeHelper.GetChild(_scrollViewer, 0);
_scrollViewerBorder = border;
_scrollerViewerManipulation = ElementCompositionPreview.GetScrollViewerManipulationPropertySet(_scrollViewer);
_compositor = _scrollerViewerManipulation.Compositor;
double ratio = 1.0;
_header.Measure(new Size(this.ActualWidth, this.ActualHeight));
var headerHeight = _header.DesiredSize.Height;
if (headerHeight == 0)
{
headerHeight = 50;
}
if (RefreshThreshold == 0.0)
{
RefreshThreshold = headerHeight;
}
ratio = RefreshThreshold / headerHeight;
_offsetAnimation = _compositor.CreateExpressionAnimation("(min(max(0, ScrollManipulation.Translation.Y * ratio) / Divider, 1)) * MaxOffsetY");
_offsetAnimation.SetScalarParameter("Divider", (float)RefreshThreshold);
_offsetAnimation.SetScalarParameter("MaxOffsetY", (float)RefreshThreshold * 5 / 4);
_offsetAnimation.SetScalarParameter("ratio", (float)ratio);
_offsetAnimation.SetReferenceParameter("ScrollManipulation", _scrollerViewerManipulation);
_opacityAnimation = _compositor.CreateExpressionAnimation("min((max(0, ScrollManipulation.Translation.Y * ratio) / Divider), 1)");
_opacityAnimation.SetScalarParameter("Divider", (float)headerHeight);
_opacityAnimation.SetScalarParameter("ratio", (float)1);
_opacityAnimation.SetReferenceParameter("ScrollManipulation", _scrollerViewerManipulation);
_headerVisual = ElementCompositionPreview.GetElementVisual(_header);
_contentVisual = ElementCompositionPreview.GetElementVisual(_scrollViewerBorder);
_headerVisual.StartAnimation("Offset.Y", _offsetAnimation);
_headerVisual.StartAnimation("Opacity", _opacityAnimation);
_contentVisual.StartAnimation("Offset.Y", _offsetAnimation);
}
示例7: ConfigureGearAnimation
private void ConfigureGearAnimation(Visual currentGear, Visual previousGear)
{
// If rotation expression is null then create an expression of a gear rotating the opposite direction
_rotationExpression = _rotationExpression ?? _compositor.CreateExpressionAnimation("-previousGear.RotationAngleInDegrees");
// put in placeholder parameters
_rotationExpression.SetReferenceParameter("previousGear", previousGear);
// Start the animation based on the Rotation Angle in Degrees.
currentGear.StartAnimation("RotationAngleInDegrees", _rotationExpression);
}
示例8: CreateVisual
private void CreateVisual()
{
visual = ElementCompositionPreview.GetElementVisual(currentTopGroupHeader);
var scrollViewerManipProps = ElementCompositionPreview.GetScrollViewerManipulationPropertySet(scrollViewer);
Compositor compositor = scrollViewerManipProps.Compositor;
expression = compositor.CreateExpressionAnimation("max(0,ScrollViewerManipProps.Translation.Y)");
// set "dynamic" reference parameter that will be used to evaluate the current position of the scrollbar every frame
expression.SetReferenceParameter("ScrollViewerManipProps", scrollViewerManipProps);
visual.StartAnimation("Offset.Y", expression);
//Windows.UI.Xaml.Media.CompositionTarget.Rendering += OnCompositionTargetRendering;
}
示例9: AnimateOpacity
// Creates and defines Expression Animation to modify target object's property by referencing another Visual's property
private void AnimateOpacity(Visual sourceVisual, Visual targetVisual)
{
// Reference the Opacity property of another Composition Visual in the expression
var expression = _compositor.CreateExpressionAnimation("source.Opacity");
expression.SetReferenceParameter("source", sourceVisual);
targetVisual.StartAnimation("Opacity", expression);
}
示例10: AnimateOffset
void AnimateOffset(Visual visual, Vector3 oldOffset, Vector3 newOffset)
{
var animation = compositor.CreateVector3KeyFrameAnimation();
animation.InsertKeyFrame(0, oldOffset);
animation.InsertKeyFrame(1, newOffset);
animation.Duration = TimeSpan.FromSeconds(1);
visual.StartAnimation("Offset", animation);
}
示例11: UpdateVisualOpacity
void UpdateVisualOpacity(Visual visual)
{
var oldOpacity = visual.Opacity;
var newOpacity = (float)rnd.NextDouble();
var animation = compositor.CreateScalarKeyFrameAnimation();
animation.InsertKeyFrame(0, oldOpacity);
animation.InsertKeyFrame(1, newOpacity);
visual.Opacity = newOpacity;
visual.StartAnimation("Opacity", animation);
}
示例12: Animation1
// Defines a KeyFrame animation to animate offset
public void Animation1(Visual _target)
{
var animation = _compositor.CreateVector3KeyFrameAnimation();
animation.InsertKeyFrame(1.0f, new Vector3(175.0f, 250.0f, 0.0f));
animation.Duration = TimeSpan.FromMilliseconds(2000);
_target.StartAnimation("Offset", animation);
}
示例13: Animation2
// Defines a KeyFrame animation to animate rotation
public void Animation2(Visual _target)
{
var animation2 = _compositor.CreateScalarKeyFrameAnimation();
animation2.InsertKeyFrame(0.00f, 0.00f, _linear);
animation2.InsertKeyFrame(0.50f, 180.0f, _linear);
animation2.InsertKeyFrame(1.00f, 360.0f, _linear);
animation2.Duration = TimeSpan.FromMilliseconds(2000);
animation2.IterationCount = 5;
_target.StartAnimation("RotationAngleinDegrees", animation2);
}
示例14: Animation3
// Defines a KeyFrame animation to animate opacity
public void Animation3(Visual _target)
{
var animation3 = _compositor.CreateScalarKeyFrameAnimation();
animation3.InsertKeyFrame(0.00f, 1.00f);
animation3.InsertKeyFrame(0.50f, 0.50f);
animation3.InsertKeyFrame(1.00f, 1.00f);
animation3.Duration = TimeSpan.FromMilliseconds(2000);
_target.StartAnimation("Opacity", animation3);
}