private async void Load()
        {
            var items = await App.ViewModel.DiskRepository.GetFontsAsync();

            // FontItems.Clear();
            foreach (var item in items)
            {
                FontItems.Add(item);
            }
        }
Exemple #2
0
        /// <summary>
        /// load font list
        /// </summary>
        public void LoadFontList()
        {
            FontItems.Clear();

            var currentLanguages = Cultures.ToDictionary((e) => e.CultureInfo.Name);

            foreach (FontFamily fontFamily in Fonts.SystemFontFamilies)
            {
                foreach (var culture in Cultures)
                {
                    XmlLanguage userLanguage = XmlLanguage.GetLanguage(culture.CultureInfo.Name);

                    LanguageSpecificStringDictionary dictionary = fontFamily.FamilyNames;

                    if (dictionary.ContainsKey(userLanguage) == false)
                    {
                        continue;
                    }

                    var fontName = dictionary[userLanguage];

                    if (_searchWord.Length > 0)
                    {
                        if (!fontName.Contains(_searchWord))
                        {
                            continue;
                        }
                    }

                    var fontModel = new MogeraFontModel()
                    {
                        FontFamily = fontFamily,
                        FontName   = fontName,
                    };

                    FontItems.Add(new FontItemViewModel(fontModel));
                }
            }
        }