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; }
private void RemoveBlur() { _detectIsActiveTimer.Enabled = false; if (_visualBlur != null) { _visualBlur.Visible = false; _visualBlur.Dispose(); _visualBlur = null; } }
internal void TakeSnapshot() { _currentFormDisplay?.Dispose(); if (!_blurValues.BlurWhenFocusLost || _parentForm.IsDisposed || _parentForm.Disposing ) { // Has blur been turned off ? _currentFormDisplay = null; return; } Rectangle clientRectangle = CommonHelper.RealClientRectangle(_parentForm.Handle); _currentFormDisplay = TakeSnapshot(VisualBlur.GetTargetRectangle(_parentForm.DesktopLocation, clientRectangle)); }
private void RemoveBlur() { if (!_parentForm.IsDisposed && !_parentForm.Disposing && _parentBeforeOpacity.HasValue ) { _parentForm.Opacity = _parentBeforeOpacity.Value; _parentBeforeOpacity = null; } _detectIsActiveTimer.Enabled = false; if (_visualBlur != null) { _visualBlur.Visible = false; _visualBlur.Dispose(); _visualBlur = null; } }
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; }