コード例 #1
0
        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));
        }
コード例 #2
0
        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
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            var dict = new ResourceDictionary {
                Source = new Uri("pack://application:,,,/MahApps.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();

            IconsListBox.ItemsSource = foundIcons;
        }
コード例 #4
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            var dict = new ResourceDictionary {
                Source = new Uri("Resources/Icons.xaml", UriKind.RelativeOrAbsolute)
            };
            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.AllIcons = foundIcons;
        }
コード例 #5
0
        private void IconExampleView_OnLoaded(object sender, RoutedEventArgs e)
        {
            var dict = new ResourceDictionary {
                Source = new Uri("/Wheels;component/Themes/Icons8.xaml", UriKind.RelativeOrAbsolute)
            };
            var icons = dict
                        .OfType <DictionaryEntry>()
                        .Where(de => de.Value is Geometry)
                        .Select(de => new IconModel((string)de.Key, (Geometry)de.Value))
                        .OrderBy(mi => mi.IconKey)
                        .ToList();

            IconsControl.ItemsSource = icons;
        }
コード例 #6
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            var dict = new ResourceDictionary
            {
                Source =
                    new Uri("pack://application:,,,/MahApps.Metro.Resources;component/Icons.xaml",
                            UriKind.RelativeOrAbsolute)
            };
            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);

            this.AllIcons = new ObservableCollection <MetroIcon>(foundIcons);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
            static Hue GetHue(ResourceDictionary dictionary, DictionaryEntry entry)
            {
                if (!(entry.Value is Color colour))
                {
                    throw new InvalidOperationException($"Entry {entry.Key} was not of type {nameof(Color)}");
                }
                string foregroundKey = entry.Key?.ToString() + "Foreground";

                if (!(dictionary.OfType <DictionaryEntry>()
                      .Single(de => string.Equals(de.Key.ToString(), foregroundKey, StringComparison.Ordinal))
                      .Value is Color foregroundColour))
                {
                    throw new InvalidOperationException($"Entry {foregroundKey} was not of type {nameof(Color)}");
                }

                return(new Hue(entry.Key?.ToString() ?? "", colour, foregroundColour));
            }
コード例 #9
0
        public IEnumerable <CustomField> GetFieldTypes()
        {
            List <CustomField> customFields         = new List <CustomField>();
            ResourceDictionary resourceDictionaries = new ResourceDictionary()
            {
                Source = new Uri("/RSG.DMF.Fields;component/FieldDataTemplates.xaml", UriKind.Relative)
            };
            IEnumerable <DictionaryEntry> dictionaryEntries =
                from x in resourceDictionaries.OfType <DictionaryEntry>()
                where (!(x.Key is string) ? false : x.Value is DataTemplate)
                select x;

            foreach (DictionaryEntry dictionaryEntry in dictionaryEntries)
            {
                customFields.Add(new CustomField((string)dictionaryEntry.Key, string.Concat((string)dictionaryEntry.Key, "Template"), (DataTemplate)dictionaryEntry.Value));
            }
            return(customFields.AsEnumerable <CustomField>());
        }