Exemple #1
0
        private static PipelineBuilder Start(IPipelineEffect effect)
        {
            switch (effect)
            {
            case BackdropEffect backdrop when backdrop.Source == AcrylicBackgroundSource.Backdrop:
                return(PipelineBuilder.FromBackdrop());

            case BackdropEffect backdrop when backdrop.Source == AcrylicBackgroundSource.HostBackdrop:
                return(PipelineBuilder.FromHostBackdrop());

            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 when acrylic.Source == AcrylicBackgroundSource.Backdrop:
                return(PipelineBuilder.FromBackdropAcrylic(acrylic.Tint, (float)acrylic.TintMix, (float)acrylic.BlurAmount, acrylic.TextureUri));

            case AcrylicEffect acrylic when acrylic.Source == AcrylicBackgroundSource.HostBackdrop:
                return(PipelineBuilder.FromHostBackdropAcrylic(acrylic.Tint, (float)acrylic.TintMix, acrylic.TextureUri));

            default:
                throw new ArgumentException($"Invalid initial pipeline effect: {effect.GetType()}");
            }
        }
        public AcrylicAndBlurDemo()
        {
            this.InitializeComponent();
            CustomPipelineBrush = PipelineBuilder.FromHostBackdrop()
                                  .LuminanceToAlpha()
                                  .Opacity(0.4f)
                                  .Blend(
                PipelineBuilder.FromHostBackdrop(),
                BlendEffectMode.Multiply)
                                  .Blur(16)
                                  .Shade("#FF222222".ToColor(), 0.4f)
                                  .Blend(
                PipelineBuilder.FromTiles("/Assets/BrushAssets/NoiseTexture.png"),
                BlendEffectMode.Overlay,
                Placement.Background)
                                  .AsBrush();

            HasBlur             = true;
            HasLuminanceToAlpha = true;
            HasOpacity          = true;
            HasShade            = true;
            EffectOpacity       = 0.4;
            BlurAmount          = 16;
            ShadeColor          = "#FF222222".ToColor();
            ShadeIntensity      = 0.4;
            UpdateCustomPipelineBrushDark();
        }
 /// <inheritdoc/>
 protected override object ProvideValue()
 {
     return(BackgroundSource switch
     {
         AcrylicBackgroundSource.Backdrop => PipelineBuilder.FromBackdrop(),
         AcrylicBackgroundSource.HostBackdrop => PipelineBuilder.FromHostBackdrop(),
         _ => throw new ArgumentException($"Invalid source for backdrop effect: {BackgroundSource}")
     });