Skip to content

Commit

Permalink
Improved the Dispose method for attached effects
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio0694 committed Jun 25, 2017
1 parent 68de0ad commit 8c4707b
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Windows.UI.Composition;
using Windows.UI.Xaml;
Expand All @@ -25,11 +27,13 @@ internal AttachedAnimatableCompositionEffect(
Parameters = parameters;
}

/// <summary>
/// Executes the animation to the desired destination status and returns a task that completes when the animation ends
/// </summary>
/// <param name="animationType">The target animation status</param>
/// <param name="duration">The animation duration</param>
/// <inheritdoc />
protected override IEnumerable<String> GetAnimatedProperties()
{
return base.GetAnimatedProperties().Concat(new[] { Parameters.Property });
}

/// <inheritdoc />
public override Task AnimateAsync(FixedAnimationType animationType, TimeSpan duration)
{
return EffectBrush.StartAnimationAsync(Parameters.Property,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ internal AttachedCompositeAnimatableCompositionEffect(
PropertiesAnimationValues = propertyValues;
}

/// <summary>
/// Executes the animation to the desired destination status and returns a task that completes when the animation ends
/// </summary>
/// <param name="animationType">The target animation status</param>
/// <param name="duration">The animation duration</param>
/// <inheritdoc />
protected override IEnumerable<String> GetAnimatedProperties()
{
return base.GetAnimatedProperties().Concat(PropertiesAnimationValues.Keys);
}

/// <inheritdoc />
public override Task AnimateAsync(FixedAnimationType animationType, TimeSpan duration)
{
// Apply all the animations in parallel and wait for their completion
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using Windows.UI.Composition;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Hosting;
Expand Down Expand Up @@ -39,6 +40,11 @@ internal AttachedStaticCompositionEffect([NotNull] T element, [NotNull] SpriteVi
if (disposeOnUnload) element.Unloaded += (s, e) => Dispose();
}

/// <summary>
/// Gets a sequence of all the animated properties for the current instance
/// </summary>
protected virtual IEnumerable<String> GetAnimatedProperties() => new[] { "Size" };

// Indicates whether or not the wrapped effect has already been disposed
private bool _Disposed;

Expand All @@ -51,7 +57,7 @@ public void Dispose()
_Disposed = true;
try
{
Sprite.StopAnimation("Size");
foreach (String property in GetAnimatedProperties()) Sprite.StopAnimation(property);
ElementCompositionPreview.SetElementChildVisual(Element, null);
EffectBrush.Dispose();
Sprite.Dispose();
Expand Down
2 changes: 1 addition & 1 deletion UICompositionAnimations/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.5.2.0")]
[assembly: AssemblyVersion("2.5.3.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: ComVisible(false)]
4 changes: 2 additions & 2 deletions UICompositionAnimations/UICompositionAnimations.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
<package >
<metadata>
<id>Sergio0694.UWP.UICompositionAnimations</id>
<version>2.5.2.0</version>
<version>2.5.3.0</version>
<title>UICompositionAnimations</title>
<description>A wrapper UWP PCL to work with Windows.UI.Composition and XAML animations, and Win2D effects</description>
<authors>Sergio Pedri</authors>
<owners>Sergio Pedri</owners>
<projectUrl>https://github.com/Sergio0694/UICompositionAnimations</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<releaseNotes>Minor bug fixes</releaseNotes>
<releaseNotes>Minor improvements</releaseNotes>
<copyright>Copyright 2017</copyright>
<tags>uwp composition animations xaml csharp windows winrt universal app ui win2d graphics</tags>
</metadata>
Expand Down

0 comments on commit 8c4707b

Please sign in to comment.