Пример #1
0
        /// <summary>
        /// Excludes a UI element from the AeroGlass frame.
        /// </summary>
        /// <param name="element">The element to exclude.</param>
        /// <remarks>Many non-WPF rendered controls (i.e., the ExplorerBrowser control) will not
        /// render properly on top of an AeroGlass frame. </remarks>
        public void ExcludeElementFromAeroGlass(FrameworkElement element)
        {
            if (AeroGlassCompositionEnabled && element != null)
            {
                // calculate total size of window nonclient area
                HwndSource hwndSource = PresentationSource.FromVisual(this) as HwndSource;
                NativeRect windowRect;
                NativeRect clientRect;
                DesktopWindowManagerNativeMethods.GetWindowRect(hwndSource.Handle, out windowRect);
                DesktopWindowManagerNativeMethods.GetClientRect(hwndSource.Handle, out clientRect);
                Size nonClientSize = new Size(
                    (double)(windowRect.Right - windowRect.Left) - (double)(clientRect.Right - clientRect.Left),
                    (double)(windowRect.Bottom - windowRect.Top) - (double)(clientRect.Bottom - clientRect.Top));

                // calculate size of element relative to nonclient area
                GeneralTransform transform        = element.TransformToAncestor(this);
                Point            topLeftFrame     = transform.Transform(new Point(0, 0));
                Point            bottomRightFrame = transform.Transform(new Point(
                                                                            element.ActualWidth + nonClientSize.Width,
                                                                            element.ActualHeight + nonClientSize.Height));

                // Create a margin structure
                Margins margins = new Margins();
                margins.LeftWidth    = (int)topLeftFrame.X;
                margins.RightWidth   = (int)(this.ActualWidth - bottomRightFrame.X);
                margins.TopHeight    = (int)(topLeftFrame.Y);
                margins.BottomHeight = (int)(this.ActualHeight - bottomRightFrame.Y);

                // Extend the Frame into client area
                DesktopWindowManagerNativeMethods.DwmExtendFrameIntoClientArea(windowHandle, ref margins);
            }
        }
Пример #2
0
 /// <summary>
 /// Resets the AeroGlass exclusion area.
 /// </summary>
 public void ResetAeroGlass()
 {
     if (this.Handle != IntPtr.Zero)
     {
         Margins margins = new Margins(true);
         DesktopWindowManagerNativeMethods.DwmExtendFrameIntoClientArea(this.Handle, ref margins);
     }
 }
Пример #3
0
        /// <summary>
        /// Excludes a Control from the AeroGlass frame.
        /// </summary>
        /// <param name="control">The control to exclude.</param>
        /// <remarks>Many non-WPF rendered controls (i.e., the ExplorerBrowser control) will not
        /// render properly on top of an AeroGlass frame. </remarks>
        public void ExcludeControlFromAeroGlass(Control control)
        {
            if (AeroGlassCompositionEnabled)
            {
                Rectangle clientScreen  = this.RectangleToScreen(this.ClientRectangle);
                Rectangle controlScreen = control.RectangleToScreen(control.ClientRectangle);

                MARGINS margins = new MARGINS( );
                margins.cxLeftWidth    = controlScreen.Left - clientScreen.Left;
                margins.cxRightWidth   = clientScreen.Right - controlScreen.Right;
                margins.cyTopHeight    = controlScreen.Top - clientScreen.Top;
                margins.cyBottomHeight = clientScreen.Bottom - controlScreen.Bottom;

                // Extend the Frame into client area
                DesktopWindowManagerNativeMethods.DwmExtendFrameIntoClientArea(Handle, ref margins);
            }
        }
Пример #4
0
        /// <summary>
        /// Excludes a Control from the AeroGlass frame.
        /// </summary>
        /// <param name="control">The control to exclude.</param>
        /// <remarks>Many non-WPF rendered controls (i.e., the ExplorerBrowser control) will not
        /// render properly on top of an AeroGlass frame. </remarks>
        public void ExcludeControlFromAeroGlass(Control control)
        {
            if (control == null)
            {
                throw new ArgumentNullException("control");
            }

            if (AeroGlassCompositionEnabled)
            {
                Rectangle clientScreen  = this.RectangleToScreen(this.ClientRectangle);
                Rectangle controlScreen = control.RectangleToScreen(control.ClientRectangle);

                Margins margins = new Margins();
                margins.LeftWidth    = controlScreen.Left - clientScreen.Left;
                margins.RightWidth   = clientScreen.Right - controlScreen.Right;
                margins.TopHeight    = controlScreen.Top - clientScreen.Top;
                margins.BottomHeight = clientScreen.Bottom - controlScreen.Bottom;

                // Extend the Frame into client area
                DesktopWindowManagerNativeMethods.DwmExtendFrameIntoClientArea(Handle, ref margins);
            }
        }
Пример #5
0
        /// <summary>
        /// Resets the AeroGlass exclusion area.
        /// </summary>
        public void ResetAreoGlass()
        {
            MARGINS margins = new MARGINS(true);

            DesktopWindowManagerNativeMethods.DwmExtendFrameIntoClientArea(windowHandle, ref margins);
        }