当前位置: 首页 > java >正文

WPF语法高亮控件AvalonEdit



AvalonEdit is a WPF-based extensible text editor.

AvalonEdit是基于WPF的可扩展的文本编辑器。


While the WPF RichTextBox is quite powerful, you quickly run into its limits when trying to use it as a code editor: it's hard to write efficient syntax highlighting for it, and you cannot really implement features like code folding with the standard RichTextBox.

虽然WPF的RichTextBox功能很强,使用它当代码编辑器时运行迅速。但用它写有效的语法高亮文本还是比较困难,并且不能真正实现像代码折叠之类的特性。


The problem is: the RichTextBox edits a rich document. In contrast, AvalonEdit simply edits text.

问题有:RichTextBox是一个富文档编辑器,与此不同的是,AvalonEdit是一个简单文本编辑器。


However, AvalonEdit offers lots of possibilities on how the text document is displayed - so it is much more suitable for a code editor where things like the text color are not controlled by the user, but instead depend on the text (syntax highlighting).

然而,AvalonEdit为如何显示文档提供了多种可能性,比如文本颜色不是由用户控制,而是依赖于文本(语法高亮)的情况,所以它作为代码编辑器是非常合适的。


AvalonEdit was written for the SharpDevelop IDE. It replaces our old Windows Forms-based text editor (ICSharpCode.TextEditor).

AvalonEdit 是为SharpDevelop IDE而开发的编辑器,它代替了传统windows 面向表单文本的编辑器(ICSharpCode.TextEditor)。



用法:

The main class of the editor is ICSharpCode.AvalonEdit.TextEditor. You can use it similar to a normal WPF TextBox:

编辑器的主要类是ICSharpCode.AvalonEdit.TextEditor,可以用它来写一个简单的WPF文本框控件。

 
<avalonEdit:TextEditorxmlns:avalonEdit="http://icsharpcode.net/sharpdevelop/avalonedit"Name="textEditor"SyntaxHighlighting="C#"FontFamily="Consolas"FontSize="10pt"/>


系统环境:

There are two versions of AvalonEdit - the normal one requires .NET Framework 4.0 or higher; but we also offer a modified version for .NET 3.5 SP1. For compiling AvalonEdit, you will need a C# 4.0 compiler (SharpDevelop 4.x or Visual Studio 2010).

AvalonEdit有两个版本,普通版需要.Net Framework 4.0或更高版本的支持,另外也提供了基于.Net 3.5 SP1的改良版。编译AvalonEdit时,需要C#4.0的编辑器。(SharpDevelop 4.x  或 Visual Studio 2010).

private static FoldingManager foldingManager = null;private static XmlFoldingStrategy foldingStrategy = new XmlFoldingStrategy();//快速搜索txtTemplateContent.TextArea.DefaultInputHandler.NestedInputHandlers.Add(new SearchInputHandler(txtTemplateContent.TextArea));//显示行号            txtTemplateContent.ShowLineNumbers = true;//默认语法高亮规则txtTemplateContent.SyntaxHighlighting = HighlightingManager.Instance.GetDefinitionByExtension(".xml");//折叠foldingManager = FoldingManager.Install(txtTemplateContent.TextArea);txtTemplateContent.Text = DispContentValue;foldingStrategy.UpdateFoldings(foldingManager, txtTemplateContent.Document);


应用语法高亮读取xslt文档效果如下:




http://www.xdnf.cn/news/11107.html

相关文章:

  • 目前流行的几种排课算法的介绍
  • zlatan的算法笔记1--回溯中的组合问题(力扣77题)
  • document.all用法(一)
  • chatgpt提示词
  • Debug 命令详解
  • 推荐8个值得每天一看的网站,值得收藏起来!
  • 【体系结构 三 流水线技术】
  • delay的几个函数说明
  • Linux Shell Shock漏洞利用和实战
  • php语法之计算1~100偶数之和
  • c语言-exit函数
  • 【C语言】Windows下的多线程编程-关键段(临界区)
  • LARGE_INTEGER 转换 __int64
  • 进化计算(八)——MOEA/D算法详解Ⅱ
  • 12036 抢票助手开源,星标 12.7K !
  • B2B2C电商app系统开发(java开源,快速搭建)
  • 【一文读懂】什么是磁带存储?为何焕发第二春?
  • 【Laravel系列4.3】模型Eloquent ORM的使用(一)
  • 5000字详解性能需求
  • 滚动条样式修改
  • 内网端口映射工具有哪些?
  • 蝶阀的作用介绍
  • 史上最全网络安全站点集合
  • Java面试宝典
  • 分享126个图片JS特效,总有一款适合您
  • Nios II嵌入式软处理器提升系统性能方式详解
  • Happytime RTSP可用于流式传输各种设备和文
  • 俄罗斯 搜索引擎 邮箱创建
  • 使用 iMacros 来自动化日常的工作
  • LAMP架构