Пример #1
0
        private void form_Resize(object sender, EventArgs e)
        {
            Form form = sender as Form;

            if ((DesktopWindowManager.IsCompositionEnabled() && GetGlassEnabled(form)) || form.IsDesignMode())
            {
                InvalidateNonGlassClientArea(form);
            }
        }
Пример #2
0
        private void GlassifyForm(Form form, Graphics g = null)
        {
            if (!(DesktopWindowManager.IsCompositionEnabled() && GetGlassEnabled(form)) && !form.IsDesignMode())
            {
                return;
            }

            if (g == null)
            {
                g = form.CreateGraphics();
            }

            GlassFormProperties prop;

            if (!formProps.TryGetValue(form, out prop))
            {
                return;
            }

            // Paint the glass effect.
            if (prop.GlassMargins == new Padding(-1))
            {
                g.FillRectangle(Brushes.Black, form.ClientRectangle);
            }
            else
            {
                using (Region r = new Region(form.ClientRectangle))
                {
                    r.Exclude(GetNonGlassArea(form, prop));
                    g.FillRegion(Brushes.Black, r);
                }
            }

            if (!form.IsDesignMode())
            {
                form.ExtendFrameIntoClientArea(prop.GlassMargins);
            }
        }