using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace Launcheroid
{
    class Glass
    {
        #region API
        private struct MARGINS
        {
            public int m_Left;
            public int m_Right;
            public int m_Top;
            public int m_Buttom;

            public static MARGINS getFull()
            {
                MARGINS result;
                result.m_Left = -1;
                result.m_Right = -1;
                result.m_Top = -1;
                result.m_Buttom = -1;
                return result;
            }
        };
        [DllImport("dwmapi.dll")]
        private extern static int DwmExtendFrameIntoClientArea(IntPtr hwnd, ref MARGINS margin);
        [DllImport("dwmapi.dll")]
        private extern static int DwmIsCompositionEnabled(ref int en);
        #endregion

        private static bool aero;
        static Glass()
        {
            aero = System.Environment.OSVersion.Version.Major >= 6;
        }

        public static bool Composite
        {
            get { if (!aero) return false; int en = 0; DwmIsCompositionEnabled(ref en); return en > 0; }
        }

        public static void GlassForm(Form f)
        {
            if (!Composite)
                return;
            MARGINS m = MARGINS.getFull();
            DwmExtendFrameIntoClientArea(f.Handle, ref m);
        }
    }
}
