当前位置: 首页>>代码示例>>C#>>正文


C# Compositor.CreateBackdropBrush方法代码示例

本文整理汇总了C#中Compositor.CreateBackdropBrush方法的典型用法代码示例。如果您正苦于以下问题:C# Compositor.CreateBackdropBrush方法的具体用法?C# Compositor.CreateBackdropBrush怎么用?C# Compositor.CreateBackdropBrush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Compositor的用法示例。


在下文中一共展示了Compositor.CreateBackdropBrush方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetupDestinationEffect

        public void SetupDestinationEffect(Compositor compositor)
        {
            // Create SpriteVisual for blur effect
            _destVisual = compositor.CreateSpriteVisual();
            _destVisual.Size = new Vector2(0, 0);

            // Create graphics effect for blur
            var graphicsEffect = new GaussianBlurEffect
            {
                Name = "GB",
                Source = new CompositionEffectSourceParameter("destinationSource"),
                BlurAmount = 10f,
                BorderMode = EffectBorderMode.Hard,
                Optimization = EffectOptimization.Balanced

            };

            var effectFactory = compositor.CreateEffectFactory(graphicsEffect);

            var blurEffect = effectFactory.CreateBrush();
            var destinationBrush = compositor.CreateBackdropBrush();

            blurEffect.SetSourceParameter("destinationSource", destinationBrush);

            // Set the SpriteVisual's brush as blur effect
            _destVisual.Brush = blurEffect;

            // Insert the destination visual as child of the BlurRect UIElement.
            // Since the BlurRect is between the text of the flyout and the content of the page,
            // the destination visual will blur the content of the page.
            ElementCompositionPreview.SetElementChildVisual(BlurRect, _destVisual);
        }
开发者ID:huoxudong125,项目名称:Windows-universal-samples,代码行数:32,代码来源:Scenario2_Conditional.xaml.cs

示例2: Backdrop

        public Backdrop()
        {
            DefaultStyleKey = typeof(Backdrop);

            SizeChanged += (sender, e) =>
            {
                UpdateVisualSize();
            };

            var rootVisual = ElementCompositionPreview.GetElementVisual(this);
            _compositor = rootVisual.Compositor;
            _blurVisual = _compositor.CreateSpriteVisual();
            var brush = CreateBlurBrush();
            brush.SetSourceParameter("Source", _compositor.CreateBackdropBrush());
            _blurVisual.Brush = brush;

            ElementCompositionPreview.SetElementChildVisual(this, _blurVisual);
        }
开发者ID:h82258652,项目名称:SoftwareKobo.UI,代码行数:18,代码来源:BackDrop.cs

示例3: SetupBlur

        private void SetupBlur()
        {
            compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;

            var blur = new GaussianBlurEffect
            {
                Name = "Blur",
                Source = new CompositionEffectSourceParameter("Backdrop"),
                BlurAmount = 0.0f,
                BorderMode = EffectBorderMode.Hard
            };

            var blend = new BlendEffect
            {
                Name = "Blend",
                Foreground = new ColorSourceEffect
                {
                    Color = Color.FromArgb(128, 30, 30, 220),
                    Name = "ColorSource"
                },
                Background = blur,
                Mode = BlendEffectMode.Overlay
            };
            
            var effectFactory = compositor.CreateEffectFactory(blend, new[] {"Blur.BlurAmount"});
            brush = effectFactory.CreateBrush();

            var backdrop = compositor.CreateBackdropBrush();
            brush.SetSourceParameter("Backdrop", backdrop);

            var sprite = compositor.CreateSpriteVisual();

            sprite.Brush = brush;
            sprite.Size = new Vector2((float) TargetImage.ActualWidth, (float) TargetImage.ActualHeight);

            ElementCompositionPreview.SetElementChildVisual(TargetImage, sprite);
        }
开发者ID:nigel-sampson,项目名称:talks,代码行数:37,代码来源:EffectsView.xaml.cs

