public void Initialize() { InitialiseExtensions(); var settings = settingsService.GetSettings <MarkPadSettings>(); var blogs = blogService.GetBlogs(); Blogs = new ObservableCollection <BlogSetting>(blogs); Languages = Enum.GetValues(typeof(SpellingLanguages)).OfType <SpellingLanguages>().ToArray(); FontSizes = Enum.GetValues(typeof(FontSizes)).OfType <FontSizes>().ToArray(); FontFamilies = Fonts.SystemFontFamilies.OrderBy(f => f.Source); SelectedLanguage = settings.Language; var fontFamily = settings.FontFamily; SelectedFontFamily = Fonts.SystemFontFamilies.FirstOrDefault(f => f.Source == fontFamily); SelectedFontSize = settings.FontSize; if (SelectedFontFamily == null) { SelectedFontFamily = FontHelpers.TryGetFontFamilyFromStack(Constants.DEFAULT_EDITOR_FONT_FAMILY); SelectedFontSize = Constants.DEFAULT_EDITOR_FONT_SIZE; } EnableFloatingToolBar = settings.FloatingToolBarEnabled; Plugins = plugins .Where(plugin => !plugin.IsHidden) .Select(plugin => pluginViewModelCreator(plugin)); }
private FontFamily GetFontFamily() { var configuredSource = settings.FontFamily; var fontFamily = FontHelpers.TryGetFontFamilyFromStack(configuredSource, "Segoe UI", "Arial"); if (fontFamily == null) { throw new Exception("Cannot find configured font family or fallback fonts"); } return(fontFamily); }
public void Initialize() { using (var key = Registry.CurrentUser.OpenSubKey("Software").OpenSubKey("Classes")) { Extensions = Constants.DefaultExtensions .Select(s => new ExtensionViewModel(s, key.GetSubKeyNames().Contains(s) && !string.IsNullOrEmpty(key.OpenSubKey(s).GetValue("").ToString()))) .ToArray(); } var settings = settingsService.GetSettings <MarkPadSettings>(); var blogs = settings.GetBlogs(); Blogs = new ObservableCollection <BlogSetting>(blogs); Languages = Enum.GetValues(typeof(SpellingLanguages)).OfType <SpellingLanguages>().ToArray(); FontSizes = Enum.GetValues(typeof(FontSizes)).OfType <FontSizes>().ToArray(); FontFamilies = Fonts.SystemFontFamilies.OrderBy(f => f.Source); var spellCheckPlugin = plugins.OfType <SpellCheckPlugin.SpellCheckPluginSettings>().FirstOrDefault(); SelectedLanguage = spellCheckPlugin != null ? spellCheckPlugin.Language : SpellingLanguages.UnitedStates; var fontFamily = settings.FontFamily; SelectedFontFamily = Fonts.SystemFontFamilies.FirstOrDefault(f => f.Source == fontFamily); SelectedFontSize = settings.FontSize; if (SelectedFontFamily == null) { SelectedFontFamily = FontHelpers.TryGetFontFamilyFromStack(Constants.DEFAULT_EDITOR_FONT_FAMILY); SelectedFontSize = Constants.DEFAULT_EDITOR_FONT_SIZE; } EnableFloatingToolBar = settings.FloatingToolBarEnabled; Plugins = plugins .Where(plugin => !plugin.IsHidden) .Select(plugin => pluginViewModelCreator(plugin)); }
public void ResetFont() { SelectedFontFamily = FontHelpers.TryGetFontFamilyFromStack(Constants.DEFAULT_EDITOR_FONT_FAMILY); SelectedFontSize = Constants.DEFAULT_EDITOR_FONT_SIZE; }