mcpField
S
syncfusion-winforms-spell-checker

syncfusion-winforms-spell-checker

github.com/syncfusion开发283 次安装2 周前更新
代码仓库

关于 syncfusion-winforms-spell-checker

面向在 Windows Forms 文本控件中使用 Syncfusion SpellCheckerAdv 的指南,介绍词典、语言切换、上下文菜单检查和拼写建议。

主要功能

  1. 01检查 TextBox 和 RichTextBox
  2. 02Hunspell、Ispell 和 OpenOffice 词典
  3. 03运行时切换语言区域
  4. 04上下文菜单拼写建议
  5. 05忽略规则与更正选项

适用场景

  1. 01为邮件客户端添加拼写检查
  2. 02检查编辑器中的多语言内容
  3. 03验证表单输入
  4. 04忽略 URL 和电子邮件地址

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/syncfusion/winforms-ui-components-skills --skill syncfusion-winforms-spell-checker

安装后在 Claude Code 中输入/syncfusion-winforms-spell-checker确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

references/
context-menu-integration.md
customization-suggestions.md
dictionary-setup.md
getting-started.md

详细介绍

实现 Syncfusion Windows Forms SpellChecker

SpellCheckerAdv 控件为 Windows Forms 文本控件提供 Microsoft Office 风格的拼写检查功能。本技能将指导你完成安装、控件关联、词典配置、上下文菜单集成和自定义选项。

何时使用此技能

在以下情况下使用此技能:

  • 为 RichTextBox 或 TextBox 控件添加拼写检查功能
  • 配置词典来源(内置英语词典或自定义词典)
  • 设置由上下文菜单驱动的拼写检查
  • 为特殊内容(电子邮件、URL、数字)自定义忽略规则
  • 获取拼写建议和替代项
  • 通过不同词典格式支持多种语言

文档导航

入门

📄 阅读: references/getting-started.md

  • 安装和程序集引用
  • 通过设计器或代码添加控件
  • 配置 SpellCheckerAdv 与文本控件
  • 调用拼写检查操作
  • 基本实现模式
词典配置

📄 阅读: references/dictionary-setup.md

  • 设置默认英语词典
  • 添加 Hunspell 词典以支持多种语言
  • 添加 Ispell 词典
  • 添加 OpenOffice 词典
  • 在运行时切换区域性
  • 自定义词典支持
上下文菜单集成

📄 阅读: references/context-menu-integration.md

  • 实现 ISpellCheckerAdvEditorTools 接口
  • 创建 TextBoxSpellEditor 包装类
  • 设置运行时上下文菜单
  • 用户驱动的拼写检查工作流
  • 从上下文菜单将词语添加到词典
自定义和建议

📄 阅读: references/customization-suggestions.md

  • 忽略选项(电子邮件、URL、大小写混合、特殊符号)
  • 获取建议列表
  • 语音相似词替代项
  • 字谜建议
  • 自定义词语管理

快速入门示例

基本拼写检查设置:

using Syncfusion.Windows.Forms.Tools;

// 1. Create SpellCheckerAdv control
SpellCheckerAdv spellCheckerAdv = new SpellCheckerAdv();

// 2. Set dictionary path
spellCheckerAdv.DictionaryPath = "Syncfusion_en_us.dic";

// 3. Attach to RichTextBox and trigger spell check
RichTextBox richTextBox = new RichTextBox();
spellCheckerAdv.SpellCheck(new SpellCheckerAdvEditorWrapper(richTextBox));

上下文菜单拼写检查:

// Implement ISpellCheckerAdvEditorTools
class TextBoxSpellEditor : ISpellCheckerAdvEditorTools
{
    private TextBoxBase textBox;
    
    public TextBoxSpellEditor(Control control)
    {
        Control = control;
    }
    
    public Control Control 
    { 
        get { return textBox; }
        set { textBox = value as TextBoxBase; }
    }
    
    public string Text
    {
        get { return textBox.Text; }
        set { textBox.Text = value; }
    }
    
    public string CurrentWord { get; set; }
    
    public void SelectText(int start, int length)
    {
        textBox.Select(start, length);
    }
}

// Enable context menu spell checking
TextBoxSpellEditor editor = new TextBoxSpellEditor(richTextBox);
spellCheckerAdv.PerformSpellCheckUsingContextMenu(editor);

常见实现模式

模式 1:基于对话框的拼写检查

用户点击“拼写检查”按钮 → SpellCheckerAdv 对话框打开 → 用户检查并更正拼写错误的单词 → 对话框关闭。

private void buttonSpellCheck_Click(object sender, EventArgs e)
{
    spellCheckerAdv.SpellCheck(new SpellCheckerAdvEditorWrapper(richTextBox));
}
模式 2:实时上下文菜单

用户右键点击拼写错误的单词 → 显示包含建议的上下文菜单 → 用户选择更正项或将单词添加到词典。

TextBoxSpellEditor editor = new TextBoxSpellEditor(richTextBox);
spellCheckerAdv.PerformSpellCheckUsingContextMenu(editor);
模式 3:多语言支持

配置多种词典区域性,并根据用户偏好或内容语言在运行时切换。

SpellCheckerAdv spellChecker = new SpellCheckerAdv();
spellChecker.Dictionaries = new DictionaryCollection();

// Add English dictionary
spellChecker.Dictionaries.Add(new HunspellDictionary()
{
    Culture = new CultureInfo("en-US"),
    DictionaryPath = @"en-US.dic",
    GrammarPath = @"en-US.aff"
});

// Add French dictionary
spellChecker.Dictionaries.Add(new HunspellDictionary()
{
    Culture = new CultureInfo("fr-FR"),
    DictionaryPath = @"fr-FR.dic",
    GrammarPath = @"fr-FR.aff"
});

// Switch to French at runtime
spellChecker.Culture = new CultureInfo("fr-FR");

关键属性和方法

元素用途使用时机
DictionaryPath设置内置词典位置简单的英语拼写检查
Dictionaries添加自定义词典(Hunspell、Ispell、OpenOffice)多语言支持
Culture设置启用的拼写检查语言切换语言
SpellCheck()触发拼写检查对话框用户主动发起拼写检查
PerformSpellCheckUsingContextMenu()启用上下文菜单建议实时拼写检查
GetSuggestions()获取更正建议以编程方式进行拼写检查
IgnoreEmailAddress、IgnoreUrl 等跳过特殊内容类型自定义拼写检查

常见用例

  1. 电子邮件客户端:使用自定义词典进行右键拼写检查
  2. 文档编辑器:通过上下文菜单进行多语言拼写检查
  3. 表单验证器:在提交前检查用户输入
  4. 内容管理:忽略内容中的 URL 和电子邮件地址
  5. 多语言应用:根据 UI 区域性切换拼写检查语言

评论

支持 Markdown