using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Drawing;

namespace Sheng.Winform.Controls.Win32
{
    /// <summary>
    /// 
    /// </summary>
    public class DwmApi
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="hWnd"></param>
        /// <param name="pBlurBehind"></param>
         [DllImport("dwmapi.dll", PreserveSig = false)]
        public static extern void DwmEnableBlurBehindWindow(IntPtr hWnd, DWM_BLURBEHIND pBlurBehind);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="hWnd"></param>
        /// <param name="pMargins"></param>
        [DllImport("dwmapi.dll", PreserveSig = false)]
        public static extern void DwmExtendFrameIntoClientArea(IntPtr hWnd, MARGINS pMargins);
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        [DllImport("dwmapi.dll", PreserveSig = false)]
        public static extern bool DwmIsCompositionEnabled();
        /// <summary>
        /// 
        /// </summary>
        /// <param name="pcrColorization"></param>
        /// <param name="pfOpaqueBlend"></param>
        [DllImport("dwmapi.dll", PreserveSig = false)]
        public static extern void DwmGetColorizationColor(
            out int pcrColorization,
            [MarshalAs(UnmanagedType.Bool)]out bool pfOpaqueBlend);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="bEnable"></param>
        [DllImport("dwmapi.dll", PreserveSig = false)]
        public static extern void DwmEnableComposition(bool bEnable);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="dest"></param>
        /// <param name="source"></param>
        /// <returns></returns>
        [DllImport("dwmapi.dll", PreserveSig = false)]
        public static extern IntPtr DwmRegisterThumbnail(IntPtr dest, IntPtr source);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="hThumbnail"></param>
        [DllImport("dwmapi.dll", PreserveSig = false)]
        public static extern void DwmUnregisterThumbnail(IntPtr hThumbnail);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="hThumbnail"></param>
        /// <param name="props"></param>
        [DllImport("dwmapi.dll", PreserveSig = false)]
        public static extern void DwmUpdateThumbnailProperties(IntPtr hThumbnail, DWM_THUMBNAIL_PROPERTIES props);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="hThumbnail"></param>
        /// <param name="size"></param>
        [DllImport("dwmapi.dll", PreserveSig = false)]
        public static extern void DwmQueryThumbnailSourceSize(IntPtr hThumbnail, out Size size);
        /// <summary>
        /// 
        /// </summary>
        [StructLayout(LayoutKind.Sequential)]
        public class DWM_THUMBNAIL_PROPERTIES
        {
            /// <summary>
            /// 
            /// </summary>
            public uint dwFlags;
            /// <summary>
            /// 
            /// </summary>
            public RECT rcDestination;
            /// <summary>
            /// 
            /// </summary>
            public RECT rcSource;
            /// <summary>
            /// 
            /// </summary>
            public byte opacity;
            /// <summary>
            /// 
            /// </summary>
            [MarshalAs(UnmanagedType.Bool)]
            public bool fVisible;
            /// <summary>
            /// 
            /// </summary>
            [MarshalAs(UnmanagedType.Bool)]
            public bool fSourceClientAreaOnly;
            /// <summary>
            /// 
            /// </summary>
            public const uint DWM_TNP_RECTDESTINATION = 0x00000001;
            /// <summary>
            /// 
            /// </summary>
            public const uint DWM_TNP_RECTSOURCE = 0x00000002;
            /// <summary>
            /// 
            /// </summary>
            public const uint DWM_TNP_OPACITY = 0x00000004;
            /// <summary>
            /// 
            /// </summary>
            public const uint DWM_TNP_VISIBLE = 0x00000008;
            /// <summary>
            /// 
            /// </summary>
            public const uint DWM_TNP_SOURCECLIENTAREAONLY = 0x00000010;
        }
        /// <summary>
        /// 
        /// </summary>
        [StructLayout(LayoutKind.Sequential)]
        public class MARGINS
        {
            /// <summary>
            /// 
            /// </summary>
            public int cxLeftWidth, cxRightWidth, cyTopHeight, cyBottomHeight;
            /// <summary>
            /// 
            /// </summary>
            /// <param name="left"></param>
            /// <param name="top"></param>
            /// <param name="right"></param>
            /// <param name="bottom"></param>
            public MARGINS(int left, int top, int right, int bottom)
            {
                cxLeftWidth = left; cyTopHeight = top;
                cxRightWidth = right; cyBottomHeight = bottom;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        [StructLayout(LayoutKind.Sequential)]
        public class DWM_BLURBEHIND
        {
            /// <summary>
            /// 
            /// </summary>
            public uint dwFlags;
            /// <summary>
            /// 
            /// </summary>
            [MarshalAs(UnmanagedType.Bool)]
            public bool fEnable;
            /// <summary>
            /// 
            /// </summary>
            public IntPtr hRegionBlur;
            /// <summary>
            /// 
            /// </summary>
            [MarshalAs(UnmanagedType.Bool)]
            public bool fTransitionOnMaximized;
            /// <summary>
            /// 
            /// </summary>
            public const uint DWM_BB_ENABLE = 0x00000001;
            /// <summary>
            /// 
            /// </summary>
            public const uint DWM_BB_BLURREGION = 0x00000002;
            /// <summary>
            /// 
            /// </summary>
            public const uint DWM_BB_TRANSITIONONMAXIMIZED = 0x00000004;
        }
        /// <summary>
        /// 
        /// </summary>
        [StructLayout(LayoutKind.Sequential)]
        public struct RECT
        {
            /// <summary>
            /// 
            /// </summary>
            public int left, top, right, bottom;
            /// <summary>
            /// 
            /// </summary>
            /// <param name="left"></param>
            /// <param name="top"></param>
            /// <param name="right"></param>
            /// <param name="bottom"></param>
            public RECT(int left, int top, int right, int bottom)
            {
                this.left = left; this.top = top; this.right = right; this.bottom = bottom;
            }
        }
    
    }
}
