public static void ApplyThemeResourcesFromTheme([NotNull] ResourceDictionary resources, [NotNull] Theme newTheme) { if (resources.IsNull()) { throw new ArgumentNullException(nameof(resources)); } if (newTheme.IsNull()) { throw new ArgumentNullException(nameof(newTheme)); } ApplyResourceDictionary(newTheme.Resources, resources); }
public static Theme ChangeTheme([NotNull] ResourceDictionary resourceDictionary, [NotNull] Theme newTheme) { if (resourceDictionary.IsNull()) { throw new ArgumentNullException(nameof(resourceDictionary)); } if (newTheme.IsNull()) { throw new ArgumentNullException(nameof(newTheme)); } var oldTheme = DetectTheme(resourceDictionary); return(ChangeTheme(resourceDictionary, oldTheme, newTheme)); }
public static Theme ChangeTheme([NotNull] Window window, [NotNull] Theme newTheme) { if (window.IsNull()) { throw new ArgumentNullException(nameof(window)); } if (newTheme.IsNull()) { throw new ArgumentNullException(nameof(newTheme)); } var oldTheme = DetectTheme(window); return(ChangeTheme(window.Resources, oldTheme, newTheme)); }
public static Theme ChangeTheme([NotNull] Application app, [NotNull] Theme newTheme) { if (app.IsNull()) { throw new ArgumentNullException(nameof(app)); } if (newTheme.IsNull()) { throw new ArgumentNullException(nameof(newTheme)); } var oldTheme = DetectTheme(app); return(ChangeTheme(app.Resources, oldTheme, newTheme)); }
/// <summary> /// Gets the inverse <see cref="Theme" /> of the given <see cref="Theme"/>. /// This method relies on the "Dark" or "Light" affix to be present. /// </summary> /// <param name="theme">The app theme.</param> /// <returns>The inverse <see cref="Theme"/> or <c>null</c> if it couldn't be found.</returns> /// <remarks> /// Returns BaseLight, if BaseDark is given or vice versa. /// Custom Themes must end with "Dark" or "Light" for this to work, for example "CustomDark" and "CustomLight". /// </remarks> public static Theme GetInverseTheme([NotNull] Theme theme) { if (theme.IsNull()) { throw new ArgumentNullException(nameof(theme)); } if (theme.Name.StartsWith("dark.", StringComparison.OrdinalIgnoreCase)) { return(GetTheme("Light." + theme.Name.Substring("dark.".Length))); } if (theme.Name.StartsWith("light.", StringComparison.OrdinalIgnoreCase)) { return(GetTheme("Dark." + theme.Name.Substring("light.".Length))); } return(null); }
/// <summary> /// Gets the inverse <see cref="Theme" /> of the given <see cref="Theme"/>. /// This method relies on the "Dark" or "Light" affix to be present. /// </summary> /// <param name="theme">The app theme.</param> /// <returns>The inverse <see cref="Theme"/> or <c>null</c> if it couldn't be found.</returns> /// <remarks> /// Returns BaseLight, if BaseDark is given or vice versa. /// Custom Themes must end with "Dark" or "Light" for this to work, for example "CustomDark" and "CustomLight". /// </remarks> public static Theme GetInverseTheme([NotNull] Theme theme) { if (theme.IsNull()) { throw new ArgumentNullException(nameof(theme)); } if (theme.Type == ThemeType.Dark) { return(GetTheme("Light." + theme.Name.Substring("dark.".Length))); } if (theme.Type == ThemeType.Light) { return(GetTheme("Dark." + theme.Name.Substring("light.".Length))); } return(null); }