Example #1
0
        /// <summary>
        /// Adds the specified word to the internal dictionary.
        /// </summary>
        /// <param name="word">The word to add.</param>
        /// <returns>
        /// <b>True</b> if the word was successfully added; otherwise, <b>false</b>.
        /// </returns>
        public bool Add(string word)
        {
            // if spell check engine is not enabled
            if (!IsEnabled)
            {
                return(false);
            }

            if (_hunspell.Add(word))
            {
                _customDictionary.Add(word, false);
                return(true);
            }

            return(false);
        }
Example #2
0
        public void LoadSettings(Main View)
        {
            try
            {
                var settingsPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\BleckiTreeWriter\\settings.txt";
                if (System.IO.File.Exists(settingsPath))
                {
                    var text           = System.IO.File.ReadAllText(settingsPath);
                    var settingsObject = JsonConvert.DeserializeObject <SerializableSettings>(text);

                    if (!String.IsNullOrEmpty(settingsObject.Dictionary))
                    {
                        DictionaryBase = settingsObject.Dictionary;
                    }

                    SpellChecker = new NHunspell.Hunspell(DictionaryBase + ".aff", DictionaryBase + ".dic");

                    foreach (var folder in settingsObject.OpenProjects)
                    {
                        View.ProcessControllerCommand(new Commands.OpenProject(folder));
                    }

                    foreach (var document in settingsObject.OpenDocuments)
                    {
                        var owner = OpenProjects.FirstOrDefault(p => p.Path == document.Project);
                        if (owner != null)
                        {
                            View.ProcessControllerCommand(new Commands.OpenDocument(document.Path, owner));
                        }
                    }

                    if (settingsObject.CustomDictionaryEntries != null)
                    {
                        foreach (var word in settingsObject.CustomDictionaryEntries)
                        {
                            CustomDictionaryEntries.Add(word);
                            SpellChecker.Add(word);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                DictionaryBase = "en_US";

                System.Windows.Forms.MessageBox.Show("Error loading settings.", "Alert!", System.Windows.Forms.MessageBoxButtons.OK);
            }
        }
Example #3
0
        public void LoadSettings(Main View)
        {
            try
            {
                var settingsPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\BleckiTreeWriter\\settings.txt";

                if (System.IO.File.Exists(settingsPath))
                {
                    var text = System.IO.File.ReadAllText(settingsPath);
                    Settings.GlobalSettings = JsonConvert.DeserializeObject <Settings>(text);
                }
            }
            catch (Exception e)
            {
                SpellChecker = new NHunspell.Hunspell("en_US.aff", "en_US.dic");
                Thesaurus    = new NHunspell.MyThes("th_en_US_new.dat");

                System.Windows.Forms.MessageBox.Show("Error loading settings.", "Alert!", System.Windows.Forms.MessageBoxButtons.OK);
            }

            if (Settings.GlobalSettings == null)
            {
                Settings.GlobalSettings = new Settings();
            }

            Settings.GlobalSettings.Verify();

            SpellChecker = new NHunspell.Hunspell(
                Settings.GlobalSettings.Dictionary + ".aff",
                Settings.GlobalSettings.Dictionary + ".dic");
            Thesaurus = new NHunspell.MyThes(Settings.GlobalSettings.Thesaurus);

            foreach (var word in Settings.GlobalSettings.CustomDictionaryEntries)
            {
                SpellChecker.Add(word);
            }


            View.UpdateRecentDocuments();
        }