void MainWindow_SourceInitialized(object sender, EventArgs e)
    {
        var helper = new WindowInteropHelper(this);
        var hwnd   = helper.Handle;
        var src    = HwndSource.FromHwnd(hwnd);

        src.CompositionTarget.BackgroundColor = Colors.Transparent;
        WindowChrome.SetWindowChrome(this, new WindowChrome {
            CaptionHeight         = 500,
            CornerRadius          = new CornerRadius(0),
            GlassFrameThickness   = new Thickness(0),
            NonClientFrameEdges   = NonClientFrameEdges.None,
            ResizeBorderThickness = new Thickness(0),
            UseAeroCaptionButtons = false
        });
        GraphicsPath path = new GraphicsPath(FillMode.Alternate);

        path.StartFigure();
        path.AddArc(new RectangleF(0, 0, 500, 500), 0, 360);
        path.CloseFigure();
        var dbb = new DwmBlurBehind(true);

        dbb.SetRegion(Graphics.FromHwnd(hwnd), new Region(path));
        DwmApi.DwmEnableBlurBehindWindow(hwnd, ref dbb);
    }
Example #2
0
        private void UpdateGlass()
        {
            DwmBlurBehind DBB = new DwmBlurBehind();

            DBB.Flags  = 0x3;
            DBB.Enable = true;
            DBB.TransitionOnMaximized = false;
            DBB.RgnBlur = this.GlassRegion.GetHrgn(base.CreateGraphics());

            DwmEnableBlurBehindWindow(base.Handle, ref DBB); // Appelle de l'APIs qui ajoute le glass

            base.Invalidate();                               // Retrace la form
        }
Example #3
0
        /// <summary>
        /// Disables the Aero "Blur Behind" effect.
        /// </summary>
        public static void DisableBlurBehind(IntPtr hWnd)
        {
            if (!OsSupport.IsVistaOrLater || !OsSupport.IsCompositionEnabled)
            {
                return;
            }

            var bb = new DwmBlurBehind {
                fEnable = false,
                dwFlags = DwmBlurBehindFlags.Enable
            };

            DwmMethods.DwmEnableBlurBehindWindow(hWnd, ref bb);
        }
Example #4
0
        /// <summary>Enables Blur on Aero Glass.</summary>
        /// <param name="windowHandle">The windows handle to add the blur to.</param>
        /// <param name="region">The area to add the blur to.</param>
        public static void EnableBlur(IntPtr windowHandle, IntPtr region)
        {
            if (Environment.OSVersion.Version.Major < 6)
            {
                return;
            }

            var blur = new DwmBlurBehind { RegionBlur = region, Flags = BlurBehindOptions.BlurBehindRegion };

            if (NativeMethods.DwmEnableBlurBehindWindow(windowHandle, ref blur) != 0)
            {
                // throw new InvalidOperationException();
            }
        }
Example #5
0
        /// <summary>
        /// Enable the Aero "Blur Behind" effect on the whole client area.
        /// Background of the clint area must be painted in black.
        /// </summary>
        public static void EnableBlurBehind(IntPtr hWnd)
        {
            if (!OsSupport.IsVistaOrBetter || !OsSupport.IsCompositionEnabled)
            {
                return;
            }

            var bb = new DwmBlurBehind {
                fEnable  = true,
                hRgnBlur = IntPtr.Zero,
                dwFlags  = DwmBlurBehindFlags.Enable
            };

            DwmMethods.DwmEnableBlurBehindWindow(hWnd, ref bb);
        }
Example #6
0
        /// <summary>Enables Blur on Aero Glass.</summary>
        /// <param name="windowHandle">The windows handle to add the blur to.</param>
        /// <param name="region">The area to add the blur to.</param>
        public static void EnableBlur(IntPtr windowHandle, IntPtr region)
        {
            if (Environment.OSVersion.Version.Major < 6)
            {
                return;
            }

            var blur = new DwmBlurBehind {
                RegionBlur = region, Flags = BlurBehindOptions.BlurBehindRegion
            };

            if (NativeMethods.DwmEnableBlurBehindWindow(windowHandle, ref blur) != 0)
            {
                // throw new InvalidOperationException();
            }
        }
Example #7
0
 public static extern void DwmEnableBlurBehindWindow(IntPtr hwnd, ref DwmBlurBehind blurBehind);
Example #8
0
 private extern static void DwmEnableBlurBehindWindow(IntPtr hWnd, ref DwmBlurBehind BlurBehind);
Example #9
0
 internal static extern int DwmEnableBlurBehindWindow(IntPtr handle, ref DwmBlurBehind bb);
Example #10
0
 internal static extern void DwmEnableBlurBehindWindow(
     [In] HandleRef hWnd,
     [In] DwmBlurBehind pBlurBehind);