本文整理汇总了C#中Compositor.CreateFinalValueExpression方法的典型用法代码示例。如果您正苦于以下问题:C# Compositor.CreateFinalValueExpression方法的具体用法?C# Compositor.CreateFinalValueExpression怎么用?C# Compositor.CreateFinalValueExpression使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Compositor
的用法示例。
在下文中一共展示了Compositor.CreateFinalValueExpression方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitializeComposition
/// <summary>
/// Initialize all Composition related stuff here (Compositor, Animations etc)
/// </summary>
private void InitializeComposition()
{
var rootVisual = ElementCompositionPreview.GetElementVisual(this);
// Compositor
_compositor = rootVisual.Compositor;
// Composition Generator
_generator = CompositionGeneratorFactory.GetCompositionGenerator(_compositor);
// Final Value Expressions
var vector3Expr = _compositor.CreateFinalValueExpression<Vector3>();
var scalarExpr = _compositor.CreateFinalValueExpression<float>();
// Opacity Animation
var opacityAnimation = _compositor.CreateKeyFrameAnimation<float>()
.HavingDuration(DefaultOpacityAnimationDuration)
.ForTarget(() => rootVisual.Opacity);
opacityAnimation.InsertExpressionKeyFrame(1f, scalarExpr);
// Scale Animation
var scaleAnimation = _compositor.CreateKeyFrameAnimation<Vector3>()
.HavingDuration(DefaultScaleAnimationDuration)
.ForTarget(() => rootVisual.Scale);
scaleAnimation.InsertExpressionKeyFrame(1f, vector3Expr);
// ImplicitAnimation
_implicitAnimationCollection = _compositor.CreateImplicitAnimationCollection();
_implicitAnimationCollection["Opacity"] = opacityAnimation.Animation;
_implicitAnimationCollection["Scale"] = scaleAnimation.Animation;
// Expand Animations
_expandLeftInset = _compositor.CreateKeyFrameAnimation<float>()
.HavingDuration(InsetAnimationDuration)
.DelayBy(InsetAnimationDelayDuration);
_expandLeftInset.InsertKeyFrame(1f, 0);
_expandRightInset = _compositor.CreateKeyFrameAnimation<float>()
.HavingDuration(InsetAnimationDuration)
.DelayBy(InsetAnimationDelayDuration);
_expandInsetClip = _compositor.CreateKeyFrameAnimation<float>()
.HavingDuration(InsetClipAnimationDuration);
_expandInsetClip.InsertKeyFrame(1f, 0);
// Collapse Animations
_collapseLeftInset = _compositor.CreateKeyFrameAnimation<float>()
.HavingDuration(InsetAnimationDuration);
_collapseRightInset = _compositor.CreateKeyFrameAnimation<float>()
.HavingDuration(InsetAnimationDuration);
_collapseInsetClip = _compositor.CreateKeyFrameAnimation<float>()
.HavingDuration(InsetClipAnimationDuration);
// Root Container
_rootContainer = _compositor.CreateContainerVisual();
// Background Layer
_bgLayer = _compositor.CreateLayerVisual();
_bgLayer.Size = _rootContainer.Size;
_bgLayer.CenterPoint = new Vector3(_bgLayer.Size * 0.5f, 0);
// Top Layer
_topLayer = _compositor.CreateLayerVisual();
_topLayer.Size = _rootContainer.Size;
_rootContainer.Children.InsertAtBottom(_bgLayer);
_rootContainer.Children.InsertAtTop(_topLayer);
// Add the rootContainer to the visual tree
ElementCompositionPreview.SetElementChildVisual(this, _rootContainer);
}
示例2: InitializeComposition
/// <summary>
/// Initialize all Composition related stuff here (Compositor, Animations etc)
/// </summary>
private void InitializeComposition()
{
var rootVisual = ElementCompositionPreview.GetElementVisual(this);
// Compositor
_compositor = rootVisual.Compositor;
// Final Value Expressions
var vector3Expr = _compositor.CreateFinalValueExpression<Vector3>();
var scalarExpr = _compositor.CreateFinalValueExpression<float>();
// Offset Animation
var offsetAnimation = _compositor.CreateKeyFrameAnimation<Vector3>()
.HavingDuration(DefaultFluidAnimationDuration)
.ForTarget(() => rootVisual.Offset);
offsetAnimation.InsertExpressionKeyFrame(1f, vector3Expr);
// Opacity Animation
var opacityAnimation = _compositor.CreateKeyFrameAnimation<float>()
.HavingDuration(DefaultOpacityAnimationDuration)
.ForTarget(() => rootVisual.Opacity);
opacityAnimation.InsertExpressionKeyFrame(1f, scalarExpr);
// Scale Animation
var scaleAnimation = _compositor.CreateKeyFrameAnimation<Vector3>()
.HavingDuration(DefaultFluidAnimationDuration)
.ForTarget(() => rootVisual.Scale);
scaleAnimation.InsertExpressionKeyFrame(1f, vector3Expr);
// ImplicitAnimation
_implicitAnimationCollection = _compositor.CreateImplicitAnimationCollection();
_implicitAnimationCollection["Offset"] = offsetAnimation.Animation;
_implicitAnimationCollection["Opacity"] = opacityAnimation.Animation;
_implicitAnimationCollection["Scale"] = scaleAnimation.Animation;
// ImplicitDragAnimation
_implicitDragAnimationCollection = _compositor.CreateImplicitAnimationCollection();
_implicitDragAnimationCollection["Opacity"] = opacityAnimation.Animation;
_implicitDragAnimationCollection["Scale"] = scaleAnimation.Animation;
}