SharpDevelop (#develop)有很多“副產品”,其中最出名的應算SharpZipLib (#ziplib),純C#的ZIP類庫,而在SharpDevelop (#develop)中,“隱藏”了很多優秀的類庫,其中ICSharpCode.TextEditor是表表者。
ICSharpCode.TextEditor源代碼隱匿在\SharpDevelop\src\Libraries\ICSharpCode.TextEditor中,可以利用SharpDevelop (#develop)打開ICSharpCode.TextEditor.cmbx,也可以看看其例子(\SharpDevelop\samples\SharpPad中)SharpPad.cmbx。
先說說它的用法:
1:將ICSharpCode.TextEditor.dll添加到工具箱中,然后拖到界面上。
2:設置如下屬性(例):
textEditorControl1.ShowEOLMarkers = false;
textEditorControl1.ShowHRuler = false;
textEditorControl1.ShowInvalidLines = false;
textEditorControl1.ShowMatchingBracket = true;
textEditorControl1.ShowSpaces = false;
textEditorControl1.ShowTabs = false;
textEditorControl1.ShowVRuler = false;
textEditorControl1.AllowCaretBeyondEOL = false;
textEditorControl1.Document.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategy("HTML");
textEditorControl1.Encoding = Encoding.GetEncoding("GB2312");
textEditorControl1.ShowHRuler = false;
textEditorControl1.ShowInvalidLines = false;
textEditorControl1.ShowMatchingBracket = true;
textEditorControl1.ShowSpaces = false;
textEditorControl1.ShowTabs = false;
textEditorControl1.ShowVRuler = false;
textEditorControl1.AllowCaretBeyondEOL = false;
textEditorControl1.Document.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategy("HTML");
textEditorControl1.Encoding = Encoding.GetEncoding("GB2312");
3:指定內容文本
textEditorControl1.Text = "Hello World!"
再來說說他的擴展:
官方原版的是不支持T-SQL語法的,我們讓他支持T-SQL語法
下載http://files.cnblogs.com/wudingfeng/ICSharpCode.TextEditor_V3.0.rar
里面有一個TSQL-Mode.xshd文件,作為資源添加到項目中,然后修改SyntaxModes.xml文件,添加一行
<Mode file = "TSQL-Mode.xshd"
name = "TSQL"
extensions = ".sql"/>
name = "TSQL"
extensions = ".sql"/>
然后再編譯整個項目即可生成支持T-SQL的ICSharpCode.TextEditor.
下載最新SharpDevelop

