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


C# NormalizedSnapshotSpanCollection类代码示例

本文整理汇总了C#中NormalizedSnapshotSpanCollection的典型用法代码示例。如果您正苦于以下问题:C# NormalizedSnapshotSpanCollection类的具体用法?C# NormalizedSnapshotSpanCollection怎么用?C# NormalizedSnapshotSpanCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: DrawChanges

		private void DrawChanges(DrawingContext drawingContext, NormalizedSnapshotSpanCollection changes, Brush brush)
		{
			if (changes.Count > 0)
			{
				double yTop = Math.Floor(_scrollBar.GetYCoordinateOfBufferPosition(changes[0].Start)) + markerStartOffset;
				double yBottom = Math.Ceiling(_scrollBar.GetYCoordinateOfBufferPosition(changes[0].End)) + markerEndOffset;

				for (int i = 1; i < changes.Count; ++i)
				{
					double y = _scrollBar.GetYCoordinateOfBufferPosition(changes[i].Start) + markerStartOffset;
					if (yBottom < y)
					{
						drawingContext.DrawRectangle(
							brush,
							null,
							new Rect(0, yTop, markerWidth, yBottom - yTop));

						yTop = y;
					}

					yBottom = Math.Ceiling(_scrollBar.GetYCoordinateOfBufferPosition(changes[i].End)) + markerEndOffset;
				}

				drawingContext.DrawRectangle(
					brush,
					null,
					new Rect(0, yTop, markerWidth, yBottom - yTop));
			}
		}
开发者ID:jburrow,项目名称:progressive-scroll,代码行数:29,代码来源:ChangeRenderer.cs

示例2: UncommentSpans

        public NormalizedSnapshotSpanCollection UncommentSpans(NormalizedSnapshotSpanCollection spans)
        {
            Contract.Requires<ArgumentNullException>(spans != null, "spans");
            Contract.Ensures(Contract.Result<NormalizedSnapshotSpanCollection>() != null);

            throw new NotImplementedException();
        }
开发者ID:chandramouleswaran,项目名称:LangSvcV2,代码行数:7,代码来源:ICommenterContracts.cs

示例3: GetOverarchingSpan2

 public void GetOverarchingSpan2()
 {
     var spans = new NormalizedSnapshotSpanCollection();
     _selection.SetupGet(x => x.SelectedSpans).Returns(spans).Verifiable();
     Assert.True(TextSelectionUtil.GetOverarchingSelectedSpan(_selection.Object).IsNone());
     _selection.Verify();
 }
开发者ID:aesire,项目名称:VsVim,代码行数:7,代码来源:TextSelectionUtilTest.cs

示例4: FormattedStringBuilderEndToEnd1

        public void FormattedStringBuilderEndToEnd1()
        {
            var classificationFormatMap = new MockClassificationFormatMap();
            var htmlMarkupProvider = new HtmlMarkupProvider(
                classificationFormatMap,
                MockClassificationType.Default,
                Brushes.White);
            var classifier = new MockClassifier();

            var formattedStringBuilder = new FormattedStringBuilder(
                htmlMarkupProvider,
                classifier,
                MockClassificationType.Default,
                waitIndicator: null);

            var snapshot = new MockTextSnapshot("bla");
            var spans = new NormalizedSnapshotSpanCollection(new []
            {
                new SnapshotSpan(snapshot, 0, 3)
            });

            var actualResult = formattedStringBuilder.AppendSnapshotSpans(spans);
            var expectedResult = "<pre style=\"font-family:Consolas;font-size:12;color:black;background:white;\">b<span style=\"color:blue;\">l</span>a\r\n</pre>";

            Assert.AreEqual(expectedResult, actualResult);
        }
开发者ID:xornand,项目名称:VS-PPT,代码行数:26,代码来源:FormattedStringBuilderTests.cs

示例5: Add

		public void Add(ISynchronousClassifier classifier, NormalizedSnapshotSpanCollection spans, CancellationToken cancellationToken) {
			if (classifier == null)
				throw new ArgumentNullException(nameof(classifier));
			if (spans == null)
				throw new ArgumentNullException(nameof(spans));
			foreach (var span in spans) {
				if (spansCount > 0)
					htmlWriter.WriteRaw(delimiter);
				spansCount++;
				var tagSpans = classifier.GetClassificationSpans(span, cancellationToken);
				var text = span.GetText();
				int pos = span.Start.Position;
				foreach (var tagSpan in tagSpans) {
					if (pos < tagSpan.Span.Start) {
						WriteCss(classificationFormatMap.DefaultTextProperties);
						htmlWriter.WriteSpan(cssWriter.ToString(), text, pos - span.Start.Position, tagSpan.Span.Start.Position - pos);
					}
					WriteCss(classificationFormatMap.GetTextProperties(tagSpan.ClassificationType));
					htmlWriter.WriteSpan(cssWriter.ToString(), text, tagSpan.Span.Start - span.Start.Position, tagSpan.Span.Length);
					pos = tagSpan.Span.End;
				}
				if (pos < span.End) {
					WriteCss(classificationFormatMap.DefaultTextProperties);
					htmlWriter.WriteSpan(cssWriter.ToString(), text, pos - span.Start.Position, span.End.Position - pos);
				}
			}
		}
