Ejemplo n.º 1
0
        /// <summary>Update the components theme.</summary>
        /// <param name="component">The component to update.</param>
        public void UpdateComponent(IDisposable component)
        {
            if (component is IThemeSupport)
            {
                foreach (Type registeredTypes in ControlManager.ThemeSupportedTypes())
                {
                    if (component.HasMethod(DefaultConstants.ComponentUpdateMethodName))
                    {
                        switch (component)
                        {
                        case Form form:
                        {
                            if (form.GetType().BaseType == registeredTypes)
                            {
                                if (registeredTypes != null)
                                {
                                    Theme.InvokeThemeUpdate(form, registeredTypes, _theme);
                                }
                            }
                            else
                            {
                                // Form not registered.
                            }

                            break;
                        }

                        case Control control:
                        {
                            if (control.GetType() == registeredTypes)
                            {
                                Theme.InvokeThemeUpdate(control, registeredTypes, _theme);
                            }
                            else
                            {
                                // Control not registered.
                            }

                            break;
                        }
                        }
                    }
                    else
                    {
                        // The component does not contain method.
                    }
                }
            }
            else
            {
                // The component not supported.
            }
        }