本文整理汇总了C#中UndoOperation.Reset方法的典型用法代码示例。如果您正苦于以下问题:C# UndoOperation.Reset方法的具体用法?C# UndoOperation.Reset怎么用?C# UndoOperation.Reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UndoOperation
的用法示例。
在下文中一共展示了UndoOperation.Reset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InsertWithCursorOnLayer
void InsertWithCursorOnLayer(EditorScript currentScript, InsertionCursorLayer layer, TaskCompletionSource<Script> tcs, IList<AstNode> nodes, IDocument target)
{
var doc = target as TextDocument;
var op = new UndoOperation(layer, tcs);
if (doc != null) {
doc.UndoStack.Push(op);
}
layer.Exited += delegate(object s, InsertionCursorEventArgs args) {
doc.UndoStack.StartContinuedUndoGroup();
try {
if (args.Success) {
if (args.InsertionPoint.LineAfter == NewLineInsertion.None &&
args.InsertionPoint.LineBefore == NewLineInsertion.None && nodes.Count > 1) {
args.InsertionPoint.LineAfter = NewLineInsertion.BlankLine;
}
foreach (var node in nodes.Reverse ()) {
int indentLevel = currentScript.GetIndentLevelAt(target.GetOffset(args.InsertionPoint.Location));
var output = currentScript.OutputNode(indentLevel, node);
var offset = target.GetOffset(args.InsertionPoint.Location);
var delta = args.InsertionPoint.Insert(target, output.Text);
output.RegisterTrackedSegments(currentScript, delta + offset);
}
tcs.SetResult(currentScript);
}
layer.Dispose();
DisposeOnClose();
} finally {
doc.UndoStack.EndUndoGroup();
}
op.Reset();
};
}
示例2: InsertWithCursorOnLayer
void InsertWithCursorOnLayer(EditorScript currentScript, InsertionCursorLayer layer, TaskCompletionSource<Script> tcs, IList<AstNode> nodes, IDocument target)
{
var doc = target as TextDocument;
var op = new UndoOperation(layer, tcs);
if (doc != null) {
doc.UndoStack.Push(op);
}
layer.ScrollToInsertionPoint();
layer.Exited += delegate(object s, InsertionCursorEventArgs args) {
doc.UndoStack.StartContinuedUndoGroup();
try {
if (args.Success) {
if (args.InsertionPoint.LineAfter == NewLineInsertion.None &&
args.InsertionPoint.LineBefore == NewLineInsertion.None && nodes.Count > 1) {
args.InsertionPoint.LineAfter = NewLineInsertion.BlankLine;
}
var insertionPoint = args.InsertionPoint;
if (nodes.All(n => n is EnumMemberDeclaration)) {
insertionPoint.LineAfter = NewLineInsertion.Eol;
insertionPoint.LineBefore = NewLineInsertion.None;
}
int offset = currentScript.GetCurrentOffset(insertionPoint.Location);
int indentLevel = currentScript.GetIndentLevelAt(Math.Max(0, offset - 1));
foreach (var node in nodes.Reverse()) {
var output = currentScript.OutputNode(indentLevel, node);
var text = output.Text;
if (node is EnumMemberDeclaration) {
if (insertionPoint != layer.InsertionPoints.Last()) {
text += ",";
} else {
var parentEnum = currentScript.context.RootNode.GetNodeAt(insertionPoint.Location, n => (n is TypeDeclaration) && ((TypeDeclaration)n).ClassType == ClassType.Enum) as TypeDeclaration;
if (parentEnum != null) {
var lastMember = parentEnum.Members.LastOrDefault();
if (lastMember != null) {
var segment = currentScript.GetSegment(lastMember);
currentScript.InsertText(segment.EndOffset, ",");
}
}
}
}
int delta = insertionPoint.Insert(target, text);
output.RegisterTrackedSegments(currentScript, delta + offset);
}
currentScript.FormatText(nodes);
tcs.SetResult(currentScript);
}
layer.Dispose();
DisposeOnClose();
} finally {
doc.UndoStack.EndUndoGroup();
}
op.Reset();
};
}