本文整理汇总了C#中ICSharpCode.TextEditor.TextArea.EndUpdate方法的典型用法代码示例。如果您正苦于以下问题:C# TextArea.EndUpdate方法的具体用法?C# TextArea.EndUpdate怎么用?C# TextArea.EndUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICSharpCode.TextEditor.TextArea
的用法示例。
在下文中一共展示了TextArea.EndUpdate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Generate
/// <summary>
/// Inserts the PInvoke signature at the current cursor position.
/// </summary>
/// <param name="textArea">The text editor.</param>
/// <param name="signature">A PInvoke signature string.</param>
public void Generate(TextArea textArea, string signature)
{
IndentStyle oldIndentStyle = textArea.TextEditorProperties.IndentStyle;
bool oldEnableEndConstructs = PropertyService.Get("VBBinding.TextEditor.EnableEndConstructs", true);
try {
textArea.BeginUpdate();
textArea.Document.UndoStack.StartUndoGroup();
textArea.TextEditorProperties.IndentStyle = IndentStyle.Smart;
PropertyService.Set("VBBinding.TextEditor.EnableEndConstructs", false);
string[] lines = signature.Replace("\r\n", "\n").Split('\n');
for (int i = 0; i < lines.Length; ++i) {
textArea.InsertString(lines[i]);
// Insert new line if not the last line.
if ( i < (lines.Length - 1))
{
Return(textArea);
}
}
} finally {
textArea.Document.UndoStack.EndUndoGroup();
textArea.TextEditorProperties.IndentStyle = oldIndentStyle;
PropertyService.Set("VBBinding.TextEditor.EnableEndConstructs", oldEnableEndConstructs);
textArea.EndUpdate();
textArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.WholeTextArea));
textArea.Document.CommitUpdate();
}
}
示例2: InsertString
/// <summary>
/// Insert a string of text into the specified text area at the current
/// cursor location.
/// </summary>
/// <param name="textArea">The text area to use</param>
/// <param name="text">The text to insert</param>
public static void InsertString(TextArea textArea, string text)
{
int offset = textArea.Caret.Offset;
textArea.BeginUpdate();
try
{
textArea.Document.UndoStack.StartUndoGroup();
// If inserted in a selection, replace the selection.
// Otherwise, clear it.
if(textArea.SelectionManager.HasSomethingSelected)
if(textArea.SelectionManager.SelectionCollection[0].ContainsOffset(offset))
{
offset = textArea.SelectionManager.SelectionCollection[0].Offset;
textArea.SelectionManager.RemoveSelectedText();
}
else
textArea.SelectionManager.ClearSelection();
textArea.Document.Insert(offset, text);
textArea.Caret.Position = textArea.Document.OffsetToPosition(offset + text.Length);
textArea.Refresh();
textArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.WholeTextArea));
}
finally
{
textArea.Document.UndoStack.EndUndoGroup();
textArea.EndUpdate();
}
}
示例3: Highlight
public static void Highlight(TextArea textArea)
{
try
{
int beg_off = -1;
int end_off = -1;
List<TextMarker> marks = markers[textArea] as List<TextMarker>;
if (marks == null)
{
marks = new List<TextMarker>();
markers[textArea] = marks;
}
RemoveMarkers(textArea);
string word = GetWordAtOffset(textArea, out beg_off, out end_off);
if (string.Compare(word, "begin", true) == 0 || highlighted_keywords[word] != null)
{
TmpPos end_pos = GetPositionOfEnd(textArea, end_off);
if (end_pos != null)
{
TextLocation Beg = textArea.Document.OffsetToPosition(beg_off);
TextLocation End = textArea.Document.OffsetToPosition(end_off);
TextMarker marker = new TextMarker(beg_off, word.Length, TextMarkerType.SolidBlock, System.Drawing.Color.FromArgb(219, 224, 204));
marker.WholeLine = false;
textArea.Document.MarkerStrategy.AddMarker(marker);
marks.Add(marker);
textArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, textArea.Document.GetLineNumberForOffset(beg_off)));
textArea.EndUpdate();
Beg = textArea.Document.OffsetToPosition(end_pos.start_pos);
End = textArea.Document.OffsetToPosition(end_pos.start_pos + end_pos.len);
marker = new TextMarker(end_pos.start_pos, end_pos.len, TextMarkerType.SolidBlock, System.Drawing.Color.FromArgb(219, 224, 204));
marker.WholeLine = false;
textArea.Document.MarkerStrategy.AddMarker(marker);
marks.Add(marker);
textArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, textArea.Document.GetLineNumberForOffset(end_pos.start_pos)));
textArea.EndUpdate();
textArea.Document.CommitUpdate();
}
}
else if (string.Compare(word, "end", true) == 0)
{
TmpPos beg_pos = GetPositionOfBegin(textArea, beg_off);
if (beg_pos != null)
{
TextLocation Beg = textArea.Document.OffsetToPosition(beg_off);
TextLocation End = textArea.Document.OffsetToPosition(end_off);
TextMarker marker = new TextMarker(beg_off, 3, TextMarkerType.SolidBlock, System.Drawing.Color.FromArgb(219, 224, 204));
marker.WholeLine = false;
textArea.Document.MarkerStrategy.AddMarker(marker);
marks.Add(marker);
textArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, textArea.Document.GetLineNumberForOffset(beg_off)));
textArea.EndUpdate();
Beg = textArea.Document.OffsetToPosition(beg_pos.start_pos);
End = textArea.Document.OffsetToPosition(beg_pos.start_pos + beg_pos.len);
marker = new TextMarker(beg_pos.start_pos, beg_pos.len, TextMarkerType.SolidBlock, System.Drawing.Color.FromArgb(219, 224, 204));
marker.WholeLine = false;
textArea.Document.MarkerStrategy.AddMarker(marker);
marks.Add(marker);
textArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, textArea.Document.GetLineNumberForOffset(beg_pos.start_pos)));
textArea.EndUpdate();
textArea.Document.CommitUpdate();
}
}
}
catch (Exception e)
{
}
}
示例4: RemoveMarkers
private static void RemoveMarkers(TextArea textArea)
{
//textArea.Document.MarkerStrategy.RemoveAll(remove_pred);
List<TextMarker> marks = markers[textArea] as List<TextMarker>;
if (marks != null)
{
foreach (TextMarker marker in marks)
{
try
{
textArea.Document.MarkerStrategy.RemoveMarker(marker);
textArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, textArea.Document.GetLineNumberForOffset(marker.Offset)));
textArea.EndUpdate();
}
catch
{
}
}
marks.Clear();
}
textArea.Document.CommitUpdate();
}