Ejemplo n.º 1
0
        private void UpdateTransparency()
        {
            var newLevel = UpdateAtomsAndGetTransparency();

            if (newLevel != _currentLevel)
            {
                _currentLevel = newLevel;
                TransparencyLevelChanged?.Invoke(newLevel);
            }
        }
Ejemplo n.º 2
0
 private WindowTransparencyLevel EnableBlur(WindowTransparencyLevel transparencyLevel)
 {
     if (Win32Platform.WindowsVersion.Major >= 6)
     {
         if (DwmIsCompositionEnabled(out var compositionEnabled) != 0 || !compositionEnabled)
         {
             return WindowTransparencyLevel.None;
         }
         else if (Win32Platform.WindowsVersion.Major >= 10)
         {
             return Win10EnableBlur(transparencyLevel);
         }
         else if (Win32Platform.WindowsVersion.Minor >= 2)
         {
             return Win8xEnableBlur(transparencyLevel);
         }
         else
         {
             return Win7EnableBlur(transparencyLevel);
         }
     }
Ejemplo n.º 3
0
 public void SetTransparencyRequest(WindowTransparencyLevel level)
 {
     _requestedLevel = level;
     UpdateTransparency();
 }
Ejemplo n.º 4
0
 public void SetTransparencyLevelHint(WindowTransparencyLevel transparencyLevel)
 {
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TopLevel"/> class.
        /// </summary>
        /// <param name="impl">The platform-specific window implementation.</param>
        /// <param name="dependencyResolver">
        /// The dependency resolver to use. If null the default dependency resolver will be used.
        /// </param>
        public TopLevel(ITopLevelImpl impl, IAvaloniaDependencyResolver?dependencyResolver)
        {
            if (impl == null)
            {
                throw new InvalidOperationException(
                          "Could not create window implementation: maybe no windowing subsystem was initialized?");
            }

            PlatformImpl = impl;

            _actualTransparencyLevel = PlatformImpl.TransparencyLevel;

            dependencyResolver = dependencyResolver ?? AvaloniaLocator.Current;
            var styler = TryGetService <IStyler>(dependencyResolver);

            _accessKeyHandler          = TryGetService <IAccessKeyHandler>(dependencyResolver);
            _inputManager              = TryGetService <IInputManager>(dependencyResolver);
            _keyboardNavigationHandler = TryGetService <IKeyboardNavigationHandler>(dependencyResolver);
            _renderInterface           = TryGetService <IPlatformRenderInterface>(dependencyResolver);
            _globalStyles              = TryGetService <IGlobalStyles>(dependencyResolver);

            Renderer = impl.CreateRenderer(this);

            if (Renderer != null)
            {
                Renderer.SceneInvalidated += SceneInvalidated;
            }
            else
            {
                // Prevent nullable error.
                Renderer = null !;
            }

            impl.SetInputRoot(this);

            impl.Closed                   = HandleClosed;
            impl.Input                    = HandleInput;
            impl.Paint                    = HandlePaint;
            impl.Resized                  = HandleResized;
            impl.ScalingChanged           = HandleScalingChanged;
            impl.TransparencyLevelChanged = HandleTransparencyLevelChanged;

            _keyboardNavigationHandler?.SetOwner(this);
            _accessKeyHandler?.SetOwner(this);

            if (_globalStyles is object)
            {
                _globalStyles.GlobalStylesAdded   += ((IStyleHost)this).StylesAdded;
                _globalStyles.GlobalStylesRemoved += ((IStyleHost)this).StylesRemoved;
            }

            styler?.ApplyStyles(this);

            ClientSize = impl.ClientSize;
            FrameSize  = impl.FrameSize;

            this.GetObservable(PointerOverElementProperty)
            .Select(
                x => (x as InputElement)?.GetObservable(CursorProperty) ?? Observable.Empty <Cursor>())
            .Switch().Subscribe(cursor => PlatformImpl?.SetCursor(cursor?.PlatformImpl));

            if (((IStyleHost)this).StylingParent is IResourceHost applicationResources)
            {
                ResourcesChangedWeakEvent.Subscribe(applicationResources, this);
            }

            impl.LostFocus += PlatformImpl_LostFocus;
        }
Ejemplo n.º 6
0
 public void SetTransparencyLevelHint (WindowTransparencyLevel transparencyLevel)
 {
     TransparencyLevel = EnableBlur(transparencyLevel);
 }
Ejemplo n.º 7
0
 public void SetTransparencyLevelHint(WindowTransparencyLevel transparencyLevel)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 8
0
 public AvaloniaWindowBuilder Transparency(WindowTransparencyLevel transparency)
 {
     this.transparency = transparency; return(this);
 }