本文整理汇总了C#中ICSharpCode.TextEditor.TextArea.BeginUpdate方法的典型用法代码示例。如果您正苦于以下问题:C# TextArea.BeginUpdate方法的具体用法?C# TextArea.BeginUpdate怎么用?C# TextArea.BeginUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICSharpCode.TextEditor.TextArea
的用法示例。
在下文中一共展示了TextArea.BeginUpdate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
}