当前位置: 首页>>代码示例>>C#>>正文


C# UndoOperation.Reset方法代码示例

本文整理汇总了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();
			};
		}
开发者ID:kristjan84,项目名称:SharpDevelop,代码行数:32,代码来源:EditorScript.cs

示例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();
			};
		}
开发者ID:linquize,项目名称:SharpDevelop,代码行数:57,代码来源:EditorScript.cs


注:本文中的UndoOperation.Reset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。