• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# SnapshotSpan类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: CreateAndAddAdornment

        void CreateAndAddAdornment(ITextViewLine line, SnapshotSpan span, Brush brush, bool extendToRight)
        {
            var markerGeometry = _view.TextViewLines.GetMarkerGeometry(span);

            double left = 0;
            double width = _view.ViewportWidth + _view.MaxTextRightCoordinate;
            if (markerGeometry != null)
            {
                left = markerGeometry.Bounds.Left;
                if (!extendToRight) width = markerGeometry.Bounds.Width;
            }

            Rect rect = new Rect(left, line.Top, width, line.Height);

            RectangleGeometry geometry = new RectangleGeometry(rect);

            GeometryDrawing drawing = new GeometryDrawing(brush, new Pen(), geometry);
            drawing.Freeze();

            DrawingImage drawingImage = new DrawingImage(drawing);
            drawingImage.Freeze();

            Image image = new Image();
            image.Source = drawingImage;

            Canvas.SetLeft(image, geometry.Bounds.Left);
            Canvas.SetTop(image, geometry.Bounds.Top);

            _layer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, null, image, null);
        }
开发者ID:ijprest,项目名称:BackgroundColorFix,代码行数:30,代码来源:BackgroundColorVisualManager.cs


示例2: HasSuggestedActionsAsync

 public Task<bool> HasSuggestedActionsAsync(ISuggestedActionCategorySet requestedActionCategories, SnapshotSpan range, CancellationToken cancellationToken)
 {
     return Task.Factory.StartNew(() =>
     {
         return !_view.Selection.IsEmpty;
     });
 }
开发者ID:xoofx,项目名称:MarkdownEditor,代码行数:7,代码来源:SuggestedActionsSource.cs


示例3: EnterSelect

 protected void EnterSelect(int start, int length)
 {
     var span = new SnapshotSpan(_textBuffer.CurrentSnapshot, start, length);
     _textView.SelectAndMoveCaret(span);
     _context.RunAll();
     Assert.Equal(ModeKind.SelectCharacter, _vimBuffer.ModeKind);
 }
开发者ID:Yzzl,项目名称:VsVim,代码行数:7,代码来源:SelectModeIntegrationTest.cs


示例4: GetClassificationSpans

        public IList<ClassificationSpan> GetClassificationSpans(SnapshotSpan span)
        {
            IList<ClassificationSpan> spans = new List<ClassificationSpan>();

            string text = span.GetText();
            int index = text.IndexOf("#", StringComparison.Ordinal);

            if (index > -1)
            {
                var result = new SnapshotSpan(span.Snapshot, span.Start + index, text.Length - index);
                spans.Add(new ClassificationSpan(result, comment));
            }

            if (index == -1 || index > 0)
            {
                var trimmed = text.TrimStart();
                var offset = text.Length - trimmed.Length;
                string[] args = trimmed.Split(' ');

                if (args.Length >= 2 && ValidKeywords.Contains(args[0].Trim().ToLowerInvariant()))
                {
                    var result = new SnapshotSpan(span.Snapshot, span.Start + offset, args[0].Trim().Length);
                    spans.Add(new ClassificationSpan(result, keyword));
                }
            }

            return spans;
        }
开发者ID:freeman,项目名称:Paket.VisualStudio,代码行数:28,代码来源:PaketDependenciesClassifier.cs


示例5: GetSuggestedActions

            public IEnumerable<SuggestedActionSet> GetSuggestedActions(ISuggestedActionCategorySet requestedActionCategories, SnapshotSpan range, CancellationToken cancellationToken)
            {
                return
                    (
                        // code fixes
                        from tagSpan in _aggregator.GetTags(range)
                        where tagSpan.Tag is DiagnosticErrorTag
                        let diagnostic = tagSpan.Tag as DiagnosticErrorTag

                        from provider in _codeFixProviders
                        where provider.CanFix(diagnostic.Id)
                        let span = tagSpan.Span.GetSpans(_buffer).First()

                        from fix in provider.GetFixes(span)

                        group fix by provider into set
                        where set.Any()
                        select set as IEnumerable<CodeAction>
                    ).Union(
                        // code refactorings
                        from provider in _refactoringProviders
                        from refactoring in provider.GetRefactorings(range)

                        group refactoring by provider into set
                        where set.Any()
                        select set as IEnumerable<CodeAction>
                    )
                    .Select(s => s.Select(ca => ca.ToSuggestedAction()))
                    .Select(s => new SuggestedActionSet(s))
                ;
            }
