示例#1
0
        private void UpdateBrush()
        {
            if (m_isDisabledByPolicy && m_brush is CompositionEffectBrush)
            {
                m_brush.Dispose();
                m_brush = null;
            }

            if (m_brush == null)
            {
                if (m_isDisabledByPolicy)
                {
                    m_brush          = Window.Current.Compositor.CreateColorBrush(FallbackColor);
                    CompositionBrush = m_brush;
                }
                else
                {
                    var gaussianBlur = new GaussianBlurEffect
                    {
                        Name         = "Blur",
                        BlurAmount   = 30,
                        Optimization = EffectOptimization.Speed,
                        BorderMode   = EffectBorderMode.Hard,
                        Source       = new CompositionEffectSourceParameter("Backdrop")
                    };

                    var saturationEffect = new SaturationEffect
                    {
                        Name       = "Saturation",
                        Saturation = 1.7f,
                        Source     = gaussianBlur
                    };

                    var tintColorEffect = new ColorSourceEffect
                    {
                        Name  = "TintColor",
                        Color = Color.FromArgb(52, 0, 0, 0)
                    };

                    var compositeEffect = new CompositeEffect();
                    compositeEffect.Mode = CanvasComposite.SourceOver;
                    compositeEffect.Sources.Add(saturationEffect);
                    compositeEffect.Sources.Add(tintColorEffect);

                    var effectFactory = Window.Current.Compositor.CreateEffectFactory(compositeEffect);
                    var backdrop      = Window.Current.Compositor.CreateBackdropBrush();

                    var brush = effectFactory.CreateBrush();
                    brush.SetSourceParameter("Backdrop", backdrop);

                    m_brush          = brush;
                    CompositionBrush = m_brush;
                }
            }
        }
示例#2
0
 protected override void OnDisconnected()
 {
     CoreWindow.GetForCurrentThread().Activated         -= AcrylicBrush_Activated;
     CoreWindow.GetForCurrentThread().VisibilityChanged -= AcrylicBrush_VisibilityChanged;
     CompositionBrush.Dispose();
     CompositionBrush = null;
 }
 private void ClearResources()
 {
     _imageBrush?.Dispose();
     _imageBrush = null;
     _surfaceSource?.Dispose();
     _surfaceSource = null;
 }
示例#4
0
        /// <summary>
        /// Deconstructs the Composition Brush.
        /// </summary>
        protected override void OnDisconnected()
        {
            base.OnDisconnected();

            if (_device != null)
            {
                _device.DeviceLost -= CanvasDevice_DeviceLost;
                _device             = null;
            }

            if (_graphics != null)
            {
                _graphics.RenderingDeviceReplaced -= CanvasDevice_RenderingDeviceReplaced;
                _graphics = null;
            }

            // Dispose of composition resources when no longer in use.
            if (CompositionBrush != null)
            {
                CompositionBrush.Dispose();
                CompositionBrush = null;
            }

            if (_surfaceBrush != null)
            {
                _surfaceBrush.Dispose();
                _surfaceBrush = null;
            }
        }
        protected override void OnDisconnected()
        {
            if (CompositionBrush != null)
            {
                IsConnected = false;

                canvasDevice.Dispose();
                canvasDevice = null;
                graphicsDevice.Dispose();
                graphicsDevice = null;

                surfaceBrush1.Dispose();
                surfaceBrush1 = null;
                surfaceBrush2.Dispose();
                surfaceBrush2 = null;

                surface1.Dispose();
                surface1 = null;
                surface2.Dispose();
                surface2 = null;

                Source1Animation.Dispose();
                Source1Animation = null;
                Source2Animation.Dispose();
                Source2Animation = null;

                colorBrush1.Dispose();
                colorBrush1 = null;
                colorBrush2.Dispose();
                colorBrush2 = null;

                CompositionBrush.Dispose();
                CompositionBrush = null;
            }
        }
        protected override void OnDisconnected()
        {
            Window.Current.SizeChanged -= OnWindowSizeChanged;

            CompositionBrush?.Dispose();
            CompositionBrush = null;
        }
示例#7
0
 protected override void OnDisconnected()
 {
     if (CompositionBrush != null)
     {
         CompositionBrush.Dispose();
         CompositionBrush = null;
     }
 }
 /// <summary>
 /// Deconstructs the Composition Brush.
 /// </summary>
 protected override void OnDisconnected()
 {
     // Dispose of composition resources when no longer in use.
     if (CompositionBrush != null)
     {
         CompositionBrush.Dispose();
         CompositionBrush = null;
     }
 }
示例#9
0
 protected override void OnDisconnected()
 {
     // Dispose CompositionBrushes if XamlCompBrushBase is removed from tree
     if (CompositionBrush != null)
     {
         CompositionBrush.Dispose();
         CompositionBrush = null;
     }
 }
示例#10
0
 protected override void OnDisconnected()
 {
     if (CompositionBrush != null)
     {
         CompositionBrush.Dispose();
         CompositionBrush = null;
         ColorImplicitAnimations.Dispose();
         ColorImplicitAnimations = null;
         ColorAnimation.Dispose();
         ColorAnimation = null;
     }
 }
