本文整理汇总了C#中System.Windows.ResourceDictionary.OfType方法的典型用法代码示例。如果您正苦于以下问题:C# ResourceDictionary.OfType方法的具体用法?C# ResourceDictionary.OfType怎么用?C# ResourceDictionary.OfType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.ResourceDictionary
的用法示例。
在下文中一共展示了ResourceDictionary.OfType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnLoaded
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;
}
示例2: CreateSwatch
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);
}
示例3: CreateSwatch
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);
}
示例4: MetroConverter
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);
}
示例5: Freeze
private static ResourceDictionary Freeze(ResourceDictionary dict)
{
foreach (var i in dict.OfType<Freezable>())
i.Freeze();
return dict;
}