开发者ID:Peter-Juhasz,项目名称:RegistryLanguageService,代码行数:31,代码来源:RegistrySuggestedActions.cs


示例6: TranslationAdornment

        public TranslationAdornment(SnapshotSpan span, TranslationRequest request, Size viewportSize)
        {
            Span = span.Snapshot.CreateTrackingSpan(span, SpanTrackingMode.EdgeExclusive);
            Request = request;
            Request.TranslationComplete += request_TranslationComplete;

            InitializeComponent();
            DataContext = this;

            SetMaxSize(viewportSize);

            _menu = spListBox.ContextMenu;
            _menu.KeyUp += (sender, args) =>
            {
                if (args.Key == Key.Left || args.Key == Key.Escape)
                {
                    CloseMenu();
                }
            };
            _menu.Opened += (sender, args) => { _closeMenuRequested = false; };
            _menu.Closed += (sender, args) => { _ignoreItemCommand = !_closeMenuRequested; };

            ItemCommand = new RelayCommand<ItemCommandParameter>(ItemCommandExecute);
            ItemOptionsCommand = new RelayCommand<ItemCommandParameter>(ItemOptionsCommandExecute);
            MenuCommand = new RelayCommand<MenuItem>(MenuCommandExecute);
        }
开发者ID:julianpaulozzi,项目名称:VSNewTranslator,代码行数:26,代码来源:TranslationAdornment.xaml.cs


示例7: AugmentSignatureHelpSession

        public void AugmentSignatureHelpSession(ISignatureHelpSession session, IList<ISignature> signatures)
        {
            if (!session.TextView.Properties.ContainsProperty(SessionKey))
            {
                return;
            }

            // At the moment there is a bug in the javascript provider which causes it to
            // repeatedly insert the same Signature values into an ISignatureHelpSession
            // instance.  There is no way, other than reflection, for us to prevent this
            // from happening.  Instead we just ensure that our provider runs after
            // Javascript and then remove the values they add here
            signatures.Clear();

            // Map the trigger point down to our buffer.
            var subjectTriggerPoint = session.GetTriggerPoint(subjectBuffer.CurrentSnapshot);
            if (!subjectTriggerPoint.HasValue)
            {
                return;
            }

            var currentSnapshot = subjectTriggerPoint.Value.Snapshot;
            var querySpan = new SnapshotSpan(subjectTriggerPoint.Value, 0);
            var applicableToSpan = currentSnapshot.CreateTrackingSpan(
                querySpan.Start.Position,
                0,
                SpanTrackingMode.EdgeInclusive);

            string encouragement = encouragements.GetRandomEncouragement();
            if (encouragement != null)
            {
                var signature = new Signature(applicableToSpan, encouragement, "", "");
                signatures.Add(signature);
            }
        }
开发者ID:RC1140,项目名称:Encourage,代码行数:35,代码来源:EncourageSignatureHelpSource.cs


示例8: ReplSpan

 public ReplSpan(bool wasCommand, bool wasException, SnapshotSpan input, SnapshotSpan? output)
 {
     WasCommand = wasCommand;
     WasException = wasException;
     Input = input;
     Output = output;
 }
开发者ID:TerabyteX,项目名称:main,代码行数:7,代码来源:ReplSpan.cs


