当前位置: 首页>>代码示例>>C#>>正文


C# ResourceDictionary.OfType方法代码示例

本文整理汇总了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;
 }
开发者ID:jinlook,项目名称:MahApps.Metro,代码行数:11,代码来源:IconsWindow.xaml.cs

示例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);
        }
开发者ID:Chandu-cuddle,项目名称:MaterialDesignInXamlToolkit,代码行数:39,代码来源:SwatchesProvider.cs

示例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);
        }
开发者ID:ruisebastiao,项目名称:MaterialDesignInXamlToolkit,代码行数:22,代码来源:SwatchesProvider.cs

示例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);
        }
开发者ID:GamesDesignArt,项目名称:Hawk,代码行数:16,代码来源:MetroConverter.cs

示例5: Freeze

 private static ResourceDictionary Freeze(ResourceDictionary dict)
 {
     foreach (var i in dict.OfType<Freezable>())
         i.Freeze();
     return dict;
 }
开发者ID:daszat,项目名称:zetbox,代码行数:6,代码来源:App.cs


注:本文中的System.Windows.ResourceDictionary.OfType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。