예제 #1
0
        private void DoTheBlur()
        {
            if (!_blurValues.EnableBlur)
            {
                // Has blur been turned off ?
                return;
            }
            _visualBlur = new VisualBlur(_blurValues);
            Rectangle clientRectangle = CommonHelper.RealClientRectangle(_parentForm.Handle);

            _visualBlur.SetTargetRect(_parentForm.DesktopLocation, clientRectangle);

            Rectangle targetRect = _visualBlur.TargetRect;
            Bitmap    bmp        = TakeSnapshot(targetRect);

            _visualBlur.UpdateBlur(bmp);
            PI.SetWindowPos(_visualBlur.Handle, PI.HWND_TOPMOST,
                            //PI.SetWindowPos(_visualBlur.Handle, _parentForm.Handle,
                            targetRect.X, targetRect.Y, targetRect.Width, targetRect.Height,
                            PI.SWP_.NOACTIVATE
                            | PI.SWP_.NOREDRAW
                            | PI.SWP_.SHOWWINDOW
                            | PI.SWP_.NOCOPYBITS
                            //| PI.SWP_.NOOWNERZORDER
                            );
            _detectIsActiveTimer.Enabled = true;
        }
예제 #2
0
        private void DoTheBlur()
        {
            if (!_blurValues.BlurWhenFocusLost ||
                _parentForm.IsDisposed ||
                _parentForm.Disposing
                )
            {
                // Has blur been turned off ?
                return;
            }
            _visualBlur = new VisualBlur(_blurValues);
            Rectangle clientRectangle = CommonHelper.RealClientRectangle(_parentForm.Handle);

            _visualBlur.SetTargetRect(_parentForm.DesktopLocation, clientRectangle);

            Rectangle targetRect = _visualBlur.TargetRect;

            _visualBlur.UpdateBlur(_currentFormDisplay);
            // As UpdateBlur can take a few moments, then it is possible for the app to be closed before getting to the next line
            if ((_visualBlur == null) ||
                _parentForm.IsDisposed ||
                _parentForm.Disposing
                )
            {
                return;
            }

            PI.SetWindowPos(_visualBlur.Handle, PI.HWND_TOP, //.HWND_TOPMOST,
                                                             //PI.SetWindowPos(_visualBlur.Handle, _parentForm.Handle,
                            targetRect.X, targetRect.Y, targetRect.Width, targetRect.Height,
                            PI.SWP_.NOACTIVATE
                            | PI.SWP_.NOREDRAW
                            | PI.SWP_.SHOWWINDOW
                            | PI.SWP_.NOCOPYBITS
                            //| PI.SWP_.NOOWNERZORDER
                            );
            // Set parent form opacity afterwards to prevent flicker
            _parentBeforeOpacity ??= _parentForm.Opacity;

            _parentForm.Opacity          = _blurValues.Opacity / 100.0;
            _detectIsActiveTimer.Enabled = true;
        }