示例9: IsPreceededByEventAddSyntax

        /// <summary>
        /// Is the provided SnapshotPoint preceded by the '+= SomeEventType(Some_HandlerName' line
        /// </summary>
        private bool IsPreceededByEventAddSyntax(SnapshotSpan span)
        {
            // First find the last + character
            var snapshot = span.Snapshot;
            SnapshotPoint? plusPoint = null;
            for (int i = span.Length - 1; i >= 0; i--)
            {
                var position = span.Start.Position + i;
                var point = new SnapshotPoint(snapshot, position);
                if (point.GetChar() == '+')
                {
                    plusPoint = point;
                    break;
                }
            }

            if (plusPoint == null)
            {
                return false;
            }

            var eventSpan = new SnapshotSpan(plusPoint.Value, span.End);
            var eventText = eventSpan.GetText();
            return 
                s_fullEventSyntaxRegex.IsMatch(eventText) ||
                s_shortEventSyntaxRegex.IsMatch(eventText);
        }
开发者ID:aesire,项目名称:VsVim,代码行数:30,代码来源:CSharpAdapter.cs


示例10: IsEventAddSelection

        /// <summary>
        /// Is the current selection that of the C# event add pattern?
        /// </summary>
        internal bool IsEventAddSelection(ITextView textView)
        {
            var textSelection = textView.Selection;
            if (textSelection.IsEmpty || textSelection.Mode != TextSelectionMode.Stream)
            {
                return false;
            }

            var span = textView.Selection.StreamSelectionSpan.SnapshotSpan;

            var lineRange = SnapshotLineRangeUtil.CreateForSpan(span);
            if (lineRange.Count != 1)
            {
                return false;
            }

            // Include the character after the selection.  Needed to disambiguate a couple
            // of cases
            var endPoint = span.End;
            if (endPoint.Position < lineRange.End.Position)
            {
                endPoint = endPoint.Add(1);
            }

            var beforeSpan = new SnapshotSpan(lineRange.Start, endPoint);
            return IsPreceededByEventAddSyntax(beforeSpan);
        }
开发者ID:aesire,项目名称:VsVim,代码行数:30,代码来源:CSharpAdapter.cs


示例11: GetAllTags

 private IEnumerable<SnapshotSpan> GetAllTags()
 {
     var snapshot = _textView.TextBuffer.CurrentSnapshot;
     var snapshotSpan = new SnapshotSpan(snapshot, 0, snapshot.Length);
     var tags = GetTags(snapshotSpan);
     return tags;
 }
开发者ID:tgjones,项目名称:HlslTools,代码行数:7,代码来源:HighlightingNavigationManager.cs


示例12: CalculateDeletionStartFromStartPosition

        private static int CalculateDeletionStartFromStartPosition(ITextSnapshot snapshot, int startPosition)
        {
            var position = startPosition - 1;

            if (position < 0)
            {
                return 0;
            }

            while (true)
            {
                if (position > 0)
                {
                    var ss = new SnapshotSpan(snapshot, position, 1);
                    var text = ss.GetText();

                    if (text != null && !"\r\n".Contains(text) && string.IsNullOrWhiteSpace(text))
                    {
                        --position;
                        continue;
                    }

                    ++position;
                }

                return position;
            }
        }
开发者ID:NickCraver,项目名称:WebEssentials2013,代码行数:28,代码来源:RemoveCssRuleSmartTagAction.cs


示例13: GetClassificationSpans

        public IList<ClassificationSpan> GetClassificationSpans(SnapshotSpan span)
        {
            var results = new List<ClassificationSpan>();
            var snapshot = Buffer.CurrentSnapshot;
            var stylesheet = Editor.Document.Stylesheet;

            if (stylesheet != null)
            {
                try
                {
                    foreach (var current in GetItems(stylesheet.Children, span))
                    {
                        if (current.Start > span.End)
                            break;

                        var type = ClassifierContextCache.Get(current.ClassifierType).GetClassification(Registry);
                        if (type == null)
                            continue;

                        var start = Math.Max(0, current.Start);
                        var length = Math.Min(snapshot.Length - start, current.Length);
                        results.Add(new ClassificationSpan(new SnapshotSpan(snapshot, new Span(start, length)), type));
                    }
                }
                catch (Exception ex)
                {
                    Logger.Log(ex, "Failed to classify");
                }
            }

            return results;
        }
