diff --git a/components/Media/src/Brushes/AcrylicBrush.cs b/components/Media/src/Brushes/AcrylicBrush.cs index ba95daea..272764c4 100644 --- a/components/Media/src/Brushes/AcrylicBrush.cs +++ b/components/Media/src/Brushes/AcrylicBrush.cs @@ -2,17 +2,21 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#if WINUI2 using CommunityToolkit.WinUI.Media.Pipelines; +#if WINUI3 +using Microsoft.UI.Composition; +#endif using Windows.UI; +#if WINUI2 using Windows.UI.Composition; +#endif namespace CommunityToolkit.WinUI.Media; /// /// A that implements an acrylic effect with customizable parameters /// -public sealed class AcrylicBrush : XamlCompositionEffectBrushBase +public sealed partial class AcrylicBrush : XamlCompositionEffectBrushBase { /// /// The instance in use to set the blur amount @@ -30,6 +34,7 @@ public sealed class AcrylicBrush : XamlCompositionEffectBrushBase /// private EffectSetter? tintOpacitySetter; +#if WINUI2 /// /// Gets or sets the background source mode for the effect (the default is ). /// @@ -62,11 +67,18 @@ private static void OnSourcePropertyChanged(DependencyObject d, DependencyProper brush.OnConnected(); } } +#endif +#if WINUI2 /// /// Gets or sets the blur amount for the effect (must be a positive value) /// /// This property is ignored when the active mode is +#else + /// + /// Gets or sets the blur amount for the effect (must be a positive value) + /// +#endif public double BlurAmount { get => (double)GetValue(BlurAmountProperty); @@ -90,7 +102,9 @@ public double BlurAmount private static void OnBlurAmountPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is AcrylicBrush brush && +#if WINUI2 brush.BackgroundSource != AcrylicBackgroundSource.HostBackdrop && // Blur is fixed by OS when using HostBackdrop source. +#endif brush.CompositionBrush is CompositionBrush target) { brush.blurAmountSetter?.Invoke(target, (float)(double)e.NewValue); @@ -197,6 +211,7 @@ private static void OnTextureUriPropertyChanged(DependencyObject d, DependencyPr /// protected override PipelineBuilder OnPipelineRequested() { +#if WINUI2 switch (BackgroundSource) { case AcrylicBackgroundSource.Backdrop: @@ -217,6 +232,15 @@ protected override PipelineBuilder OnPipelineRequested() TextureUri); default: throw new ArgumentOutOfRangeException(nameof(BackgroundSource), $"Invalid acrylic source: {BackgroundSource}"); } +#else + return PipelineBuilder.FromBackdropAcrylic( + TintColor, + out this.tintColorSetter, + (float)TintOpacity, + out this.tintOpacitySetter, + (float)BlurAmount, + out blurAmountSetter, + TextureUri); +#endif } } -#endif