Ejemplo n.º 1
0
        public IEnumerable <ITagSpan <RegionTag> > GetTags(NormalizedSnapshotSpanCollection snapShotSpans)
        {
            foreach (SnapshotSpan snapshotSpan in snapShotSpans.Where(IsRegionOrEndRegion))
            {
                SnapshotPoint?point = View.Caret.Position.Point.GetPoint(SourceBuffer, View.Caret.Position.Affinity);

                int pointPosition          = point.HasValue ? snapshotSpan.Snapshot.GetLineNumberFromPosition(point.Value) : -1;
                int lineNumberFromPosition = snapshotSpan.Snapshot.GetLineNumberFromPosition(snapshotSpan.Start);
                int index = snapshotSpan.GetText().IndexOf(Constants.RegionIndicatorCharacter);

                SnapshotSpan newSpan = new SnapshotSpan(snapshotSpan.Snapshot, (int)snapshotSpan.Start + index, snapshotSpan.Length - index);

                string classificationTypeNames = lineNumberFromPosition != pointPosition
                    ? Constants.InactiveRegionClassificationTypeNames
                    : Constants.ActiveRegionClassificationTypeNames;

                yield return(new TagSpan <RegionTag>(newSpan, new RegionTag(ClassificationTypeRegistryService.GetClassificationType(classificationTypeNames))));
            }
        }
Ejemplo n.º 2
0
        public static (SnapshotSpan SelectItem1, SnapshotSpan SelectItem2)? SwapTarget(NormalizedSnapshotSpanCollection selectedSpans)
        {
            var result = new List <SnapshotSpan>();

            foreach (var item in selectedSpans.Where(x => !string.IsNullOrEmpty(x.GetText())))
            {
                result.Add(item);
                if (2 < result.Count)
                {
                    return(null);
                }
            }

            if (result.Count == 2)
            {
                return(result[0], result[1]);
            }

            return(null);
        }