private void OnLoaded(object sender, RoutedEventArgs e) { var dict = new ResourceDictionary {Source = new Uri("pack://application:,,,/MVVMApps.Metro.Resources;component/Icons.xaml")}; var foundIcons = dict .OfType<DictionaryEntry>() .Where(de => de.Value is Canvas) .Select(de => new MetroIcon((string)de.Key, (Canvas)de.Value)) .OrderBy(mi => mi.Name) .ToList(); this.IconsListBox.ItemsSource = foundIcons; }
private static Swatch CreateSwatch(string name, ResourceDictionary primaryDictionary, ResourceDictionary accentDictionary) { var primaryHues = new List<Hue>(); var accentHues = new List<Hue>(); if (primaryDictionary != null) { foreach (var entry in primaryDictionary.OfType<DictionaryEntry>() .OrderBy(de => de.Key) .Where(de => !de.Key.ToString().EndsWith("Foreground", StringComparison.Ordinal))) { var colour = (Color)entry.Value; var foregroundColour = (Color) primaryDictionary.OfType<DictionaryEntry>() .Single(de => de.Key.ToString().Equals(entry.Key.ToString() + "Foreground")) .Value; primaryHues.Add(new Hue(entry.Key.ToString(), colour, foregroundColour)); } } if (accentDictionary != null) { foreach (var entry in accentDictionary.OfType<DictionaryEntry>() .OrderBy(de => de.Key) .Where(de => !de.Key.ToString().EndsWith("Foreground", StringComparison.Ordinal))) { var colour = (Color)entry.Value; var foregroundColour = (Color) accentDictionary.OfType<DictionaryEntry>() .Single(de => de.Key.ToString().Equals(entry.Key.ToString() + "Foreground")) .Value; accentHues.Add(new Hue(entry.Key.ToString(), colour, foregroundColour)); } } return new Swatch(name, primaryHues, accentHues); }
private static Swatch CreateSwatch(string name, ResourceDictionary resourceDictionary) { var primaryHues = new List<Hue>(); var accentHues = new List<Hue>(); foreach (var entry in resourceDictionary.OfType<DictionaryEntry>() .OrderBy(de => de.Key) .Where(de => !de.Key.ToString().EndsWith("Foreground"))) { var targetList = (entry.Key.ToString().StartsWith("Primary") ? primaryHues : accentHues); var colour = (Color) entry.Value; var foregroundColour = (Color) resourceDictionary.OfType<DictionaryEntry>() .Single(de => de.Key.ToString().Equals(entry.Key.ToString() + "Foreground")) .Value; targetList.Add(new Hue(entry.Key.ToString(), colour, foregroundColour)); } return new Swatch(name, primaryHues, accentHues); }
static MetroConverter() { dict = new ResourceDictionary {}; try { dict.Source = new Uri("Hawk.Core;component/Themes/Icons.xaml", UriKind.RelativeOrAbsolute); } catch (Exception ex) { } foundIcons = dict .OfType<DictionaryEntry>() .Where(de => de.Value is Canvas).ToDictionary(d=> d.Key,d=>d.Value); }
private static ResourceDictionary Freeze(ResourceDictionary dict) { foreach (var i in dict.OfType<Freezable>()) i.Freeze(); return dict; }