示例#11
0
        protected override async void OnDisconnected()
        {
            await _semaphoreSlim.WaitAsync();

            if (CompositionBrush != null)
            {
                CompositionBrush.Dispose();
                CompositionBrush = null;
            }
            _semaphoreSlim.Release();
            base.OnDisconnected();
        }
示例#12
0
 protected override void OnDisconnected()
 {
     if (_surface != null)
     {
         _surface.Dispose();
         _surface = null;
     }
     if (CompositionBrush != null)
     {
         CompositionBrush.Dispose();
         CompositionBrush = null;
     }
 }
示例#13
0
        private void DisconnectAcryilicBrush()
        {
            if (backdropBrush != null)
            {
                backdropBrush.Dispose();
                backdropBrush = null;
            }

            if (CompositionBrush != null)
            {
                CompositionBrush.Dispose();
                CompositionBrush = null;
            }
        }
示例#14
0
 protected override void OnDisconnected()
 {
     // Dispose Surface and CompositionBrushes if XamlCompBrushBase is removed from tree
     if (_surface != null)
     {
         _surface.Dispose();
         _surface = null;
     }
     if (CompositionBrush != null)
     {
         CompositionBrush.Dispose();
         CompositionBrush = null;
     }
 }
        protected override void OnDisconnected()
        {
            if (CompositionBrush != null)
            {
                IsConnected         = false;
                TransitionCompleted = null;

                ColorAnimation.Dispose();
                ColorAnimation = null;

                CompositionBrush.Dispose();
                CompositionBrush = null;
            }
        }
示例#16
0
        protected override void OnDisconnected()
        {
            _connected  = false;
            _tintEffect = null;

            if (CompositionBrush != null)
            {
                CompositionBrush.Dispose();
                CompositionBrush = null;
            }

            if (Surface != null)
            {
                Surface.Dispose();
                Surface = null;
            }
        }
示例#17
0
        protected override void OnDisconnected()
        {
            base.OnDisconnected();

            if (_window != null)
            {
                _window.Changed -= AppWindow_Changed;
            }

            if (_appWindowActivationListener != null)
            {
                _appWindowActivationListener.InputActivationChanged -= AppWindow_InputActivationChanged;
                _appWindowActivationListener.Dispose();
            }

            if (_settings != null)
            {
                _settings.ColorValuesChanged -= ColorValuesChanged;
                _settings = null;
            }

            if (_accessibilitySettings != null)
            {
                _accessibilitySettings.HighContrastChanged -= AccessibilitySettings_HighContrastChanged;
                _accessibilitySettings = null;
            }

            PowerManager.EnergySaverStatusChanged -= PowerManager_EnergySaverStatusChanged;

            CompositionCapabilities.GetForCurrentView().Changed -= CompositionCapabilities_Changed;

            if (CompositionBrush != null)
            {
                CompositionBrush.Dispose();
                CompositionBrush = null;
            }
        }
示例#18
0
        private void UpdateBrush()
        {
            FrameworkElement root = _root;

            if (_window != null)
            {
                root = ElementCompositionPreview.GetAppWindowContent(_window) as FrameworkElement;
            }

            if (root == null || _settings == null || _accessibilitySettings == null || _fastEffects == null || _energySaver == null)
            {
                return;
            }

            bool useSolidColorFallback = !_settings.AdvancedEffectsEnabled || !_wallpaperBrushSupported || !_windowActivated || _fastEffects == false || _energySaver == true;


            Compositor compositor = Window.Current.Compositor;

            ElementTheme currentTheme = root.ActualTheme;
            Color        tintColor    = currentTheme == ElementTheme.Light ? Color.FromArgb(255, 243, 243, 243) : Color.FromArgb(255, 32, 32, 32);
            float        tintOpacity  = currentTheme == ElementTheme.Light ? 0.5f : 0.8f;

            if (_accessibilitySettings.HighContrast)
            {
                tintColor             = _settings.GetColorValue(UIColorType.Background);
                useSolidColorFallback = true;
            }

            FallbackColor = tintColor;

            CompositionBrush newBrush;

            if (useSolidColorFallback)
            {
                newBrush = compositor.CreateColorBrush(tintColor);
            }
            else
            {
                newBrush = BuildMicaEffectBrush(compositor, tintColor, tintOpacity, 1.0f);
            }

            CompositionBrush oldBrush = CompositionBrush;

            if (oldBrush == null || (CompositionBrush.Comment == "Crossfade") || (oldBrush is CompositionColorBrush && newBrush is CompositionColorBrush))
            {
                // Set new brush directly
                if (oldBrush != null)
                {
                    oldBrush.Dispose();
                }
                CompositionBrush = newBrush;
            }
            else
            {
                // Crossfade
                CompositionBrush        crossFadeBrush = CreateCrossFadeEffectBrush(compositor, oldBrush, newBrush);
                ScalarKeyFrameAnimation animation      = CreateCrossFadeAnimation(compositor);
                CompositionBrush = crossFadeBrush;

                var crossFadeAnimationBatch = compositor.CreateScopedBatch(CompositionBatchTypes.Animation);
                crossFadeBrush.StartAnimation("CrossFade.CrossFade", animation);
                crossFadeAnimationBatch.End();

                crossFadeAnimationBatch.Completed += (o, a) =>
                {
                    crossFadeBrush.Dispose();
                    oldBrush.Dispose();
                    CompositionBrush = newBrush;
                };
            }
        }