本文整理汇总了C#中ICSharpCode.TextEditor.TextEditorControl.SetHighlighting方法的典型用法代码示例。如果您正苦于以下问题:C# TextEditorControl.SetHighlighting方法的具体用法?C# TextEditorControl.SetHighlighting怎么用?C# TextEditorControl.SetHighlighting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICSharpCode.TextEditor.TextEditorControl
的用法示例。
在下文中一共展示了TextEditorControl.SetHighlighting方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateTextBox
private TextEditorControl CreateTextBox()
{
var tb = new TextEditorControl();
tb.IsReadOnly = true;
// TODO: set proper highlighting.
tb.SetHighlighting("C#");
var high = (ICSharpCode.TextEditor.Document.DefaultHighlightingStrategy)tb.Document.HighlightingStrategy;
var def = high.Rules.First();
var delim = " ,().:\t\n\r";
for(int i = 0; i < def.Delimiters.Length; ++i)
def.Delimiters[i] = delim.Contains((char)i);
tb.ShowLineNumbers = false;
tb.ShowInvalidLines = false;
tb.ShowVRuler = false;
tb.ActiveTextAreaControl.TextArea.ToolTipRequest += OnToolTipRequest;
tb.ActiveTextAreaControl.TextArea.MouseMove += OnTextAreaMouseMove;
string[] tryFonts = new[] { "Consolas", "Lucida Console" };
foreach (var fontName in tryFonts)
{
tb.Font = new Font(fontName, 9, FontStyle.Regular);
if (tb.Font.Name == fontName) break;
}
if (!tryFonts.Contains(tb.Font.Name))
tb.Font = new Font(FontFamily.GenericMonospace, 9);
return tb;
}
示例2: FdoSqlQueryCtl
public FdoSqlQueryCtl()
{
InitializeComponent();
_editor = new TextEditorControl();
_editor.Dock = DockStyle.Fill;
_editor.SetHighlighting("SQL");
this.Controls.Add(_editor);
}
示例3: PlistEditControl
public PlistEditControl(FATabStrip tabStrip, string title, PlistInfo p = null)
{
Editor = new TextEditorControl();
Tab = new FATabStripItem();
Tab.Title = title;
Tab.Controls.Add(Editor);
Editor.Dock = DockStyle.Fill;
if (p == null)
{
p = new PlistInfo();
}
Pinfo = p;
Editor.Text = p.Content;
Editor.SetHighlighting("XML");
Editor.TextChanged += Editor_TextChanged;
tabStrip.AddTab(Tab);
Saved = true;
}
示例4: DocumentPanel
public DocumentPanel(string fileName)
{
InitializeComponent();
_fileName = fileName;
TabText = _fileName;
if (PlatformSupport.Platform == PlatformType.Windows)
{
Icon = Properties.Resources.document_properties;
// SharpDevelop text editor is Windows only.
var txtDocument = new TextEditorControl {Dock = DockStyle.Fill, IsReadOnly = true, Name = "txtDocument"};
Controls.Add(txtDocument);
txtDocument.SetHighlighting("SMI"); // Activate the highlighting, use the name from the SyntaxDefinition node.
txtDocument.LoadFile(_fileName);
}
else
{
var txtDocument = new RichTextBox {Dock = DockStyle.Fill, Name = "txtDocument", ReadOnly = true};
Controls.Add(txtDocument);
txtDocument.LoadFile(_fileName, RichTextBoxStreamType.PlainText);
}
}
示例5: _initControl
public override void _initControl()
{
if (null == mTextEditorControl || mTextEditorControl.IsDisposed)
{
mTextEditorControl = new TextEditorControl();
if (string.Compare(mDockStyle, @"Top") == 0)
{
mTextEditorControl.Dock = DockStyle.Top;
}
else if (string.Compare(mDockStyle, @"Bottom") == 0)
{
mTextEditorControl.Dock = DockStyle.Bottom;
}
else if (string.Compare(mDockStyle, @"Fill") == 0)
{
mTextEditorControl.Dock = DockStyle.Fill;
}
else if (string.Compare(mDockStyle, @"Left") == 0)
{
mTextEditorControl.Dock = DockStyle.Left;
}
else if (string.Compare(mDockStyle, @"Right") == 0)
{
mTextEditorControl.Dock = DockStyle.Right;
}
else
{
mTextEditorControl.Dock = DockStyle.None;
}
mTextEditorControl.SetHighlighting(mHighlighting);
if (null != mUrl)
{
this._openUrl(mUrl);
}
}
}
示例6: Open
public TabInfo Open(string file, OpenType type, bool addToMRU = true, bool alwaysNew = false)
{
if (type == OpenType.File) {
if (!Path.IsPathRooted(file)) {
file = Path.GetFullPath(file);
}
//Add this file to the recent files list
if (addToMRU) {
Settings.AddRecentFile(file);
}
UpdateRecentList();
//If this is an int, decompile
if (string.Compare(Path.GetExtension(file), ".int", true) == 0) {
var compiler = new Compiler();
string decomp = compiler.Decompile(file);
if (decomp == null) {
MessageBox.Show("Decompilation of '" + file + "' was not successful", "Error");
return null;
} else {
file = decomp;
type = OpenType.Text;
}
} else {
//Check if the file is already open
for (int i = 0; i < tabs.Count; i++) {
if (string.Compare(tabs[i].filepath, file, true) == 0) {
tabControl1.SelectTab(i);
return tabs[i];
}
}
}
}
//Create the text editor and set up the tab
ICSharpCode.TextEditor.TextEditorControl te = new ICSharpCode.TextEditor.TextEditorControl();
te.ShowVRuler = false;
te.Document.FoldingManager.FoldingStrategy = new CodeFolder();
te.IndentStyle = IndentStyle.Smart;
te.ConvertTabsToSpaces = Settings.tabsToSpaces;
te.TabIndent = Settings.tabSize;
te.Document.TextEditorProperties.IndentationSize = Settings.tabSize;
if (type == OpenType.File)
te.LoadFile(file, false, true);
else if (type == OpenType.Text)
te.Text = file;
if (type == OpenType.File && string.Compare(Path.GetExtension(file), ".msg", true) == 0)
te.SetHighlighting("msg");
else
te.SetHighlighting("ssl"); // Activate the highlighting, use the name from the SyntaxDefinition node.
te.TextChanged += textChanged;
te.ActiveTextAreaControl.TextArea.MouseDown += delegate(object a1, MouseEventArgs a2) {
if (a2.Button == MouseButtons.Left)
UpdateEditorToolStripMenu();
lbAutocomplete.Hide();
};
te.ActiveTextAreaControl.TextArea.KeyPress += KeyPressed;
te.HorizontalScroll.Visible = false;
te.ActiveTextAreaControl.TextArea.PreviewKeyDown += delegate(object sender, PreviewKeyDownEventArgs a2) {
if (lbAutocomplete.Visible) {
if ((a2.KeyCode == Keys.Down || a2.KeyCode == Keys.Up || a2.KeyCode == Keys.Tab)) {
lbAutocomplete.Focus();
lbAutocomplete.SelectedIndex = 0;
} else if (a2.KeyCode == Keys.Escape) {
lbAutocomplete.Hide();
}
} else {
if (toolTipAC.Active && a2.KeyCode != Keys.Left && a2.KeyCode != Keys.Right)
toolTipAC.Hide(panel1);
}
};
TabInfo ti = new TabInfo();
ti.textEditor = te;
ti.changed = false;
if (type == OpenType.File && !alwaysNew) {
ti.filepath = file;
ti.filename = Path.GetFileName(file);
} else {
ti.filepath = null;
ti.filename = unsaved;
}
ti.index = tabControl1.TabCount;
te.ActiveTextAreaControl.TextArea.ToolTipRequest += new ToolTipRequestEventHandler(TextArea_ToolTipRequest);
te.ContextMenuStrip = editorMenuStrip;
tabs.Add(ti);
TabPage tp = new TabPage(ti.filename);
tp.Controls.Add(te);
te.Dock = DockStyle.Fill;
tabControl1.TabPages.Add(tp);
if (type == OpenType.File & !alwaysNew) {
tp.ToolTipText = ti.filepath;
System.String ext = Path.GetExtension(file).ToLower();
if (ext == ".ssl" || ext == ".h") {
ti.shouldParse = true;
ti.needsParse = true;
if (Settings.autoOpenMsgs && ti.filepath != null)
AssossciateMsg(ti, false);
}
//.........这里部分代码省略.........
示例7: SetupIntellisense
public void SetupIntellisense(TextEditorControl control)
{
_control = control;
control.SetHighlighting((SupportedLanguage == SupportedLanguage.CSharp) ? "C#" : "VBNET");
control.ShowEOLMarkers = false;
control.ShowInvalidLines = false;
HostCallbackImplementation.Register(this);
CodeCompletionKeyHandler.Attach(this, control);
ToolTipProvider.Attach(this, control);
ProjectContentRegistry = new ProjectContentRegistry(); // Default .NET 2.0 registry
// Persistence lets SharpDevelop.Dom create a cache file on disk so that
// future starts are faster.
// It also caches XML documentation files in an on-disk hash table, thus
// reducing memory usage.
try
{
if (Settings.Default.CacheFiles)
{
var persistencePath = Path.Combine(Path.GetTempPath(), ReflexilPersistence);
var persistenceCheck = Path.Combine(persistencePath, ReflexilPersistenceCheck);
Directory.CreateDirectory(persistencePath); // Check write/access to directory
File.WriteAllText(persistenceCheck, @"Using cache!"); // Check write file rights
File.ReadAllText(persistenceCheck); // Check read file rights
ProjectContentRegistry.ActivatePersistence(persistencePath);
}
}
// ReSharper disable once EmptyGeneralCatchClause
catch (Exception)
{
// don't use cache file
}
ProjectContent = new DefaultProjectContent {Language = LanguageProperties};
ParseInformation = new ParseInformation(new DefaultCompilationUnit(ProjectContent));
}