public FontAppSettingsPage(FontAndColorOptions[] options, FontAppSettingsPageOptions fontAppSettingsPageOptions) { if (options == null) { throw new ArgumentNullException(nameof(options)); } this.fontAppSettingsPageOptions = fontAppSettingsPageOptions; allFonts = new FontCollection(); monospacedFonts = new FontCollection(); FontAndColorOptions = new ObservableCollection <FontAndColorOptionsVM>(options.OrderBy(a => a.DisplayName, StringComparer.CurrentCultureIgnoreCase).Select(a => new FontAndColorOptionsVM(a, GetFontCollection(a.FontOption.FontType)))); SelectedFontAndColorOptions = (uint)fontAppSettingsPageOptions.SelectedIndex < (uint)FontAndColorOptions.Count ? FontAndColorOptions[fontAppSettingsPageOptions.SelectedIndex] : GetBestFontAndColorOptions(); Task.Factory.StartNew(() => Fonts.SystemFontFamilies.Where(a => !FontUtilities.IsSymbol(a)).OrderBy(a => a.Source, StringComparer.CurrentCultureIgnoreCase).Select(a => new FontFamilyVM(a)).ToArray() ) .ContinueWith(t => { var ex = t.Exception; if (!t.IsCanceled && !t.IsFaulted) { allFonts.FontFamilies = t.Result; monospacedFonts.FontFamilies = t.Result.Where(a => FontUtilities.IsMonospacedFont(a.FontFamily)).ToArray(); } }, CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); }
FontAppSettingsPageProvider([ImportMany] IEnumerable <Lazy <FontAndColorOptionsProvider> > fontAndColorOptionsProviders) { this.fontAndColorOptionsProviders = fontAndColorOptionsProviders.ToArray(); fontAppSettingsPageOptions = new FontAppSettingsPageOptions(); }
FontAppSettingsPageProvider([ImportMany] IEnumerable<Lazy<FontAndColorOptionsProvider>> fontAndColorOptionsProviders) { this.fontAndColorOptionsProviders = fontAndColorOptionsProviders.ToArray(); fontAppSettingsPageOptions = new FontAppSettingsPageOptions(); }
public FontAppSettingsPage(FontAndColorOptions[] options, FontAppSettingsPageOptions fontAppSettingsPageOptions) { if (options == null) throw new ArgumentNullException(nameof(options)); this.fontAppSettingsPageOptions = fontAppSettingsPageOptions; allFonts = new FontCollection(); monospacedFonts = new FontCollection(); FontAndColorOptions = new ObservableCollection<FontAndColorOptionsVM>(options.OrderBy(a => a.DisplayName, StringComparer.CurrentCultureIgnoreCase).Select(a => new FontAndColorOptionsVM(a, GetFontCollection(a.FontOption.FontType)))); SelectedFontAndColorOptions = (uint)fontAppSettingsPageOptions.SelectedIndex < (uint)FontAndColorOptions.Count ? FontAndColorOptions[fontAppSettingsPageOptions.SelectedIndex] : GetBestFontAndColorOptions(); Task.Factory.StartNew(() => Fonts.SystemFontFamilies.Where(a => !FontUtilities.IsSymbol(a)).OrderBy(a => a.Source, StringComparer.CurrentCultureIgnoreCase).Select(a => new FontFamilyVM(a)).ToArray() ) .ContinueWith(t => { var ex = t.Exception; if (!t.IsCanceled && !t.IsFaulted) { allFonts.FontFamilies = t.Result; monospacedFonts.FontFamilies = t.Result.Where(a => FontUtilities.IsMonospacedFont(a.FontFamily)).ToArray(); } }, CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); }