/// <summary> /// Gets the <see cref="Accent"/> with the given resource dictionary. /// </summary> /// <param name="resources"><see cref="ResourceDictionary"/> from which the accent should be retrieved.</param> /// <returns>The <see cref="Accent"/> or <c>null</c>, if the accent wasn't found.</returns> public static Accent GetAccent(ResourceDictionary resources) { if (resources == null) { throw new ArgumentNullException(nameof(resources)); } var builtInAccent = Accents.FirstOrDefault(x => AreResourceDictionarySourcesEqual(x.Resources.Source, resources.Source)); if (builtInAccent != null) { return(builtInAccent); } // support dynamically created runtime resource dictionaries if (resources.Source == null) { if (IsAccentDictionary(resources)) { return(new Accent { Name = "Runtime accent", Resources = resources, }); } } return(null); }
/// <summary> /// Gets an accent color with the specified name, if it exists. /// </summary> /// <param name="name">The name.</param> /// <returns></returns> public static Maybe <IAccentColor> TryGetAccent(string name) { Requires.NotNullOrEmpty(name, nameof(name)); var ret = Accents.FirstOrDefault(v => v.Name.Equals(name, StringComparison.OrdinalIgnoreCase)); return(ret == null ? new Maybe <IAccentColor>() : new Maybe <IAccentColor>(ret)); }
/// <summary> /// Gets the <see cref="Accent"/> with the given resource dictionary. /// </summary> /// <param name="resources"></param> /// <returns>The <see cref="Accent"/> or <c>null</c>, if the accent wasn't found.</returns> public static Accent GetAccent(ResourceDictionary resources) { if (resources == null) { throw new ArgumentNullException("resources"); } return(Accents.FirstOrDefault(x => x.Resources.Source == resources.Source)); }
/// <summary> /// Gets the <see cref="Accent"/> with the given name. /// </summary> /// <param name="accentName"></param> /// <returns>The <see cref="Accent"/> or <c>null</c>, if the app theme wasn't found</returns> public static Accent GetAccent(string accentName) { if (accentName == null) { throw new ArgumentNullException("accentName"); } return(Accents.FirstOrDefault(x => x.Name == accentName)); }
/// <summary> /// Gets the <see cref="Accent"/> with the given name. /// </summary> /// <returns>The <see cref="Accent"/> or <c>null</c>, if the app theme wasn't found</returns> public static Accent GetAccent(string accentName) { if (accentName == null) { throw new ArgumentNullException(nameof(accentName)); } return(Accents.FirstOrDefault(x => x.Name.Equals(accentName, StringComparison.OrdinalIgnoreCase))); }
private void GetSetting() { Log.Debug(String.Format("Get Setting")); RegistryKey subKey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\MP\UI DEV\PrevSesParameters"); SelectedAccent = Accents.FirstOrDefault(e => e.Tag.ToString() == subKey.GetValue("Accent", "Lime").ToString()); SelectedTheme = Themes.FirstOrDefault(e => e == subKey.GetValue("AppTheme", "NIGHT").ToString()); SelectedLanguage = Languages.FirstOrDefault(l => l.Culture == subKey.GetValue("Language", "en").ToString()); subKey.Close(); }