Пример #1
0
        public void SetLanguage(SpellingLanguages language)
        {
            speller = new Hunspell();

            var languageKey = LangLookup[language];

            var assembly = Assembly.GetExecutingAssembly();

            var dictionaryFileStart = string.Format("{0}.Document.SpellCheck.Dictionaries.{1}", assembly.GetName().Name, languageKey);
            var dictionaryFiles     = assembly
                                      .GetManifestResourceNames()
                                      .Where(name => name.StartsWith(dictionaryFileStart))
                                      .ToArray();

            var affixes      = dictionaryFiles.Where(name => name.EndsWith(".aff")).OrderBy(s => s);
            var dictionaries = dictionaryFiles.Where(name => name.EndsWith(".dic")).OrderBy(s => s);

            var dictionaryPairs = affixes.Zip(dictionaries, (aff, dic) => new { aff, dic });

            foreach (var pair in dictionaryPairs)
            {
                using (var affStream = assembly.GetManifestResourceStream(pair.aff))
                    using (var dicStream = assembly.GetManifestResourceStream(pair.dic))
                    {
                        if (affStream != null && dicStream != null)
                        {
                            var affBytes = new BinaryReader(affStream).ReadBytes((int)affStream.Length);
                            var dicBytes = new BinaryReader(dicStream).ReadBytes((int)dicStream.Length);

                            speller.Load(affBytes, dicBytes);
                        }
                    }
            }
        }
Пример #2
0
        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);

            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;
            EnableSpellCheck = settings.SpellCheckEnabled;
        }
Пример #3
-1
        public void SetLanguage(SpellingLanguages language)
        {
            speller = new Hunspell();

            var languageKey = LangLookup[language];

            var assembly = Assembly.GetExecutingAssembly();

            var dictionaryFileStart = string.Format("{0}.Document.SpellCheck.Dictionaries.{1}", assembly.GetName().Name, languageKey);
            var dictionaryFiles = assembly
                .GetManifestResourceNames()
                .Where(name => name.StartsWith(dictionaryFileStart))
                .ToArray();

            var affixes = dictionaryFiles.Where(name => name.EndsWith(".aff")).OrderBy(s => s);
            var dictionaries = dictionaryFiles.Where(name => name.EndsWith(".dic")).OrderBy(s => s);

            var dictionaryPairs = affixes.Zip(dictionaries, (aff, dic) => new { aff, dic });

            foreach (var pair in dictionaryPairs)
            {
                using (var affStream = assembly.GetManifestResourceStream(pair.aff))
                using (var dicStream = assembly.GetManifestResourceStream(pair.dic))
                {
                    if (affStream != null && dicStream != null)
                    {
                        var affBytes = new BinaryReader(affStream).ReadBytes((int)affStream.Length);
                        var dicBytes = new BinaryReader(dicStream).ReadBytes((int)dicStream.Length);

                        speller.Load(affBytes, dicBytes);
                    }
                }
            }
        }