/// <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 (ObjectManagement.HasMethod(component, SettingConstants.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) { if (_formCollection[0] is VisualForm visualForm) { control.BackColor = visualForm.Background; } Theme.InvokeThemeUpdate(control, registeredTypes, _theme); } else { // Control not registered. } break; } } } else { // The component does not contain method. } } } else { // The component not supported. } }
/// <summary>Determines whether the object has the method.</summary> /// <param name="source">The object source.</param> /// <param name="methodName">The name of the method.</param> /// <returns>The <see cref="bool" />.</returns> public static bool HasMethod(this object source, string methodName) { return(ObjectManagement.HasMethod(source, methodName)); }