-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDefault.aspx.cs
49 lines (39 loc) · 1.51 KB
/
Default.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DevExpress.XtraSpellChecker;
using DevExpress.Web.ASPxSpellChecker;
using System.Globalization;
using System.IO;
public partial class _Default : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
}
protected void btn_Click(object sender, EventArgs e) {
String correctedText = CheckText(memo.Text);
memo.Text = correctedText;
}
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;
}
void checker_NotInDictionaryWordFound(object sender, NotInDictionaryWordFoundEventArgs e) {
e.Result = SpellCheckOperation.ChangeAll;
e.Handled = true;
}
}