13

所以无论如何,我正在尝试在 Visual C#.NET 中将自定义语法突出显示到 Scintilla 控件中。

我被告知通过 XML 文件执行此操作。我已将其命名为“ScintillaNET.xml”并将其放在我的项目的调试箱中。

在 Form_Load 中,我将其语言设置为批处理(这是正确的),并在属性中指定文件的位置。

我在 XML 文件中的代码是:

<?xml version="1.0" encoding="utf-8"?>

<ScintillaNET>

    <!-- Set up the language, style, and lexer for batch -->
    <Language Name="batch">

        <!-- Lexer -->
        <Lexer StreamCommentPrefix="{ " StreamCommentSuffix=" }">
            <Keywords List="0">var</Keywords>
        </Lexer>

        <!-- Style -->
        <Styles>
            <Sytle Name="CHARACTER" ForeColor="Black" BackColor="Red"/>
        </Styles>

        <!-- Other Settings -->
        <Indentation TabWidth="2" UseTabs="false"/>

    </Language>

</ScintillaNET>

不幸的是,这似乎不起作用......当我运行我的程序时,在 Scintilla 中什么也没有发生。

我对自定义语法突出显示的主要目标并不复杂。

我只想能够: 选择要突出显示的单词。选择颜色以使它们突出显示/着色。

我该怎么做呢?我的代码有什么问题?

(如果有人有关于如何做的快速教程,那将不胜感激)

4

1 回答 1

17

我已经在我的机器上测试了你的 xml 文件。带有 ScintillaNet Control 和您的 xml 的 Windows 窗体应用程序运行良好。

在此处输入图像描述

确保您执行以下操作:

  1. 您的系统“路径”包括 SciLexer.dll 所在的目录
  2. 在 ScintillaNet Control 的 ConfigrationManager 属性中。设置 CustomLocation 属性 = ScintillaNET.xml
  3. 在 ScintillaNet Control 的 ConfigrationManager 属性中。语言属性 = 批次。

参考:

(安装)http://scintillanet.codeplex.com/wikipage?title=Installation&referringTitle=Documentation

(如何使用我自己的配置文件?)http://scintillanet.codeplex.com/wikipage?title=HowToCustomConfig&referringTitle=Documentation

于 2011-08-04T18:32:39.497 回答