开发者ID:kissYou,项目名称:SassyStudio,代码行数:32,代码来源:SassClassifier.cs


示例14: GetClassificationSpans

        public IList<ClassificationSpan> GetClassificationSpans(SnapshotSpan span)
        {
            IList<ClassificationSpan> list = new List<ClassificationSpan>();

            string text = span.GetText();

            if (text.StartsWith("/// <binding"))
            {
                foreach (Match match in _binding.Matches(text))
                {
                    var value = match.Groups["value"];
                    var result = new SnapshotSpan(span.Snapshot, span.Start + value.Index, value.Length);
                    list.Add(new ClassificationSpan(result, _formatDefinition));
                }                
            }
            else
            {
                int index = text.IndexOf(_searchText, StringComparison.Ordinal);

                if (index == -1)
                    return list;

                foreach (Match match in _task.Matches(text))
                {
                    var name = match.Groups["name"];
                    var result = new SnapshotSpan(span.Snapshot, span.Start + name.Index, name.Length);
                    list.Add(new ClassificationSpan(result, _formatDefinition));
                }
            }

            return list;
        }
开发者ID:venux,项目名称:WebEssentials2015,代码行数:32,代码来源:TaskClassifier.cs


示例15: GetClassificationSpans

        public IList<ClassificationSpan> GetClassificationSpans(SnapshotSpan span) {
            var result = new List<ClassificationSpan>();
            
            var semanticModelResult = SemanticModelService.SemanticModelResult;
            if(semanticModelResult == null) {
                return result;
            }

            var classificationType = ClassificationTypeRegistryService.GetClassificationType(ClassificationTypeNames.DeadCode);

            var extent      = TextExtent.FromBounds(span.Start.Position, span.End.Position);
            var diagnostics = semanticModelResult.CompilationUnit.Diagnostics;
            var candidates  = diagnostics.Where(diagnostic => diagnostic.Category == DiagnosticCategory.DeadCode)
                                         .Where(d => d.Location.Extent.IntersectsWith(extent)); 

            foreach (var diagnostic in candidates) {
                var diagnosticSpan = new SnapshotSpan(semanticModelResult.Snapshot, new Span(diagnostic.Location.Start, diagnostic.Location.Length));

                var classification = new ClassificationSpan(
                        diagnosticSpan.TranslateTo(span.Snapshot, SpanTrackingMode.EdgeExclusive),
                        classificationType);


                result.Add(classification);
            }
            
            return result;
        }
开发者ID:csharper2010,项目名称:Nav.Language.Extensions,代码行数:28,代码来源:SemanticClassifier.cs


示例16: ExternalEditMarker

 internal ExternalEditMarker(
     ExternalEditKind kind,
     SnapshotSpan span)
 {
     ExternalEditKind = kind;
     Span = span;
 }
开发者ID:rschatz,项目名称:VsVim,代码行数:7,代码来源:ExternalEditMarker.cs


示例17: CalculateDeletionEndFromRuleEndPosition

        private static int CalculateDeletionEndFromRuleEndPosition(ITextSnapshot snapshot, int endPosition)
        {
            var position = endPosition;
            var committedPosition = position;

            while (true)
            {
                if (position < snapshot.Length)
                {
                    var ss = new SnapshotSpan(snapshot, position, 1);
                    var text = ss.GetText();

                    if (text != null)
                    {
                        if ("\r\n".Contains(text))
                        {
                            committedPosition = ++position;
                            continue;
                        }

                        if (string.IsNullOrWhiteSpace(text))
                        {
                            ++position;
                            continue;
                        }
                    }
                }

                return committedPosition;
            }
        }
开发者ID:Russe11,项目名称:WebEssentials2013,代码行数:31,代码来源:RemoveCssRuleSmartTagAction.cs


