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


C# IDocument.OpenUndoGroup方法代码示例

本文整理汇总了C#中IDocument.OpenUndoGroup方法的典型用法代码示例。如果您正苦于以下问题:C# IDocument.OpenUndoGroup方法的具体用法?C# IDocument.OpenUndoGroup怎么用?C# IDocument.OpenUndoGroup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDocument的用法示例。


在下文中一共展示了IDocument.OpenUndoGroup方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SortLines

		public void SortLines(IDocument document, int startLine, int endLine, StringComparer comparer, bool removeDuplicates)
		{
			List<string> lines = new List<string>();
			for (int i = startLine; i <= endLine; ++i) {
				IDocumentLine line = document.GetLine(i);
				lines.Add(document.GetText(line.Offset, line.Length));
			}
			
			lines.Sort(comparer);
			
			if (removeDuplicates) {
				lines = lines.Distinct(comparer).ToList();
			}
			
			using (document.OpenUndoGroup()) {
				for (int i = 0; i < lines.Count; ++i) {
					IDocumentLine line = document.GetLine(startLine + i);
					document.Replace(line.Offset, line.Length, lines[i]);
				}
				
				// remove removed duplicate lines
				for (int i = startLine + lines.Count; i <= endLine; ++i) {
					IDocumentLine line = document.GetLine(startLine + lines.Count);
					document.Remove(line.Offset, line.TotalLength);
				}
			}
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:27,代码来源:SortSelectionCommand.cs

示例2: DocumentScript

		public DocumentScript(IDocument document, CSharpFormattingOptions formattingOptions, TextEditorOptions options) : base(formattingOptions, options)
		{
			this.originalDocument = document.CreateDocumentSnapshot();
			this.currentDocument = document;
			Debug.Assert(currentDocument.Version.CompareAge(originalDocument.Version) == 0);
			this.undoGroup = document.OpenUndoGroup();
		}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:7,代码来源:DocumentScript.cs

示例3: SwapText

		/// <summary>
		/// Swaps 2 ranges of text in a document.
		/// </summary>
		static void SwapText(IDocument document, Location start1, Location end1, Location start2, Location end2)
		{
			if (start1 > start2) {
				Location sw;
				sw = start1; start1 = start2; start2 = sw;
				sw = end1; end1 = end2; end2 = sw;
			}
			if (end1 >= start2)
				throw new InvalidOperationException("Cannot swap overlaping segments");
			int offset1 = document.PositionToOffset(start1);
			int len1 = document.PositionToOffset(end1) - offset1;
			int offset2 = document.PositionToOffset(start2);
			int len2 = document.PositionToOffset(end2) - offset2;
			
			string text1 = document.GetText(offset1, len1);
			string text2 = document.GetText(offset2, len2);
			
			using (var undoGroup = document.OpenUndoGroup()) {
				document.Replace(offset2, len2, text1);
				document.Replace(offset1, len1, text2);
			}
		}
开发者ID:hpsa,项目名称:SharpDevelop,代码行数:25,代码来源:CodeManipulation.cs

示例4: ModifyDocument

		public static void ModifyDocument(List<Modification> modifications, IDocument doc, int offset, int length, string newName)
		{
			using (doc.OpenUndoGroup()) {
				foreach (Modification m in modifications) {
					if (m.Document == doc) {
						if (m.Offset < offset)
							offset += m.LengthDifference;
					}
				}
				int lengthDifference = newName.Length - length;
				doc.Replace(offset, length, newName);
				if (lengthDifference != 0) {
					for (int i = 0; i < modifications.Count; ++i) {
						Modification m = modifications[i];
						if (m.Document == doc) {
							if (m.Offset > offset) {
								m.Offset += lengthDifference;
								modifications[i] = m; // Modification is a value type
							}
						}
					}
					modifications.Add(new Modification(doc, offset, lengthDifference));
				}
			}
		}
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:25,代码来源:FindReferencesAndRenameHelper.cs

示例5: Apply

 public void Apply(IDocument document)
 {
     using (document.OpenUndoGroup()) {
         var changes = oldVersion.GetChangesTo(newVersion);
         foreach (var change in changes)
             document.Replace(change.Offset, change.RemovalLength, change.InsertedText);
     }
 }
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:8,代码来源:SearchResultMatch.cs

示例6: Insert

		public int Insert (IDocument document, string text)
		{
			int offset = document.GetOffset (Location);
			using (var undo = document.OpenUndoGroup ()) {
				text = DocumentUtilities.NormalizeNewLines(text, document, Location.Line);
				
				var line = document.GetLineByOffset (offset);
				int insertionOffset = line.Offset + Location.Column - 1;
				offset = insertionOffset;
				InsertNewLine (document, LineBefore, ref offset);
				
				document.Insert (offset, text);
				offset += text.Length;
				InsertNewLine (document, LineAfter, ref offset);
				return offset;
			}
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:17,代码来源:InsertionPoint.cs


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