16

我正在开发一个项目,其中包括为我的 WPF (.Net4) windows 应用程序实现脚本接口。我很好奇是否有人可以推荐首选编辑器AvalonEdit vs ScintillaNET。任何一个相对于另一个的缺陷和优势。我们需要同时支持 C# 和 IronPython 作为脚本语言。(至少这是最初的计划。我们可能会最终确定其中一个)。

ScintillaNET 的缺点之一是它只是原生(非托管)Scintilla 的托管包装器。与 WPF4 一起使用时,这会导致任何问题吗?

任何指针和建议表示赞赏。

4

1 回答 1

23

I think this depends on how many features you want to implement in the editor. Also how much work you are willing to put in to extend it and how much of a learning curve you are willing to deal with.

If you are targetting Win32 and you don't mind the unmanaged dll then I think Scintilla.NET won't be a problem. Also you can easily host it in WPF as this page suggests.

Personally I felt that Scintilla performs better than AvalonEdit. It also is easier to get started with a basic editor, and provides a lot out of the box, for instance Scintilla provides code folding out of the box.

With AvalonEdit you have to create a folding strategy and parse the document yourself, This is what I had to do to support IronPython for AvalonEdit which I haven't implemented yet.

All I needed to support an IronPython editor in scintilla was the SciLexer.dll in the search path and the Scintilla.net assembly and the following configuration:

private void Form1_Load(object sender, EventArgs e)
    {
        this.scintilla1 = new ScintillaNet.Scintilla();
        this.scintilla1.ConfigurationManager.Language = "python";
        this.scintilla1.Indentation.ShowGuides = true;
        this.scintilla1.Indentation.SmartIndentType = ScintillaNet.SmartIndent.Simple;
        this.scintilla1.Location = new System.Drawing.Point(0, 0);
        this.scintilla1.Margins.Margin0.Width = 40;
        this.scintilla1.Margins.Margin2.Width = 20;
        this.scintilla1.Name = "scintilla1";
        this.scintilla1.TabIndex = 4;
        this.scintilla1.Whitespace.Mode = ScintillaNet.WhitespaceMode.VisibleAfterIndent;
        this.scintilla1.Dock = DockStyle.Fill;
        this.Controls.Add(this.scintilla1);
    }

For AvalonEdit you have to load an external highlighter file, you can see the this blog post for more info. So if you want the basics (highlighting, folding for python+c#) my conclusion is schintilla is easier and performs better. Although with AvalonEdit you might be able to do more in the end if you are willing to put in the effort and deal with the learning curve. At the moment I am using Scintilla as my stable editor and am experimenting with Avalon as a proof of concept. Perhaps I will form new opinions too as I learn more about the editor.

Good luck

于 2012-01-03T11:29:16.940 回答