Beispiel #1
0
        private static void SetControlTheme(Control control, ColorTheme theme)
        {
            IThemedControl ctrl = control as IThemedControl;

            if (ctrl != null)
            {
                ctrl.SetTheme(theme);
            }

            foreach (Control child in control.Controls)
            {
                SetControlTheme(child, theme);
            }
        }
Beispiel #2
0
        public void ThemeRecursive(System.Windows.Forms.Control control, bool forDialog)
        {
            bool recurse   = true;
            bool autoTheme = true;
            ISupportsVSTheming themeControl = control as ISupportsVSTheming;

            if (themeControl != null)
            {
                CancelEventArgs ca = new CancelEventArgs(false);
                if (themeControl != null)
                {
                    themeControl.OnThemeChange(this, ca);
                }

                if (ca.Cancel)
                {
                    recurse = autoTheme = false; // No recurse!
                }
            }

            IThemedControl themed = control as IThemedControl;

            if (themed != null)
            {
                ApplyThemeEventArgs atea = new ApplyThemeEventArgs(this, forDialog);

                themed.OnApplyTheme(atea);

                recurse   = !atea.NoRecurse;
                autoTheme = !atea.DontTheme;
                forDialog = atea.ForDialog;
            }

            if (autoTheme && control.IsHandleCreated)
            {
                VSThemeWindow(control, forDialog);
            }

            if (recurse)
            {
                foreach (Control c in control.Controls)
                {
                    ThemeRecursive(c, forDialog);
                }
            }
        }