Example #1
0
        public virtual MetroVisualManager VisualManager(bool bSet = false, MetroVisualManager vm = null)
        {
            if (bSet)
            {
                _visualManager = vm;
                return(null);
            }
            else
            {
                if (_visualManager == null)
                {
                    IMetroControl parentControl = Owner as IMetroControl;

                    if (parentControl != null)
                    {
                        return(parentControl.VisualManager());
                    }

                    IMetroWindow parentWindow = Owner as IMetroWindow;

                    if (parentWindow != null)
                    {
                        return(parentWindow.VisualManager());
                    }

                    throw new ArgumentException("Impissibile recuperare il MetroVisualManager");
                }
                else
                {
                    return(_visualManager);
                }
            }
        }
Example #2
0
        public static void ApplyMetroStyle(IMetroControl control)
        {
            if (control == null)
                return;

            control.StyleManager = MANAGER;
            Control legacyControl = control as Control;
            if (legacyControl != null)
                legacyControl.Disposed += new EventHandler(legacyControl_Disposed);
        }
        public static void ApplyMetroStyle(IMetroControl control)
        {
            if (control == null)
            {
                return;
            }

            control.StyleManager = MANAGER;
            Control legacyControl = control as Control;

            if (legacyControl != null)
            {
                legacyControl.Disposed += new EventHandler(legacyControl_Disposed);
            }
        }
        private static void legacyControl_Disposed(object sender, EventArgs e)
        {
            IMetroControl control = sender as IMetroControl;

            if (control != null)
            {
                control.StyleManager = null;
            }

            Control legacyControl = sender as Control;

            if (legacyControl != null)
            {
                legacyControl.Disposed -= new EventHandler(legacyControl_Disposed);
            }
        }
Example #5
0
        private void UpdateControl(Control ctrl)
        {
            if (ctrl == null)
            {
                return;
            }

            IMetroControl metroControl = ctrl as IMetroControl;

            if (metroControl != null)
            {
                ApplyTheme(metroControl);
            }

            IMetroComponent metroComponent = ctrl as IMetroComponent;

            if (metroComponent != null)
            {
                ApplyTheme(metroComponent);
            }

            TabControl tabControl = ctrl as TabControl;

            if (tabControl != null)
            {
                foreach (TabPage tp in ((TabControl)ctrl).TabPages)
                {
                    UpdateControl(tp);
                }
            }

            if (ctrl.Controls != null)
            {
                foreach (Control child in ctrl.Controls)
                {
                    UpdateControl(child);
                }
            }

            if (ctrl.ContextMenuStrip != null)
            {
                UpdateControl(ctrl.ContextMenuStrip);
            }

            ctrl.Refresh();
        }
        private void UpdateControls(Control.ControlCollection controls)
        {
            if (controls == null)
            {
                throw new ArgumentNullException(nameof(controls));
            }

            foreach (Control ctrl in controls)
            {
                IMetroControl control = ctrl as IMetroControl;
                if (control != null && CustomTheme != null)
                {
                    control.Style        = Style;
                    control.ThemeAuthor  = ThemeAuthor;
                    control.ThemeName    = ThemeName;
                    control.StyleManager = this;
                }
                if (control is TabControl tabControl)
                {
                    foreach (TabPage c in tabControl.TabPages)
                    {
                        if (c is IMetroControl)
                        {
                            control.Style        = Style;
                            control.StyleManager = this;
                            control.ThemeAuthor  = ThemeAuthor;
                            control.ThemeName    = ThemeName;
                        }
                        UpdateControls(c.Controls);
                    }
                }

                foreach (Control child in ctrl.Controls)
                {
                    if (!(child is IMetroControl))
                    {
                        continue;
                    }
                    ((IMetroControl)child).Style        = Style;
                    ((IMetroControl)child).StyleManager = this;
                    ((IMetroControl)child).ThemeAuthor  = ThemeAuthor;
                    ((IMetroControl)child).ThemeName    = ThemeName;
                }
            }
        }
Example #7
0
 public void WireStyleManager(Control cont)
 {
     foreach (Control ctl in cont.Controls)
     {
         try
         {
             IMetroControl metroctl = (IMetroControl)ctl;
             metroctl.StyleManager = Program.MainStyleManager;
             if (ctl.HasChildren)
             {
                 WireStyleManager((Control)metroctl);
             }
         }
         catch
         {
             if (ctl.HasChildren)
             {
                 WireStyleManager(ctl);
             }
         }
     }
 }
Example #8
0
        private void UpdateControl(Control ctrl)
        {
            if (ctrl == null)
            {
                return;
            }
            IMetroControl metroControl = ctrl as IMetroControl;

            if (metroControl != null)
            {
                this.ApplyTheme(metroControl);
            }
            IMetroComponent metroComponent = ctrl as IMetroComponent;

            if (metroComponent != null)
            {
                this.ApplyTheme(metroComponent);
            }
            if (ctrl is TabControl)
            {
                foreach (TabPage tabPage in ((TabControl)ctrl).TabPages)
                {
                    this.UpdateControl(tabPage);
                }
            }
            if (ctrl.Controls != null)
            {
                foreach (Control control in ctrl.Controls)
                {
                    this.UpdateControl(control);
                }
            }
            if (ctrl.ContextMenuStrip != null)
            {
                this.UpdateControl(ctrl.ContextMenuStrip);
            }
            ctrl.Refresh();
        }
Example #9
0
 private void ApplyTheme(IMetroControl control)
 {
     control.StyleManager = this;
 }
 private void ApplyTheme(IMetroControl control)
 {
     control.StyleManager = this;
 }
Example #11
0
 private void ApplyTheme(IMetroControl control)
 {
     control.VisualManager = this;
 }