I want to use Hunspell with WPF, but initialization seems to fail.

Asked 1 months ago, Updated 1 months ago, 5 views

WPF uses HunSpell wrapper class NHunspellWrapper.

private void Window_Loaded (object sender, RoutedEventArgse)
{
   // spelling check
   varhunspell=new NHunspellWrapper();
}

Called by

publicNHunspellWrapper(): this("en_US.aff", "en_US.dic", null, new SpellingFormBasic())
{

}

/// <param name="affFile">"en_us.aff"</param>
/// <param name="dicFile">"en_us.dic"</param>
public NHunspellWrapper(string affFile, stringdicFile, ISpellingControl textEditor, ISpellingWindowspellForm)
{
    try
    {
        hunspell=new Hunspell(affFile,dicFile);
        varchk=hunspell.Spell("with");<-false returns
            :

Hunspell is not null, but I feel like I can't read the dictionary file or initialization has failed.
There's no basis, but...

I couldn't find this sample of Hunspell when I looked for something like WinForm and WPF.

src=

It seems that the HunspellWrapper component spellingWorker is made in WinForm, but not in WPF.

How do I use Hunspell components in WPF?

Environment Windows 10 VS 2015 C#WPF

c# wpf

2022-09-30 13:56

1 Answers

Why not replace it with NHunspellSpellcheck-Hyphen-Thesaurus standard SpellCheck

It seems that this will work.

https://sourceforge.net/p/nhunspell/code/ci/default/tree/NHunspellSamples/CSharpConsoleSamples/Program.cs#l51

From the above site

using(var hunspell=new Hunspell("en_us.aff", "en_us.dic")))
{

    string [ ] lines = System.IO.File.ReadAllLines("CustomWords-en_US.txt");
    foreach (var line in lines)
    {
        hunspell.Add(line);
    }

It seems to work in the form of the directly.

Thank you.


2022-09-30 13:56

If you have any answers or tips


© 2022 OneMinuteCode. All rights reserved.