开发者ID:manojdjoshi,项目名称:dnSpy,代码行数:27,代码来源:HtmlBuilder.cs

示例6: GenerateHtmlFragmentCore

		string GenerateHtmlFragmentCore(NormalizedSnapshotSpanCollection spans, ITextView textView, string delimiter, CancellationToken cancellationToken) {
			ISynchronousClassifier classifier = null;
			try {
				int tabSize;
				IClassificationFormatMap classificationFormatMap;
				if (textView != null) {
					classifier = synchronousViewClassifierAggregatorService.GetSynchronousClassifier(textView);
					classificationFormatMap = classificationFormatMapService.GetClassificationFormatMap(textView);
					tabSize = textView.Options.GetTabSize();
				}
				else {
					classifier = spans.Count == 0 ? null : synchronousClassifierAggregatorService.GetSynchronousClassifier(spans[0].Snapshot.TextBuffer);
					classificationFormatMap = classificationFormatMapService.GetClassificationFormatMap(AppearanceCategoryConstants.TextEditor);
					tabSize = defaultTabSize;
				}
				tabSize = OptionsHelpers.FilterTabSize(tabSize);

				var builder = new HtmlBuilder(classificationFormatMap, delimiter, tabSize);
				if (spans.Count != 0)
					builder.Add(classifier, spans, cancellationToken);
				return builder.Create();
			}
			finally {
				(classifier as IDisposable)?.Dispose();
			}
		}
开发者ID:manojdjoshi,项目名称:dnSpy,代码行数:26,代码来源:HtmlBuilderService.cs

示例7: CalculateForBlock3

 public void CalculateForBlock3()
 {
     var buffer = EditorUtil.CreateBuffer("dog", "cat", "chicken");
     var col = new NormalizedSnapshotSpanCollection(buffer.GetSpan(0, 2));
     var span = _calcRaw.CalculateForBlock(buffer.GetLine(1).Start.Add(1), col);
     Assert.IsTrue(span.IsMultiple);
     Assert.AreEqual(buffer.GetLine(1).Start.Add(1).GetSpan(2), span.AsMultiple().Item2[0]);
 }
开发者ID:rride,项目名称:VsVim,代码行数:8,代码来源:VisualSpanCalculatorTest.cs

示例8: GenerateHtmlFragment

		public string GenerateHtmlFragment(NormalizedSnapshotSpanCollection spans, string delimiter, CancellationToken cancellationToken) {
			if (spans == null)
				throw new ArgumentNullException(nameof(spans));
			if (delimiter == null)
				throw new ArgumentNullException(nameof(delimiter));

			return GenerateHtmlFragmentCore(spans, null, delimiter, cancellationToken);
		}
开发者ID:manojdjoshi,项目名称:dnSpy,代码行数:8,代码来源:HtmlBuilderService.cs

示例9: GetTags

        private static IEnumerable<ITagSpan<OutliningRegionTag>> GetTags(string input)
        {
            var buffer = new FakeTextBuffer(input);
            var tagger = new TemplateOutliningTagger(buffer);

            var snapshotSpans = new NormalizedSnapshotSpanCollection(new SnapshotSpan(buffer.CurrentSnapshot, 0, buffer.CurrentSnapshot.Length));
            return tagger.GetTags(snapshotSpans);
        }
开发者ID:icool123,项目名称:T4Toolbox,代码行数:8,代码来源:TemplateOutliningTaggerTest.cs

示例10: GetOverarchingSpan3

 public void GetOverarchingSpan3()
 {
     var buffer = CreateTextBuffer("foo bar");
     var span = buffer.GetLineRange(0).Extent;
     var col = new NormalizedSnapshotSpanCollection(span);
     _selection.SetupGet(x => x.SelectedSpans).Returns(col).Verifiable();
     Assert.Equal(span, TextSelectionUtil.GetOverarchingSelectedSpan(_selection.Object).Value);
     _selection.Verify();
 }
开发者ID:aesire,项目名称:VsVim,代码行数:9,代码来源:TextSelectionUtilTest.cs

示例11: GetOverarchingSpan4

 public void GetOverarchingSpan4()
 {
     var buffer = CreateTextBuffer("foo", "baz", "bar");
     var span1 = buffer.GetLineRange(0).Extent;
     var span2 = buffer.GetLineRange(0, 1).Extent;
     var col = new NormalizedSnapshotSpanCollection(new SnapshotSpan[] { span1, span2 });
     _selection.SetupGet(x => x.SelectedSpans).Returns(col).Verifiable();
     Assert.AreEqual(buffer.GetLineRange(0, 1).Extent, TextSelectionUtil.GetOverarchingSelectedSpan(_selection.Object).Value);
     _selection.Verify();
 }
