private void ResetStyles(Control control)
        {
            // Skip container controls with a dedicated style manager component
            IMetroContainerControl container = control as IMetroContainerControl;

            if (container != null && container.StyleManager != null)
            {
                return;
            }

            IMetroStyledComponent styledComponent = control as IMetroStyledComponent;

            if (styledComponent != null)
            {
                var propc     = TypeDescriptor.GetProperties(control);
                var propTheme = propc.Find(MetroStyleManager.THEME_PROPERTY_NAME, false);
                if (propTheme != null && propTheme.CanResetValue(control))
                {
                    propTheme.ResetValue(control);
                }
                var propStyle = propc.Find(MetroStyleManager.STYLE_PROPERTY_NAME, true);
                if (propStyle != null && propStyle.CanResetValue(control))
                {
                    propStyle.ResetValue(control);
                }
            }

            if (control.ContextMenuStrip != null)
            {
                ResetStyles(control.ContextMenuStrip);
            }

            // descend into tab pages
            TabControl tabControl = control as TabControl;

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

            // descend into child controls
            if (control.Controls != null)
            {
                foreach (Control child in control.Controls)
                {
                    ResetStyles(child);
                }
            }
        }
Beispiel #2
0
        private void UpdateControl(Control control)
        {
            if (control == null)
            {
                return;
            }

            // If a container control is exposing a Style Manager, we link to it
            // but do not access the container's children.
            IMetroContainerControl container = control as IMetroContainerControl;

            if (container != null && container.StyleManager != null && !ReferenceEquals(this, container.StyleManager))
            {
                ((IMetroStyledComponent)container.StyleManager).InternalStyleManager = this;
                return;
            }

            // Link to metro controls
            IMetroStyledComponent styledComponent = control as IMetroStyledComponent;

            if (styledComponent != null)
            {
                styledComponent.InternalStyleManager = this;
            }

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

            // descend into tab pages
            TabControl tabControl = control as TabControl;

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

            // descend into child controls
            if (control.Controls != null)
            {
                foreach (Control child in control.Controls)
                {
                    UpdateControl(child);
                }
            }
        }
Beispiel #3
0
        // Token: 0x0600009F RID: 159 RVA: 0x00003E2C File Offset: 0x0000202C
        private void UpdateControl(Control control)
        {
            if (control == null)
            {
                return;
            }
            IMetroContainerControl metroContainerControl = control as IMetroContainerControl;

            if (metroContainerControl != null && metroContainerControl.StyleManager != null && !object.ReferenceEquals(this, metroContainerControl.StyleManager))
            {
                ((IMetroStyledComponent)metroContainerControl.StyleManager).InternalStyleManager = this;
                return;
            }
            IMetroStyledComponent metroStyledComponent = control as IMetroStyledComponent;

            if (metroStyledComponent != null)
            {
                metroStyledComponent.InternalStyleManager = this;
            }
            if (control.ContextMenuStrip != null)
            {
                this.UpdateControl(control.ContextMenuStrip);
            }
            TabControl tabControl = control as TabControl;

            if (tabControl != null)
            {
                foreach (object obj in tabControl.TabPages)
                {
                    TabPage control2 = (TabPage)obj;
                    this.UpdateControl(control2);
                }
            }
            if (control.Controls != null)
            {
                foreach (object obj2 in control.Controls)
                {
                    Control control3 = (Control)obj2;
                    this.UpdateControl(control3);
                }
            }
        }
Beispiel #4
0
 // Token: 0x0600009E RID: 158 RVA: 0x00003D90 File Offset: 0x00001F90
 public void Update()
 {
     if (this._owner != null)
     {
         this.UpdateControl((Control)this._owner);
     }
     if (this._parentContainer == null || this._parentContainer.Components == null)
     {
         return;
     }
     foreach (object obj in this._parentContainer.Components)
     {
         if (!object.ReferenceEquals(obj, this))
         {
             IMetroStyledComponent metroStyledComponent = obj as IMetroStyledComponent;
             if (metroStyledComponent != null)
             {
                 metroStyledComponent.InternalStyleManager = this;
             }
         }
     }
 }