From ad02b06f0e3ad5a08e4f6fc6f861d25851039aa7 Mon Sep 17 00:00:00 2001 From: ChrisBlackman Date: Wed, 12 Jul 2017 21:54:29 -0400 Subject: [PATCH 1/3] Made CompositionManager public --- .../Composition/CompositionManager.cs | 2 +- .../UICompositionAnimations.nuget.props | 4 +- UICompositionAnimations/project.lock.json | 118 ++---------------- 3 files changed, 16 insertions(+), 108 deletions(-) diff --git a/UICompositionAnimations/Composition/CompositionManager.cs b/UICompositionAnimations/Composition/CompositionManager.cs index c42b01d..96168b1 100644 --- a/UICompositionAnimations/Composition/CompositionManager.cs +++ b/UICompositionAnimations/Composition/CompositionManager.cs @@ -8,7 +8,7 @@ namespace UICompositionAnimations.Composition /// /// Create composition animations using this class /// - internal static class CompositionManager + public static class CompositionManager { // UIElement scalar animation public static void BeginScalarAnimation(UIElement element, String propertyPath, float to, float? from, TimeSpan duration, TimeSpan? delay, CompositionEasingFunction ease) diff --git a/UICompositionAnimations/UICompositionAnimations.nuget.props b/UICompositionAnimations/UICompositionAnimations.nuget.props index f8463e5..4892c1c 100644 --- a/UICompositionAnimations/UICompositionAnimations.nuget.props +++ b/UICompositionAnimations/UICompositionAnimations.nuget.props @@ -3,9 +3,9 @@ True NuGet - C:\Users\Sergi\Documents\GitHub\UICompositionAnimations\UICompositionAnimations\project.lock.json + C:\Users\Chris\Documents\GitHub\UICompositionAnimations\UICompositionAnimations\project.lock.json $(UserProfile)\.nuget\packages\ - C:\Users\Sergi\.nuget\packages\ + C:\Users\Chris\.nuget\packages\ ProjectJson 4.2.0 diff --git a/UICompositionAnimations/project.lock.json b/UICompositionAnimations/project.lock.json index a17611f..46f34e7 100644 --- a/UICompositionAnimations/project.lock.json +++ b/UICompositionAnimations/project.lock.json @@ -2111,15 +2111,6 @@ "lib/win81/_._": {} } }, - "System.ValueTuple/4.3.1": { - "type": "package", - "compile": { - "lib/netstandard1.0/System.ValueTuple.dll": {} - }, - "runtime": { - "lib/netstandard1.0/System.ValueTuple.dll": {} - } - }, "System.Xml.ReaderWriter/4.0.11": { "type": "package", "dependencies": { @@ -2224,7 +2215,7 @@ } } }, - "Win2D.uwp/1.20.0": { + "Win2D.uwp/1.21.0": { "type": "package", "compile": { "lib/uap10.0/Microsoft.Graphics.Canvas.winmd": {} @@ -4447,15 +4438,6 @@ "lib/win81/_._": {} } }, - "System.ValueTuple/4.3.1": { - "type": "package", - "compile": { - "lib/netstandard1.0/System.ValueTuple.dll": {} - }, - "runtime": { - "lib/netstandard1.0/System.ValueTuple.dll": {} - } - }, "System.Xml.ReaderWriter/4.0.11": { "type": "package", "dependencies": { @@ -4554,7 +4536,7 @@ "lib/netcore50/System.Xml.XmlSerializer.dll": {} } }, - "Win2D.uwp/1.20.0": { + "Win2D.uwp/1.21.0": { "type": "package", "compile": { "lib/uap10.0/Microsoft.Graphics.Canvas.winmd": {} @@ -6805,15 +6787,6 @@ "lib/win81/_._": {} } }, - "System.ValueTuple/4.3.1": { - "type": "package", - "compile": { - "lib/netstandard1.0/System.ValueTuple.dll": {} - }, - "runtime": { - "lib/netstandard1.0/System.ValueTuple.dll": {} - } - }, "System.Xml.ReaderWriter/4.0.11": { "type": "package", "dependencies": { @@ -6912,7 +6885,7 @@ "runtimes/aot/lib/netcore50/System.Xml.XmlSerializer.dll": {} } }, - "Win2D.uwp/1.20.0": { + "Win2D.uwp/1.21.0": { "type": "package", "compile": { "lib/uap10.0/Microsoft.Graphics.Canvas.winmd": {} @@ -9133,15 +9106,6 @@ "lib/win81/_._": {} } }, - "System.ValueTuple/4.3.1": { - "type": "package", - "compile": { - "lib/netstandard1.0/System.ValueTuple.dll": {} - }, - "runtime": { - "lib/netstandard1.0/System.ValueTuple.dll": {} - } - }, "System.Xml.ReaderWriter/4.0.11": { "type": "package", "dependencies": { @@ -9240,7 +9204,7 @@ "lib/netcore50/System.Xml.XmlSerializer.dll": {} } }, - "Win2D.uwp/1.20.0": { + "Win2D.uwp/1.21.0": { "type": "package", "compile": { "lib/uap10.0/Microsoft.Graphics.Canvas.winmd": {} @@ -11500,15 +11464,6 @@ "lib/win81/_._": {} } }, - "System.ValueTuple/4.3.1": { - "type": "package", - "compile": { - "lib/netstandard1.0/System.ValueTuple.dll": {} - }, - "runtime": { - "lib/netstandard1.0/System.ValueTuple.dll": {} - } - }, "System.Xml.ReaderWriter/4.0.11": { "type": "package", "dependencies": { @@ -11607,7 +11562,7 @@ "runtimes/aot/lib/netcore50/System.Xml.XmlSerializer.dll": {} } }, - "Win2D.uwp/1.20.0": { + "Win2D.uwp/1.21.0": { "type": "package", "compile": { "lib/uap10.0/Microsoft.Graphics.Canvas.winmd": {} @@ -13828,15 +13783,6 @@ "lib/win81/_._": {} } }, - "System.ValueTuple/4.3.1": { - "type": "package", - "compile": { - "lib/netstandard1.0/System.ValueTuple.dll": {} - }, - "runtime": { - "lib/netstandard1.0/System.ValueTuple.dll": {} - } - }, "System.Xml.ReaderWriter/4.0.11": { "type": "package", "dependencies": { @@ -13935,7 +13881,7 @@ "lib/netcore50/System.Xml.XmlSerializer.dll": {} } }, - "Win2D.uwp/1.20.0": { + "Win2D.uwp/1.21.0": { "type": "package", "compile": { "lib/uap10.0/Microsoft.Graphics.Canvas.winmd": {} @@ -16195,15 +16141,6 @@ "lib/win81/_._": {} } }, - "System.ValueTuple/4.3.1": { - "type": "package", - "compile": { - "lib/netstandard1.0/System.ValueTuple.dll": {} - }, - "runtime": { - "lib/netstandard1.0/System.ValueTuple.dll": {} - } - }, "System.Xml.ReaderWriter/4.0.11": { "type": "package", "dependencies": { @@ -16302,7 +16239,7 @@ "runtimes/aot/lib/netcore50/System.Xml.XmlSerializer.dll": {} } }, - "Win2D.uwp/1.20.0": { + "Win2D.uwp/1.21.0": { "type": "package", "compile": { "lib/uap10.0/Microsoft.Graphics.Canvas.winmd": {} @@ -24352,33 +24289,6 @@ "ref/xamarinwatchos10/_._" ] }, - "System.ValueTuple/4.3.1": { - "sha512": "xzDmg26Wb2x2rFDjwziaMYQJqxhrK+b4OUC008o7CnZhUMb2p5XfwgOgAQ/WlKhqxMUSDWRUm5/lNTKdh27pJA==", - "type": "package", - "path": "system.valuetuple/4.3.1", - "files": [ - "ThirdPartyNotices.txt", - "dotnet_library_license.txt", - "lib/MonoAndroid10/_._", - "lib/MonoTouch10/_._", - "lib/netstandard1.0/.xml", - "lib/netstandard1.0/System.ValueTuple.dll", - "lib/portable-net40+sl4+win8+wp8/.xml", - "lib/portable-net40+sl4+win8+wp8/System.ValueTuple.dll", - "lib/xamarinios10/_._", - "lib/xamarinmac20/_._", - "lib/xamarintvos10/_._", - "lib/xamarinwatchos10/_._", - "ref/MonoAndroid10/_._", - "ref/MonoTouch10/_._", - "ref/xamarinios10/_._", - "ref/xamarinmac20/_._", - "ref/xamarintvos10/_._", - "ref/xamarinwatchos10/_._", - "system.valuetuple.4.3.1.nupkg.sha512", - "system.valuetuple.nuspec" - ] - }, "System.Xml.ReaderWriter/4.0.11": { "sha512": "ZIiLPsf67YZ9zgr31vzrFaYQqxRPX9cVHjtPSnmx4eN6lbS/yEyYNr2vs1doGDEscF0tjCZFsk9yUg1sC9e8tg==", "type": "package", @@ -24621,10 +24531,10 @@ "runtimes/aot/lib/netcore50/System.Xml.XmlSerializer.dll" ] }, - "Win2D.uwp/1.20.0": { - "sha512": "sFyNT2EiV6vmEFMrkiJdSolaKNyOyk+kfjgvXN8XqUhdEPqBd2zPrFdl7SojNHQGm2Br6JLIBOdrj9fB1Qy4GA==", + "Win2D.uwp/1.21.0": { + "sha512": "4Ds/p7HgysgV67pBo/+w7Lidj08Hfa4GD9Zg9HdN3/zLfzRPttHrIn2TUiOUZCgH4eLVJwzOk114ntv4bveS1Q==", "type": "package", - "path": "win2d.uwp/1.20.0", + "path": "win2d.uwp/1.21.0", "files": [ "Win2d.githash.txt", "build/native/Win2D.uwp.targets", @@ -24635,7 +24545,7 @@ "runtimes/win10-arm/native/Microsoft.Graphics.Canvas.dll", "runtimes/win10-x64/native/Microsoft.Graphics.Canvas.dll", "runtimes/win10-x86/native/Microsoft.Graphics.Canvas.dll", - "win2d.uwp.1.20.0.nupkg.sha512", + "win2d.uwp.1.21.0.nupkg.sha512", "win2d.uwp.nuspec" ] } @@ -24645,8 +24555,7 @@ "JetBrains.Annotations >= 10.4.0", "Microsoft.NETCore.UniversalWindowsPlatform >= 5.3.3", "System.Threading.Tasks.Extensions >= 4.3.0", - "System.ValueTuple >= 4.3.1", - "Win2D.uwp >= 1.20.0" + "Win2D.uwp >= 1.21.0" ], "UAP,Version=v10.0": [] }, @@ -24665,8 +24574,7 @@ "JetBrains.Annotations": "10.4.0", "Microsoft.NETCore.UniversalWindowsPlatform": "5.3.3", "System.Threading.Tasks.Extensions": "4.3.0", - "System.ValueTuple": "4.3.1", - "Win2D.uwp": "1.20.0" + "Win2D.uwp": "1.21.0" }, "frameworks": { "uap10.0": {} From d2ab01d35a240f2add549650da1eb5557d59fa30 Mon Sep 17 00:00:00 2001 From: ChrisBlackman Date: Thu, 13 Jul 2017 01:25:01 -0400 Subject: [PATCH 2/3] Made TintMix and BlurAmount default values into doubles --- UICompositionAnimations/Brushes/CustomAcrylicBrush.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/UICompositionAnimations/Brushes/CustomAcrylicBrush.cs b/UICompositionAnimations/Brushes/CustomAcrylicBrush.cs index 3ad4c89..a3ed4ed 100644 --- a/UICompositionAnimations/Brushes/CustomAcrylicBrush.cs +++ b/UICompositionAnimations/Brushes/CustomAcrylicBrush.cs @@ -80,7 +80,7 @@ public double BlurAmount /// Gets the for the property /// public static readonly DependencyProperty BlurAmountProperty = - DependencyProperty.Register(nameof(BlurAmount), typeof(double), typeof(LightingBrush), new PropertyMetadata(8, OnBlurAmountPropertyChanged)); + DependencyProperty.Register(nameof(BlurAmount), typeof(double), typeof(LightingBrush), new PropertyMetadata(8d, OnBlurAmountPropertyChanged)); private static async void OnBlurAmountPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { @@ -131,7 +131,7 @@ public double TintMix /// Gets the for the property /// public static readonly DependencyProperty TintMixProperty = - DependencyProperty.Register(nameof(Tint), typeof(double), typeof(LightingBrush), new PropertyMetadata(0, OnTintMixPropertyChanged)); + DependencyProperty.Register(nameof(Tint), typeof(double), typeof(LightingBrush), new PropertyMetadata(0d, OnTintMixPropertyChanged)); private static async void OnTintMixPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { From 29e21e9e932b5caca03d3eda24794fb944343238 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Fri, 14 Jul 2017 01:05:11 +0200 Subject: [PATCH 3/3] Added XML comments to the CompositionManager class, minor refactoring --- .../AttachedCompositionEffectFactory.cs | 4 +- .../Composition/CompositionManager.cs | 200 +++++++++++++++--- .../CompositionExtensions.cs | 34 +-- 3 files changed, 189 insertions(+), 49 deletions(-) diff --git a/UICompositionAnimations/Behaviours/AttachedCompositionEffectFactory.cs b/UICompositionAnimations/Behaviours/AttachedCompositionEffectFactory.cs index a1b0e89..e2872d3 100644 --- a/UICompositionAnimations/Behaviours/AttachedCompositionEffectFactory.cs +++ b/UICompositionAnimations/Behaviours/AttachedCompositionEffectFactory.cs @@ -166,8 +166,8 @@ const String if (fadeIn) { // Fade the effect in - ScalarKeyFrameAnimation opacityAnimation = sprite.Compositor.CreateScalarKeyFrameAnimation(1, 0, - TimeSpan.FromMilliseconds(ms), null, sprite.GetEasingFunction(EasingFunctionNames.Linear)); + ScalarKeyFrameAnimation opacityAnimation = sprite.Compositor.CreateScalarKeyFrameAnimation(0, + 1, TimeSpan.FromMilliseconds(ms), null, sprite.GetEasingFunction(EasingFunctionNames.Linear)); sprite.StartAnimation("Opacity", opacityAnimation); } diff --git a/UICompositionAnimations/Composition/CompositionManager.cs b/UICompositionAnimations/Composition/CompositionManager.cs index 96168b1..6317dde 100644 --- a/UICompositionAnimations/Composition/CompositionManager.cs +++ b/UICompositionAnimations/Composition/CompositionManager.cs @@ -2,6 +2,7 @@ using System.Numerics; using Windows.UI.Composition; using Windows.UI.Xaml; +using JetBrains.Annotations; namespace UICompositionAnimations.Composition { @@ -10,44 +11,126 @@ namespace UICompositionAnimations.Composition /// public static class CompositionManager { - // UIElement scalar animation - public static void BeginScalarAnimation(UIElement element, String propertyPath, float to, float? from, TimeSpan duration, TimeSpan? delay, CompositionEasingFunction ease) + #region Animations initialization + + /// + /// Creates and starts a scalar animation on the target element + /// + /// The element to animate + /// The path that identifies the property to animate + /// The optional starting value for the animation + /// The final value for the animation + /// The animation duration + /// The optional initial delay for the animation + /// The optional easing function for the animation + [PublicAPI] + public static void BeginScalarAnimation([NotNull] UIElement element, [NotNull] String propertyPath, + float? from, float to, TimeSpan duration, TimeSpan? delay, [CanBeNull] CompositionEasingFunction ease = null) { - element.GetVisual().BeginScalarAnimation(propertyPath, to, from, duration, delay, ease); + element.GetVisual().BeginScalarAnimation(propertyPath, from, to, duration, delay, ease); } - // UIElement Vector2 animation - public static void BeginVector2Animation(UIElement element, String propertyPath, Vector2 to, Vector2? from, TimeSpan duration, TimeSpan? delay, CompositionEasingFunction ease) + /// + /// Creates and starts a animation on the target element + /// + /// The element to animate + /// The path that identifies the property to animate + /// The optional starting value for the animation + /// The final value for the animation + /// The animation duration + /// The optional initial delay for the animation + /// The optional easing function for the animation + [PublicAPI] + public static void BeginVector2Animation([NotNull] UIElement element, [NotNull] String propertyPath, + Vector2? from, Vector2 to, TimeSpan duration, TimeSpan? delay, [CanBeNull] CompositionEasingFunction ease = null) { - element.GetVisual().BeginVector2Animation(propertyPath, to, from, duration, delay, ease); + element.GetVisual().BeginVector2Animation(propertyPath, from, to, duration, delay, ease); } - // UIElement Vector3 animation - public static void BeginVector3Animation(UIElement element, String propertyPath, Vector3 to, Vector3? from, TimeSpan duration, TimeSpan? delay, CompositionEasingFunction ease) + /// + /// Creates and starts a animation on the target element + /// + /// The element to animate + /// The path that identifies the property to animate + /// The optional starting value for the animation + /// The final value for the animation + /// The animation duration + /// The optional initial delay for the animation + /// The optional easing function for the animation + public static void BeginVector3Animation([NotNull] UIElement element, [NotNull] String propertyPath, + Vector3? from, Vector3 to, TimeSpan duration, TimeSpan? delay, [CanBeNull] CompositionEasingFunction ease = null) { - element.GetVisual().BeginVector3Animation(propertyPath, to, from, duration, delay, ease); + element.GetVisual().BeginVector3Animation(propertyPath, from, to, duration, delay, ease); } - // CompositionObject scalar animation - public static void BeginScalarAnimation(this CompositionObject compObj, String propertyPath, float to, float? from, TimeSpan duration, TimeSpan? delay, CompositionEasingFunction ease) + /// + /// Creates and starts a scalar animation on the current + /// + /// The target to animate + /// The path that identifies the property to animate + /// The optional starting value for the animation + /// The final value for the animation + /// The animation duration + /// The optional initial delay for the animation + /// The optional easing function for the animation + [PublicAPI] + public static void BeginScalarAnimation([NotNull] this CompositionObject compObj, [NotNull] String propertyPath, + float? from, float to, TimeSpan duration, TimeSpan? delay, [CanBeNull] CompositionEasingFunction ease = null) { - compObj.StartAnimation(propertyPath, compObj.Compositor.CreateScalarKeyFrameAnimation(to, from, duration, delay, ease)); + compObj.StartAnimation(propertyPath, compObj.Compositor.CreateScalarKeyFrameAnimation(from, to, duration, delay, ease)); } - // CompositionObject Vector2 animation - public static void BeginVector2Animation(this CompositionObject compObj, String propertyPath, Vector2 to, Vector2? from, TimeSpan duration, TimeSpan? delay, CompositionEasingFunction ease) + /// + /// Creates and starts a animation on the current + /// + /// The target to animate + /// The path that identifies the property to animate + /// The optional starting value for the animation + /// The final value for the animation + /// The animation duration + /// The optional initial delay for the animation + /// The optional easing function for the animation + [PublicAPI] + public static void BeginVector2Animation([NotNull]this CompositionObject compObj, [NotNull] String propertyPath, + Vector2? from, Vector2 to, TimeSpan duration, TimeSpan? delay, [CanBeNull] CompositionEasingFunction ease = null) { - compObj.StartAnimation(propertyPath, compObj.Compositor.CreateVector2KeyFrameAnimation(to, from, duration, delay, ease)); + compObj.StartAnimation(propertyPath, compObj.Compositor.CreateVector2KeyFrameAnimation(from, to, duration, delay, ease)); } - // CompositionObject Vector3 animation - public static void BeginVector3Animation(this CompositionObject compObj, String propertyPath, Vector3 to, Vector3? from, TimeSpan duration, TimeSpan? delay, CompositionEasingFunction ease) + /// + /// Creates and starts a animation on the current + /// + /// The target to animate + /// The path that identifies the property to animate + /// The optional starting value for the animation + /// The final value for the animation + /// The animation duration + /// The optional initial delay for the animation + /// The optional easing function for the animation + [PublicAPI] + public static void BeginVector3Animation([NotNull] this CompositionObject compObj, [NotNull] String propertyPath, + Vector3? from, Vector3 to, TimeSpan duration, TimeSpan? delay, [CanBeNull] CompositionEasingFunction ease = null) { - compObj.StartAnimation(propertyPath, compObj.Compositor.CreateVector3KeyFrameAnimation(to, from, duration, delay, ease)); + compObj.StartAnimation(propertyPath, compObj.Compositor.CreateVector3KeyFrameAnimation(from, to, duration, delay, ease)); } - // Create scalar animation from compositor - public static ScalarKeyFrameAnimation CreateScalarKeyFrameAnimation(this Compositor compositor, float to, float? from, TimeSpan duration, TimeSpan? delay, CompositionEasingFunction ease) + #endregion + + #region KeyFrame animations + + /// + /// Creates a instance with the given parameters to on a target element + /// + /// The current instance used to create the animation + /// The optional starting value for the animation + /// The final value for the animation + /// The animation duration + /// The optional initial delay for the animation + /// The optional easing function for the animation + [PublicAPI] + [Pure, NotNull] + public static ScalarKeyFrameAnimation CreateScalarKeyFrameAnimation([NotNull] this Compositor compositor, + float? from, float to, TimeSpan duration, TimeSpan? delay, [CanBeNull] CompositionEasingFunction ease = null) { // Set duration and delay time ScalarKeyFrameAnimation ani = compositor.CreateScalarKeyFrameAnimation(); @@ -60,8 +143,19 @@ public static ScalarKeyFrameAnimation CreateScalarKeyFrameAnimation(this Composi return ani; } - // Create expression scalar animation from compositor - public static ScalarKeyFrameAnimation CreateScalarKeyFrameAnimation(this Compositor compositor, String to, float? from, TimeSpan duration, TimeSpan? delay, CompositionEasingFunction ease) + /// + /// Creates a instance with the given parameters to on a target element, using an expression animation + /// + /// The current instance used to create the animation + /// The optional starting value for the animation + /// A string that indicates the final value for the animation + /// The animation duration + /// The optional initial delay for the animation + /// The optional easing function for the animation + [PublicAPI] + [Pure, NotNull] + public static ScalarKeyFrameAnimation CreateScalarKeyFrameAnimation([NotNull] this Compositor compositor, + float? from, [NotNull] String to, TimeSpan duration, TimeSpan? delay, [CanBeNull] CompositionEasingFunction ease = null) { // Set duration and delay time ScalarKeyFrameAnimation ani = compositor.CreateScalarKeyFrameAnimation(); @@ -74,8 +168,19 @@ public static ScalarKeyFrameAnimation CreateScalarKeyFrameAnimation(this Composi return ani; } - // Create Vector2 animation from compositor - public static Vector2KeyFrameAnimation CreateVector2KeyFrameAnimation(this Compositor compositor, Vector2 to, Vector2? from, TimeSpan duration, TimeSpan? delay, CompositionEasingFunction ease) + /// + /// Creates a instance with the given parameters to on a target element + /// + /// The current instance used to create the animation + /// The optional starting value for the animation + /// The final value for the animation + /// The animation duration + /// The optional initial delay for the animation + /// The optional easing function for the animation + [PublicAPI] + [Pure, NotNull] + public static Vector2KeyFrameAnimation CreateVector2KeyFrameAnimation([NotNull] this Compositor compositor, + Vector2? from, Vector2 to, TimeSpan duration, TimeSpan? delay, [CanBeNull] CompositionEasingFunction ease = null) { // Set duration and delay time Vector2KeyFrameAnimation ani = compositor.CreateVector2KeyFrameAnimation(); @@ -88,8 +193,19 @@ public static Vector2KeyFrameAnimation CreateVector2KeyFrameAnimation(this Compo return ani; } - // Create Vector2 expression animation from compositor - public static Vector2KeyFrameAnimation CreateVector2KeyFrameAnimation(this Compositor compositor, String to, Vector2? from, TimeSpan duration, TimeSpan? delay, CompositionEasingFunction ease) + /// + /// Creates a instance with the given parameters to on a target element, using an expression animation + /// + /// The current instance used to create the animation + /// The optional starting value for the animation + /// A string that indicates the final value for the animation + /// The animation duration + /// The optional initial delay for the animation + /// The optional easing function for the animation + [PublicAPI] + [Pure, NotNull] + public static Vector2KeyFrameAnimation CreateVector2KeyFrameAnimation([NotNull] this Compositor compositor, + Vector2? from, [NotNull] String to, TimeSpan duration, TimeSpan? delay, [CanBeNull] CompositionEasingFunction ease = null) { // Set duration and delay time Vector2KeyFrameAnimation ani = compositor.CreateVector2KeyFrameAnimation(); @@ -102,8 +218,19 @@ public static Vector2KeyFrameAnimation CreateVector2KeyFrameAnimation(this Compo return ani; } - // Create Vector3 animation from compositor - public static Vector3KeyFrameAnimation CreateVector3KeyFrameAnimation(this Compositor compositor, Vector3 to, Vector3? from, TimeSpan duration, TimeSpan? delay, CompositionEasingFunction ease) + /// + /// Creates a instance with the given parameters to on a target element + /// + /// The current instance used to create the animation + /// The optional starting value for the animation + /// The final value for the animation + /// The animation duration + /// The optional initial delay for the animation + /// The optional easing function for the animation + [PublicAPI] + [Pure, NotNull] + public static Vector3KeyFrameAnimation CreateVector3KeyFrameAnimation([NotNull] this Compositor compositor, + Vector3? from, Vector3 to, TimeSpan duration, TimeSpan? delay, [CanBeNull] CompositionEasingFunction ease = null) { // Set duration and delay time Vector3KeyFrameAnimation ani = compositor.CreateVector3KeyFrameAnimation(); @@ -116,8 +243,19 @@ public static Vector3KeyFrameAnimation CreateVector3KeyFrameAnimation(this Compo return ani; } - // Create Vector3 expression animation from compositor - public static Vector3KeyFrameAnimation CreateVector3KeyFrameAnimation(this Compositor compositor, String to, Vector3? from, TimeSpan duration, TimeSpan? delay, CompositionEasingFunction ease) + /// + /// Creates a instance with the given parameters to on a target element, using an expression animation + /// + /// The current instance used to create the animation + /// The optional starting value for the animation + /// A string that indicates the final value for the animation + /// The animation duration + /// The optional initial delay for the animation + /// The optional easing function for the animation + [PublicAPI] + [Pure, NotNull] + public static Vector3KeyFrameAnimation CreateVector3KeyFrameAnimation([NotNull] this Compositor compositor, + Vector3? from, [NotNull] String to, TimeSpan duration, TimeSpan? delay, [CanBeNull] CompositionEasingFunction ease = null) { // Set duration and delay time Vector3KeyFrameAnimation ani = compositor.CreateVector3KeyFrameAnimation(); @@ -129,5 +267,7 @@ public static Vector3KeyFrameAnimation CreateVector3KeyFrameAnimation(this Compo if (from.HasValue) ani.InsertKeyFrame(0, from.Value); return ani; } + + #endregion } } diff --git a/UICompositionAnimations/CompositionExtensions.cs b/UICompositionAnimations/CompositionExtensions.cs index 32e9ee6..77f23f9 100644 --- a/UICompositionAnimations/CompositionExtensions.cs +++ b/UICompositionAnimations/CompositionExtensions.cs @@ -73,7 +73,7 @@ private static Task ManageCompositionFadeAnimationAsync(this UIElement element, else delay = null; // Get the opacity animation - ScalarKeyFrameAnimation opacityAnimation = visual.Compositor.CreateScalarKeyFrameAnimation(endOp, startOp, duration, delay, ease); + ScalarKeyFrameAnimation opacityAnimation = visual.Compositor.CreateScalarKeyFrameAnimation(startOp, endOp, duration, delay, ease); // Close the batch and manage its event CompositionScopedBatch batch = visual.Compositor.CreateScopedBatch(CompositionBatchTypes.Animation); @@ -144,7 +144,7 @@ public static void SetCompositionFadeImplicitAnimation(this FrameworkElement ele // Get the opacity animation CompositionAnimationGroup group = visual.Compositor.CreateAnimationGroup(); - ScalarKeyFrameAnimation opacityAnimation = visual.Compositor.CreateScalarKeyFrameAnimation(end, start, duration, delay, ease); + ScalarKeyFrameAnimation opacityAnimation = visual.Compositor.CreateScalarKeyFrameAnimation(start, end, duration, delay, ease); opacityAnimation.Target = "Opacity"; group.Add(opacityAnimation); @@ -195,10 +195,10 @@ private static Task ManageCompositionFadeSlideAnimationAsync(this UIElement elem CompositionScopedBatch batch = visual.Compositor.CreateScopedBatch(CompositionBatchTypes.Animation); // Get the opacity the animation - ScalarKeyFrameAnimation opacityAnimation = visual.Compositor.CreateScalarKeyFrameAnimation(endOp, startOp, durationOp, delay, ease); + ScalarKeyFrameAnimation opacityAnimation = visual.Compositor.CreateScalarKeyFrameAnimation(startOp, endOp, durationOp, delay, ease); // Offset animation - Vector3KeyFrameAnimation offsetAnimation = visual.Compositor.CreateVector3KeyFrameAnimation(endOffset, initialOffset, durationSlide, delay, ease); + Vector3KeyFrameAnimation offsetAnimation = visual.Compositor.CreateVector3KeyFrameAnimation(initialOffset, endOffset, durationSlide, delay, ease); // Close the batch and manage its event TaskCompletionSource tcs = new TaskCompletionSource(); @@ -299,10 +299,10 @@ public static void SetCompositionFadeSlideImplicitAnimation(this FrameworkElemen // Create and return the animations CompositionAnimationGroup group = visual.Compositor.CreateAnimationGroup(); - ScalarKeyFrameAnimation fade = visual.Compositor.CreateScalarKeyFrameAnimation(endOp, startOp, durationOp, delay, ease); + ScalarKeyFrameAnimation fade = visual.Compositor.CreateScalarKeyFrameAnimation(startOp, endOp, durationOp, delay, ease); fade.Target = "Opacity"; group.Add(fade); - Vector3KeyFrameAnimation slide = visual.Compositor.CreateVector3KeyFrameAnimation(endOffset, initialOffset, durationSlide, delay, ease); + Vector3KeyFrameAnimation slide = visual.Compositor.CreateVector3KeyFrameAnimation(initialOffset, endOffset, durationSlide, delay, ease); slide.Target = "Offset"; group.Add(slide); @@ -351,10 +351,10 @@ private static async Task ManageCompositionFadeScaleAnimationAsync(this Framewor }; // Get the opacity the animation - ScalarKeyFrameAnimation opacityAnimation = visual.Compositor.CreateScalarKeyFrameAnimation(endOp, startOp, durationOp, delay, ease); + ScalarKeyFrameAnimation opacityAnimation = visual.Compositor.CreateScalarKeyFrameAnimation(startOp, endOp, durationOp, delay, ease); // Scale animation - Vector3KeyFrameAnimation scaleAnimation = visual.Compositor.CreateVector3KeyFrameAnimation(endScale, initialScale, durationScale, delay, ease); + Vector3KeyFrameAnimation scaleAnimation = visual.Compositor.CreateVector3KeyFrameAnimation(initialScale, endScale, durationScale, delay, ease); // Get the batch and start the animations CompositionScopedBatch batch = visual.Compositor.CreateScopedBatch(CompositionBatchTypes.Animation); @@ -444,10 +444,10 @@ public static async Task SetCompositionFadeScaleImplicitAnimationAsync(this Fram // Get the animations CompositionAnimationGroup group = visual.Compositor.CreateAnimationGroup(); - ScalarKeyFrameAnimation opacityAnimation = visual.Compositor.CreateScalarKeyFrameAnimation(endOp, startOp, durationOp, delay, ease); + ScalarKeyFrameAnimation opacityAnimation = visual.Compositor.CreateScalarKeyFrameAnimation(startOp, endOp, durationOp, delay, ease); opacityAnimation.Target = "Opacity"; group.Add(opacityAnimation); - Vector3KeyFrameAnimation scaleAnimation = visual.Compositor.CreateVector3KeyFrameAnimation(endScale3, initialScale, durationScale, delay, ease); + Vector3KeyFrameAnimation scaleAnimation = visual.Compositor.CreateVector3KeyFrameAnimation(initialScale, endScale3, durationScale, delay, ease); scaleAnimation.Target = "Scale"; group.Add(scaleAnimation); @@ -492,7 +492,7 @@ private static async Task ManageCompositionScaleAnimationAsync(this Frame }; // Scale animation - Vector3KeyFrameAnimation scaleAnimation = visual.Compositor.CreateVector3KeyFrameAnimation(endScale, initialScale, duration, delay, ease); + Vector3KeyFrameAnimation scaleAnimation = visual.Compositor.CreateVector3KeyFrameAnimation(initialScale, endScale, duration, delay, ease); // Get the batch and start the animations CompositionScopedBatch batch = visual.Compositor.CreateScopedBatch(CompositionBatchTypes.Animation); @@ -572,7 +572,7 @@ public static async Task SetCompositionScaleImplicitAnimationAsync(this Framewor // Get the animations CompositionAnimationGroup group = visual.Compositor.CreateAnimationGroup(); - Vector3KeyFrameAnimation scaleAnimation = visual.Compositor.CreateVector3KeyFrameAnimation(endScale, initialScale, duration, delay, ease); + Vector3KeyFrameAnimation scaleAnimation = visual.Compositor.CreateVector3KeyFrameAnimation(initialScale, endScale, duration, delay, ease); scaleAnimation.Target = "Scale"; group.Add(scaleAnimation); @@ -616,7 +616,7 @@ private static async Task ManageCompositionSlideAnimationAsync(this Frame } // Scale animation - Vector3KeyFrameAnimation offsetAnimation = visual.Compositor.CreateVector3KeyFrameAnimation(endOffset, initialOffset, duration, delay, ease); + Vector3KeyFrameAnimation offsetAnimation = visual.Compositor.CreateVector3KeyFrameAnimation(initialOffset, endOffset, duration, delay, ease); // Get the batch and start the animations CompositionScopedBatch batch = visual.Compositor.CreateScopedBatch(CompositionBatchTypes.Animation); @@ -708,7 +708,7 @@ public static void SetCompositionSlideImplicitAnimation(this FrameworkElement el // Get the animations CompositionAnimationGroup group = visual.Compositor.CreateAnimationGroup(); - Vector3KeyFrameAnimation offsetAnimation = visual.Compositor.CreateVector3KeyFrameAnimation(endOffset, initialOffset, duration, delay, ease); + Vector3KeyFrameAnimation offsetAnimation = visual.Compositor.CreateVector3KeyFrameAnimation(initialOffset, endOffset, duration, delay, ease); offsetAnimation.Target = "Offset"; group.Add(offsetAnimation); @@ -763,13 +763,13 @@ private static async Task ManageCompositionRollAnimationAsync(this Framew if (startDegrees == null) startDegrees = visual.RotationAngle.ToDegrees(); // Get the opacity the animation - ScalarKeyFrameAnimation opacityAnimation = visual.Compositor.CreateScalarKeyFrameAnimation(endOp, startOp, duration, delay, ease); + ScalarKeyFrameAnimation opacityAnimation = visual.Compositor.CreateScalarKeyFrameAnimation(startOp, endOp, duration, delay, ease); // Scale animation - Vector3KeyFrameAnimation offsetAnimation = visual.Compositor.CreateVector3KeyFrameAnimation(endOffset, initialOffset, duration, delay, ease); + Vector3KeyFrameAnimation offsetAnimation = visual.Compositor.CreateVector3KeyFrameAnimation(initialOffset, endOffset, duration, delay, ease); // Rotate animation - ScalarKeyFrameAnimation rotateAnimation = visual.Compositor.CreateScalarKeyFrameAnimation(endDegrees.ToRadians(), startDegrees.Value.ToRadians(), duration, delay, ease); + ScalarKeyFrameAnimation rotateAnimation = visual.Compositor.CreateScalarKeyFrameAnimation(startDegrees.Value.ToRadians(), endDegrees.ToRadians(), duration, delay, ease); // Get the batch and start the animations CompositionScopedBatch batch = visual.Compositor.CreateScopedBatch(CompositionBatchTypes.Animation);