diff --git a/UICompositionAnimations/Brushes/Base/XamlCompositionEffectBrushBase.cs b/UICompositionAnimations/Brushes/Base/XamlCompositionEffectBrushBase.cs
index a967254..7bc90b1 100644
--- a/UICompositionAnimations/Brushes/Base/XamlCompositionEffectBrushBase.cs
+++ b/UICompositionAnimations/Brushes/Base/XamlCompositionEffectBrushBase.cs
@@ -22,12 +22,28 @@ public abstract class XamlCompositionEffectBrushBase : XamlCompositionBrushBase
[MustUseReturnValue, NotNull]
protected abstract PipelineBuilder OnBrushRequested();
+ private bool _IsEnabled = true;
+
+ ///
+ /// Gest or sets whether or not the current brush is using the provided pipeline, or the fallback color
+ ///
+ public bool IsEnabled
+ {
+ get => _IsEnabled;
+ set => OnEnabledToggled(value);
+ }
+
///
protected override async void OnConnected()
{
using (await ConnectedMutex.LockAsync())
+ {
if (CompositionBrush == null)
- CompositionBrush = await OnBrushRequested().BuildAsync();
+ {
+ if (_IsEnabled) CompositionBrush = await OnBrushRequested().BuildAsync();
+ else CompositionBrush = await PipelineBuilder.FromColor(FallbackColor).BuildAsync();
+ }
+ }
base.OnConnected();
}
@@ -44,5 +60,24 @@ protected override async void OnDisconnected()
}
base.OnDisconnected();
}
+
+ ///
+ /// Updates the property depending on the input value
+ ///
+ /// The new value being set to the property
+ protected async void OnEnabledToggled(bool value)
+ {
+ using (await ConnectedMutex.LockAsync())
+ {
+ if (_IsEnabled == value) return;
+ _IsEnabled = value;
+
+ if (CompositionBrush != null)
+ {
+ if (_IsEnabled) CompositionBrush = await OnBrushRequested().BuildAsync();
+ else CompositionBrush = await PipelineBuilder.FromColor(FallbackColor).BuildAsync();
+ }
+ }
+ }
}
}
diff --git a/UICompositionAnimations/Brushes/Effects/AcrylicEffect.cs b/UICompositionAnimations/Brushes/Effects/AcrylicEffect.cs
new file mode 100644
index 0000000..f78d554
--- /dev/null
+++ b/UICompositionAnimations/Brushes/Effects/AcrylicEffect.cs
@@ -0,0 +1,39 @@
+using System;
+using Windows.UI;
+using Windows.UI.Xaml.Media;
+using UICompositionAnimations.Brushes.Effects.Interfaces;
+
+namespace UICompositionAnimations.Brushes.Effects
+{
+ ///
+ /// A custom acrylic effect that can be inserted into a pipeline
+ ///
+ public sealed class AcrylicEffect : IPipelineEffect
+ {
+ ///
+ /// Gets or sets the source mode for the effect
+ ///
+ public AcrylicBackgroundSource Source { get; set; }
+
+ ///
+ /// Gets or sets the blur amount for the effect
+ ///
+ /// This property is ignored when the active mode is
+ public double BlurAmount { get; set; }
+
+ ///
+ /// Gets or sets the tint for the effect
+ ///
+ public Color Tint { get; set; }
+
+ ///
+ /// Gets or sets the color for the tint effect
+ ///
+ public double TintMix { get; set; }
+
+ ///
+ /// Gets or sets the to the texture to use
+ ///
+ public Uri TextureUri { get; set; }
+ }
+}
diff --git a/UICompositionAnimations/Brushes/PipelineBrush.cs b/UICompositionAnimations/Brushes/PipelineBrush.cs
index 0f33992..ea1f7c6 100644
--- a/UICompositionAnimations/Brushes/PipelineBrush.cs
+++ b/UICompositionAnimations/Brushes/PipelineBrush.cs
@@ -31,6 +31,13 @@ PipelineBuilder Start(IPipelineEffect effect)
case SolidColorEffect color: return PipelineBuilder.FromColor(color.Color);
case ImageEffect image: return PipelineBuilder.FromImage(image.Uri, image.DPIMode, image.CacheMode);
case TileEffect tile: return PipelineBuilder.FromTiles(tile.Uri, tile.DPIMode, tile.CacheMode);
+ case AcrylicEffect acrylic:
+ switch (acrylic.Source)
+ {
+ case AcrylicBackgroundSource.Backdrop: return PipelineBuilder.FromBackdropAcrylic(acrylic.Tint, (float)acrylic.TintMix, (float)acrylic.BlurAmount, acrylic.TextureUri);
+ case AcrylicBackgroundSource.HostBackdrop: return PipelineBuilder.FromHostBackdropAcrylic(acrylic.Tint, (float)acrylic.TintMix, acrylic.TextureUri);
+ default: throw new ArgumentOutOfRangeException(nameof(acrylic.Source), $"Invalid acrylic source: {acrylic.Source}");
+ }
default: throw new ArgumentException($"Invalid initial pipeline effect: {effect.GetType()}");
}
}
diff --git a/UICompositionAnimations/Properties/AssemblyInfo.cs b/UICompositionAnimations/Properties/AssemblyInfo.cs
index 70401c0..a0be0a0 100644
--- a/UICompositionAnimations/Properties/AssemblyInfo.cs
+++ b/UICompositionAnimations/Properties/AssemblyInfo.cs
@@ -23,8 +23,8 @@
// 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("4.0.3.0")]
-[assembly: AssemblyFileVersion("4.0.3.0")]
-[assembly: AssemblyInformationalVersion("4.0.3")]
+[assembly: AssemblyVersion("4.1.0.0")]
+[assembly: AssemblyFileVersion("4.1.0.0")]
+[assembly: AssemblyInformationalVersion("4.1.0")]
[assembly: ComVisible(false)]
diff --git a/UICompositionAnimations/UICompositionAnimations.csproj b/UICompositionAnimations/UICompositionAnimations.csproj
index 8028b0e..f29595d 100644
--- a/UICompositionAnimations/UICompositionAnimations.csproj
+++ b/UICompositionAnimations/UICompositionAnimations.csproj
@@ -130,6 +130,7 @@
+
diff --git a/UICompositionAnimations/UICompositionAnimations.nuspec b/UICompositionAnimations/UICompositionAnimations.nuspec
index fbb8e66..9a43609 100644
--- a/UICompositionAnimations/UICompositionAnimations.nuspec
+++ b/UICompositionAnimations/UICompositionAnimations.nuspec
@@ -2,7 +2,7 @@
UICompositionAnimations
- 4.0.3
+ 4.1.0
UICompositionAnimations
A wrapper UWP PCL to work with Windows.UI.Composition and XAML animations, and Win2D effects
Sergio Pedri
@@ -10,7 +10,7 @@
https://github.com/Sergio0694/UICompositionAnimations
GPL-3.0-only
false
- New extension APIs, more annotations
+ New composition brush APIs and pipeline effects
Copyright © 2019
uwp composition animations xaml csharp windows winrt universal app ui win2d graphics