示例4: OnLoaded

        private async void OnLoaded(object sender, RoutedEventArgs e)
        {
            _compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;
            _generator = CompositionGeneratorFactory.GetCompositionGenerator(_compositor);
            _backdropBrush = _compositor.CreateBackdropBrush();

            _width = 300f;
            _height = 300f;
            // Create the combined geometry
            var ellipse1 = CanvasGeometry.CreateEllipse(_generator.Device, _width / 2, _height / 2, 0.45f * _width, 0.225f * _height);
            var ellipse2 = CanvasGeometry.CreateEllipse(_generator.Device, _width / 2, _height / 2, 0.225f * _width, 0.45f * _height);
            _combinedGeometry = ellipse1.CombineWith(ellipse2, Matrix3x2.Identity, CanvasGeometryCombine.Union);

            // Create the container to host the visuals
            var container1 = _compositor.CreateContainerVisual();
            container1.Size = new Vector2(CompositionGrid1.ActualWidth.Single(), CompositionGrid1.ActualHeight.Single());

            // Background Visual
            _bgVisual1 = _compositor.CreateSpriteVisual();
            _bgVisual1.Size = new Vector2(_width * 0.45f, _height * 0.45f);
            _bgVisual1.Offset = new Vector3(((CompositionGrid1.ActualWidth - _width) / 2).Single(),
                                         ((CompositionGrid1.ActualHeight - _height) / 2).Single(), 0);

            _bgVisual1.Brush = _compositor.CreateColorBrush(Colors.DarkOrange);

            container1.Children.InsertAtBottom(_bgVisual1);

            // Create custom shaped visual using CompositionMaskBrush
            _visual1 = _compositor.CreateSpriteVisual();
            _visual1.Size = new Vector2(_width, _height);
            _visual1.Offset = new Vector3(((CompositionGrid1.ActualWidth - _width) / 2).Single(),
                                         ((CompositionGrid1.ActualHeight - _height) / 2).Single(), 0);
            // Create the CompositionMask
            var ellipseGeometry = CanvasGeometry.CreateEllipse(_generator.Device, _width / 2, _height / 2, 0.4f * _width, 0.4f * _height);
            var compositionMask = _generator.CreateMaskSurface(_visual1.Size.ToSize(), ellipseGeometry);
            // Create Masked BackdropBrush from CompositionMask
            _visual1.Brush = _compositor.CreateMaskedBackdropBrush(compositionMask, Colors.AntiqueWhite, 30f, _backdropBrush);

            container1.Children.InsertAtTop(_visual1);

            var visual = _compositor.CreateSpriteVisual();
            visual.Size = new Vector2(400, 400);
            visual.Offset = new Vector3(((3 * CompositionGrid1.ActualWidth / 4f) - (_width / 2)).Single(),
                                         ((3 * CompositionGrid1.ActualHeight / 4f) - (_height / 2)).Single(), 0);
            var roundRectGeometry = CanvasGeometry.CreateRoundedRectangle(_generator.Device, 0, 0, _width, _height, 25, 25);
            var maskSurface = _generator.CreateMaskSurface(visual.Size.ToSize(), roundRectGeometry);

            var frostedBrush = _compositor.CreateFrostedGlassBrush(maskSurface, Colors.AntiqueWhite, 30f, _backdropBrush);

            var shadow = _compositor.CreateDropShadow();
            shadow.Opacity = 0.5f;
            shadow.Color = Colors.Black;
            shadow.Offset = new Vector3(10, 10, 0);
            shadow.BlurRadius = 15;
            shadow.Mask = frostedBrush.GetSourceParameter("mask");

            visual.Brush = frostedBrush;
            visual.Shadow = shadow;

            container1.Children.InsertAtTop(visual);

            ElementCompositionPreview.SetElementChildVisual(CompositionGrid1, container1);

            // Initialize the visuals for the Animated Canvas
            // Create the container to host the visuals
            var container2 = _compositor.CreateContainerVisual();
            container2.Size = new Vector2(CompositionGrid2.ActualWidth.Single(), CompositionGrid2.ActualHeight.Single());

            // Background Visual
            _bgVisual2 = _compositor.CreateSpriteVisual();
            _bgVisual2.Size = new Vector2(_width * Factor, _height * Factor);
            _bgVisual2.Offset = new Vector3(((CompositionGrid2.ActualWidth - (_width * Factor)) / 2).Single(),
                                         ((CompositionGrid2.ActualHeight - (_height * Factor)) / 2).Single(), 0);

            //var radians = ((45f * Math.PI) / 180).Single();
            //var bgGeometry = _combinedGeometry.Transform(Matrix3x2.CreateRotation(radians, new Vector2(_width / 2, _height / 2)));
            //var bgMask = await _generator.CreateMaskAsync(_bgVisual2.Size.ToSize(), bgGeometry, Colors.DarkRed);
            //_bgVisual2.Brush = _compositor.CreateSurfaceBrush(bgMask.Surface);
            _bgVisual2.Brush = _compositor.CreateColorBrush(Colors.LawnGreen);

            container2.Children.InsertAtBottom(_bgVisual2);

            // Animated Visual
            _animatedVisual = _compositor.CreateSpriteVisual();
            _animatedVisual.Size = new Vector2(_width, _height);
            _animatedVisual.Offset = new Vector3(((CompositionGrid2.ActualWidth - _width) / 2).Single(),
                                                ((CompositionGrid2.ActualHeight - _height) / 2).Single(), 0);
            // Create the Excluded geometry
            _outerGeometry = CanvasGeometry.CreateRectangle(_generator.Device, 0, 0, _width, _height);
            var excludedGeometry = _outerGeometry.CombineWith(_combinedGeometry, Matrix3x2.Identity, CanvasGeometryCombine.Exclude);
            // Create the CompositionMask
            _animatedCompositionMask = _generator.CreateMaskSurface(_animatedVisual.Size.ToSize(), excludedGeometry);
            var animBrush = _compositor.CreateMaskedBackdropBrush(_animatedCompositionMask, Colors.AntiqueWhite, 10f, _backdropBrush);
            _animatedVisual.Brush = animBrush;

            container2.Children.InsertAtTop(_animatedVisual);

            ElementCompositionPreview.SetElementChildVisual(CompositionGrid2, container2);
        }
开发者ID:RareNCool,项目名称:CompositionProToolkit,代码行数:99,代码来源:MaskedBackdropPage.xaml.cs


注:本文中的Compositor.CreateBackdropBrush方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。