2014-09-04 8 views
2

我有汉斯帕桑特做出这种控制,我从这里(Trying to use the C# SpellCheck class)抓住和修改,以加载额外的词典:为什么拼写检查总是将附加字典中的单词(utf-8,带有BOM,UTF-16的utf-8)标记为坏?

using System; 
using System.Windows; 
using System.ComponentModel; 
using System.Windows.Controls; 
using System.Windows.Forms.Integration; 

namespace SoAL_TextExtractor 
{ 
    class SpellBox : ElementHost 
    { 
     public SpellBox() 
     { 
      box = new TextBox(); 
      base.Child = box; 
      box.TextChanged += (s, e) => OnTextChanged(EventArgs.Empty); 
      Uri lex_file = new Uri(System.Windows.Forms.Application.StartupPath + "\\Russian.lex"); 
      box.SpellCheck.CustomDictionaries.Add(lex_file); 
      box.SpellCheck.IsEnabled = true; 
      box.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; 
      this.Size = new System.Drawing.Size(100, 20); 
     } 
     public override string Text 
     { 
      get { return box.Text; } 
      set { box.Text = value; } 
     } 
     [DefaultValue(false)] 
     public bool Multiline 
     { 
      get { return box.AcceptsReturn; } 
      set { box.AcceptsReturn = value; } 
     } 
     [DefaultValue(false)] 
     public bool WordWrap 
     { 
      get { return box.TextWrapping != TextWrapping.NoWrap; } 
      set { box.TextWrapping = value ? TextWrapping.Wrap : TextWrapping.NoWrap; } 
     } 
     [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] 
     public new System.Windows.UIElement Child 
     { 
      get { return base.Child; } 
      set { /* Do nothing to solve a problem with the serializer !! */ } 
     } 
     private TextBox box; 
    } 
} 

这本字典:

enter image description here

而且,这结果:

enter image description here

我对* .lex尝试了不同的编码,但仍标记为不良。

有法盖子,需要:

#LID 1049 
абажур 
абажура 
... 

这是怎么回事?

+0

你不能只是复制别人的代码,并重新发布它,就好像它是你自己的。要求归因,请查看页面底部的详细信息。 – 2014-09-04 09:52:15

+0

@HansPassant - 对不起?我在哪里说过这是我的代码?我所说的只是“我有这个控制权”。我知道这是从另一个答案抓住,但我从来没有告诉过,这是我的。我使用它,我遇到了问题,并且在这里展示了我的所有内容。 – Kosmos 2014-09-04 13:42:41

+0

该许可证没有说任何关于这一点。这是一个非常简单的规则,当你转发别人的工作时,你必须**属性。总是。请照顾好它。 – 2014-09-04 14:11:15

回答

2

我可以通过以下操作来获得法国工作:使用1252编码

    • 保存文件中设置语言上的文本框中
    • 在lex文件中的#LID设置为1036

    试验:使用包含文件:EEE

    例如

    box.Language = System.Windows.Markup.XmlLanguage.GetLanguage("fr"); 
    String text = System.IO.File.ReadAllText(lex_file.AbsolutePath, Encoding.UTF8); 
    System.IO.File.WriteAllText(lex_file.AbsolutePath, text, Encoding.GetEncoding(1252)); 
    

    不幸的是,这不适用于俄罗斯。它似乎只默认支持4种语言。有关更多信息,请参阅Does SpellCheck .Net class support russian language?

  • 相关问题