开发者ID:bajtos,项目名称:VsVim,代码行数:10,代码来源:TextSelectionUtilTest.cs

示例12: GetTagsReturnsErrorSpanForSemanticError

        public static void GetTagsReturnsErrorSpanForSemanticError()
        {
            var buffer = new FakeTextBuffer("<#@ include file=\" \" #>");
            var tagger = new TemplateErrorTagger(buffer);

            var snapshotSpans = new NormalizedSnapshotSpanCollection(new SnapshotSpan(buffer.CurrentSnapshot, 0, buffer.CurrentSnapshot.Length));
            ITagSpan<ErrorTag> errorSpan = tagger.GetTags(snapshotSpans).Single();

            Assert.Equal(new Span(12, 8), errorSpan.Span);
            Assert.Contains("File", (string)errorSpan.Tag.ToolTipContent, StringComparison.OrdinalIgnoreCase);
        }
开发者ID:icool123,项目名称:T4Toolbox,代码行数:11,代码来源:TemplateErrorTaggerTest.cs

示例13: ShouldClassifyScenario

 public void ShouldClassifyScenario()
 {
     TestInitialise("Features/gherkin.feature");
     var snapShotSpan = new SnapshotSpan(new MockTextSnapshot(featureFileContent), new Span(0, 15));
     var spanCollection = new NormalizedSnapshotSpanCollection(new[] { snapShotSpan });
     var tags = playTagger.GetTags(spanCollection);
     var tag = tags.First(_ => _.Span.GetText().StartsWith("  Scenario: SC2")).Tag;
     Assert.AreEqual("Scenario: SC2" + Environment.NewLine +
                     "  Given something" + Environment.NewLine +
                     "  When some event occurs" + Environment.NewLine +
                     "  Then there is some outcome", tag.GetText());
 }
开发者ID:AngelPortal,项目名称:NBehave,代码行数:12,代码来源:PlayTaggerSpec.cs

示例14: IsComment

        private static bool IsComment(SnapshotPoint position)
        {
            if (position.Position < 2)
                return false;

            var tagger = position.Snapshot.TextBuffer.Properties.GetProperty<ITagger<ClassificationTag>>(jsTaggerType);

            Span span = Span.FromBounds(position.Position - 1, position.Position);
            var spans = new NormalizedSnapshotSpanCollection(new SnapshotSpan(position.Snapshot, span));
            var classifications = tagger.GetTags(spans);

            return classifications.Any(c => c.Tag.ClassificationType.IsOfType("comment"));
        }
开发者ID:venux,项目名称:WebEssentials2015,代码行数:13,代码来源:JsDocCompletionSource.cs

示例15: CreateElisionBufferWithoutIndentation

        public static IElisionBuffer CreateElisionBufferWithoutIndentation(
            this IProjectionBufferFactoryService factoryService,
            IEditorOptions editorOptions,
            IContentType contentType,
            IEnumerable<SnapshotSpan> exposedSpans)
        {
            var spans = new NormalizedSnapshotSpanCollection(exposedSpans);

            if (spans.Count > 0)
            {
                // BUG(6335): We have to make sure that the spans refer to the current snapshot of
                // the buffer.
                var buffer = spans.First().Snapshot.TextBuffer;
                var currentSnapshot = buffer.CurrentSnapshot;
                spans = new NormalizedSnapshotSpanCollection(
                    spans.Select(s => s.TranslateTo(currentSnapshot, SpanTrackingMode.EdgeExclusive)));
            }

            contentType = contentType ?? factoryService.ProjectionContentType;
            var elisionBuffer = factoryService.CreateElisionBuffer(
                null, spans, ElisionBufferOptions.None, contentType);

            if (spans.Count > 0)
            {
                var snapshot = spans.First().Snapshot;
                var buffer = snapshot.TextBuffer;

                // We need to figure out the shorted indentation level of the exposed lines.  We'll
                // then remove that indentation from all lines.
                var indentationColumn = DetermineIndentationColumn(editorOptions, spans);

                var spansToElide = new List<Span>();

                foreach (var span in spans)
                {
                    var startLineNumber = snapshot.GetLineNumberFromPosition(span.Start);
                    var endLineNumber = snapshot.GetLineNumberFromPosition(span.End);

                    for (var lineNumber = startLineNumber; lineNumber <= endLineNumber; lineNumber++)
                    {
                        var line = snapshot.GetLineFromLineNumber(lineNumber);
                        var lineOffsetOfColumn = line.GetLineOffsetFromColumn(indentationColumn, editorOptions);
                        spansToElide.Add(Span.FromBounds(line.Start, line.Start + lineOffsetOfColumn));
                    }
                }

                elisionBuffer.ElideSpans(new NormalizedSpanCollection(spansToElide));
            }

            return elisionBuffer;
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:51,代码来源:IProjectionBufferFactoryServiceExtensions.cs


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