예제 #1
0
        void Form1_Load(object sender, EventArgs e)
        {
            CultureInfo usCulture = new CultureInfo("en-US");
            SpellCheckerISpellDictionary dictionary1 = new SpellCheckerISpellDictionary(@"..\..\american.xlg", @"..\..\english.aff", usCulture);

            dictionary1.AlphabetPath = @"..\..\EnglishAlphabet.txt";
            dictionary1.Load();
            this.spellChecker1.Dictionaries.Add(dictionary1);

            this.richEditControl1.Text = @"Accordnig to an englnsih unviersitry sutdy the oredr of letetrs in a word dosen't mttaer, the olny thnig thta's imporantt is that the frsit and last ltteer of eevry word is in the crrecot psoition. The rset can be jmbueld and one is stlil able to read the txet withuot dificultfiy.";
            this.labelControl1.Text    = "Right-click a misspelled word for a context menu containing a list of suggested replacements";
        }
        static SpellCheckerDictionaryBase GetDefaultDictionary(string path)
        {
            SpellCheckerISpellDictionary dic = new SpellCheckerISpellDictionary();

            dic.DictionaryLoaded += new EventHandler(dic_DictionaryLoaded);

            dic.DictionaryPath = path + "\\american.xlg";
            dic.GrammarPath    = path + "\\english.aff";
            dic.AlphabetPath   = path + "\\EnglishAlphabet.txt";
            dic.Culture        = new CultureInfo("en-US");
            dic.Load();
            dic.DictionaryLoaded -= dic_DictionaryLoaded;
            return(dic);
        }
        /// <summary>
        /// create rich editor
        /// </summary>
        /// <param name="fieldInfo"></param>
        /// <returns></returns>
        ///
        protected virtual RichEditControl CreateRichTextEdit(ModuleFieldInfo fieldInfo)
        {
            //var rtControl = new RichEditControl
            //{
            //    Name = string.Format(CONSTANTS.RICHTEXT_NAME_FORMAT, fieldInfo.FieldName),
            //    Tag = fieldInfo
            //};
            rtControl              = new RichEditControl();
            spellChecker1          = new SpellChecker();
            rtControl.SpellChecker = spellChecker1;
            //spellChecker1.SetShowSpellCheckMenu(rtControl, false);
            //spellChecker1.SetSpellCheckerOptions(this.rtControl, optionsSpelling1);
            CultureInfo usCulture = new CultureInfo("en-US");
            SpellCheckerISpellDictionary dictionary1 = new SpellCheckerISpellDictionary(@"..\..\american.xlg", @"..\..\english.aff", usCulture);

            dictionary1.AlphabetPath = @"..\..\EnglishAlphabet.txt";
            dictionary1.Load();
            spellChecker1.Dictionaries.Add(dictionary1);
            rtControl.PopupMenuShowing += new DevExpress.XtraRichEdit.PopupMenuShowingEventHandler(rtControl_PopupMenuShowing);
            return(rtControl);
        }
    String CheckText(String text)
    {
        SpellCheckerBase checker = new SpellCheckerBase();

        checker.NotInDictionaryWordFound += new NotInDictionaryWordFoundEventHandler(checker_NotInDictionaryWordFound);

        SpellCheckerISpellDictionary dict = new SpellCheckerISpellDictionary(Server.MapPath("~/Dictionaries/american.xlg"),
                                                                             Server.MapPath("~/Dictionaries/english.aff"),
                                                                             new CultureInfo("en-us"));

        dict.AlphabetPath = Server.MapPath("~/Dictionaries/EnglishAlphabet.txt");
        dict.CacheKey     = "ispellDic";
        dict.Load();

        checker.Dictionaries.Add(dict);

        checker.LevenshteinDistance = 4;

        String result = checker.Check(text);

        return(result);
    }
예제 #5
0
        private void LoadISpellDictionaries()
        {
            #region #LoadISpellDictionaries
            spellChecker1.Dictionaries.Clear();

            SpellCheckerISpellDictionary ispellDictionaryEnglish = new SpellCheckerISpellDictionary();
            ispellDictionaryEnglish.DictionaryPath = @"Dictionaries\ISpell\en_US\american.xlg";
            ispellDictionaryEnglish.GrammarPath    = @"Dictionaries\ISpell\en_US\english.aff";
            ispellDictionaryEnglish.AlphabetPath   = @"Dictionaries\EnglishAlphabet.txt";
            ispellDictionaryEnglish.Culture        = new CultureInfo("en-US");
            ispellDictionaryEnglish.Load();
            spellChecker1.Dictionaries.Add(ispellDictionaryEnglish);
            #endregion #LoadISpellDictionaries

            SpellCheckerISpellDictionary ispellDictionarySpanish = new SpellCheckerISpellDictionary();
            ispellDictionarySpanish.DictionaryPath = @"Dictionaries\ISpell\es_ES\espanol.dic";
            ispellDictionarySpanish.GrammarPath    = @"Dictionaries\ISpell\es_ES\espanol.aff";
            ispellDictionarySpanish.AlphabetPath   = @"Dictionaries\SpanishAlphabet.txt";
            ispellDictionarySpanish.Culture        = new CultureInfo("es-ES");
            ispellDictionarySpanish.Load();
            spellChecker1.Dictionaries.Add(ispellDictionarySpanish);

            LoadCustomDictionary();
        }