示例18: GetClassificationSpans

        // This does not work properly for multiline fenced code-blocks,
        // since we get each line separately.  If I can assume that this
        // always runs sequentially without skipping, I can add state to
        // track whether we're in a fenced block.
        public IList<ClassificationSpan> GetClassificationSpans(SnapshotSpan span)
        {
            string text = span.GetText();

            var codeBlocks = FindMatches(span, text, _reCode, _code).ToList();

            if (codeBlocks.Any())
            {
                // Flatten all code blocks to avoid matching text within them
                var nonCodeBuilder = text.ToCharArray();
                foreach (var code in codeBlocks)
                {
                    for (int i = code.Span.Start; i < code.Span.End; i++)
                    {
                        nonCodeBuilder[i - span.Start] = 'Q';
                    }
                }
                text = new String(nonCodeBuilder);
            }

            var quotes = FindMatches(span, text, _reQuote, _quote);
            var bolds = FindMatches(span, text, _reBold, _bold);
            var italics = FindMatches(span, text, _reItalic, _italic);
            var headers = FindMatches(span, text, _reHeader, _header);

            return bolds.Concat(italics).Concat(headers).Concat(codeBlocks).Concat(quotes).ToList();
        }
开发者ID:LogoPhonix,项目名称:WebEssentials2012,代码行数:31,代码来源:MarkdownClassifier.cs


示例19: DoGetClassificationSpans

		private IList<ClassificationSpan> DoGetClassificationSpans(SnapshotSpan span)
		{
			List<ClassificationSpan> spans = null;

			object prop;
			if (span.Snapshot.TextBuffer.Properties.TryGetProperty(typeof(ITextDocument), out prop))
			{
				var doc = (ITextDocument)prop;
				string fileName = System.IO.Path.GetFileName(doc.FilePath);
				Language lang = Languages.FindLanguage(fileName);

				if (lang != null)
				{
					List<ClassificationSpan> strings = new List<ClassificationSpan>();
					List<ClassificationSpan> comments = new List<ClassificationSpan>();
					DoGetStringSpans(lang, span, strings, comments);

					spans = new List<ClassificationSpan>();
					if (!strings.Any(s => s.Span.Contains(span) && !comments.Any(t => t.Span.Contains(span))))
					{
						IEnumerable<ClassificationSpan> mine = lang.GetClassificationSpans(span);
						spans.AddRange(from c in mine where !strings.Any(d => d.Span.OverlapsWith(c.Span)) && !comments.Any(d => d.Span.OverlapsWith(c.Span)) select c);
					}
					spans.AddRange(strings);
					spans.AddRange(comments);
				}
			}

			return spans ?? ms_noSpans;
		}
开发者ID:jesse99,项目名称:Linguist,代码行数:30,代码来源:Linguist.cs


示例20: CreateVisuals

        /// <summary>
        /// Within the given line add the scarlet box behind the a
        /// </summary>
        private void CreateVisuals(ITextViewLine line)
        {
            //grab a reference to the lines in the current TextView 
            IWpfTextViewLineCollection textViewLines = _view.TextViewLines;
            int start = line.Start;
            int end = line.End;

            //Loop through each character, and place a box around any a 
            for (int i = start; (i < end); ++i)
            {
                if (_view.TextSnapshot[i] == 'a')
                {
                    SnapshotSpan span = new SnapshotSpan(_view.TextSnapshot, Span.FromBounds(i, i + 1));
                    Geometry g = textViewLines.GetMarkerGeometry(span);
                    if (g != null)
                    {
                        GeometryDrawing drawing = new GeometryDrawing(_brush, _pen, g);
                        drawing.Freeze();

                        DrawingImage drawingImage = new DrawingImage(drawing);
                        drawingImage.Freeze();

                        Image image = new Image();
                        image.Source = drawingImage;

                        //Align the image with the top of the bounds of the text geometry
                        Canvas.SetLeft(image, g.Bounds.Left);
                        Canvas.SetTop(image, g.Bounds.Top);

                        _layer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, null, image, null);
                    }
                }
            }
        }
开发者ID:AlmatoolboxCE,项目名称:AlmaStyleFix,代码行数:37,代码来源:TextAdornment1.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Snippet类代码示例发布时间:2022-05-24
下一篇:
C# SnapshotPoint类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap