예제 #1
0
        IEnumerable <HexGlyphTag> GetGlyphTags(WpfHexViewLine line)
        {
            foreach (var tagSpan in tagAggregator.GetTags(line.BufferSpan))
            {
                if (line.IntersectsBufferSpan(tagSpan.Span))
                {
                    yield return(tagSpan.Tag);
                }
            }
            var taggerContext = new HexTaggerContext(line.BufferLine, line.BufferLine.TextSpan);

            foreach (var tagSpan in tagAggregator.GetLineTags(taggerContext))
            {
                yield return(tagSpan.Tag);
            }
        }
예제 #2
0
 public override HexToolTipInfoCollection GetToolTipInfo(HexBufferPoint position)
 {
     if (position.IsDefault)
     {
         throw new ArgumentException();
     }
     if (position > HexPosition.MaxEndPosition)
     {
         throw new ArgumentOutOfRangeException(nameof(position));
     }
     if (hexView.IsClosed)
     {
         return(null);
     }
     if (position >= HexPosition.MaxEndPosition)
     {
         return(null);
     }
     return(TryCreateToolTipInfoCollection(position, tagAggregator.GetTags(new HexBufferSpan(position, 1)).ToArray()));
 }
        public override IEnumerable <IHexTagSpan <HexSpaceNegotiatingAdornmentTag> > GetTags(NormalizedHexBufferSpanCollection spans)
        {
            if (wpfHexView.IsClosed)
            {
                yield break;
            }

            foreach (var span in spans)
            {
                foreach (var tagSpan in tagAggregator.GetTags(span))
                {
                    var    uiElem        = tagSpan.Tag.Adornment;
                    double topSpace      = tagSpan.Tag.TopSpace ?? 0;
                    double bottomSpace   = tagSpan.Tag.BottomSpace ?? 0;
                    double textHeight    = tagSpan.Tag.TextHeight ?? (Filter(uiElem.DesiredSize.Height) - (topSpace + bottomSpace));
                    var    adornmentInfo = new AdornmentTagInfo(tagSpan.Span, uiElem, tagSpan);
                    var    tag           = new HexSpaceNegotiatingAdornmentTag(Filter(uiElem.DesiredSize.Width), topSpace,
                                                                               tagSpan.Tag.Baseline ?? textHeight * 0.75, textHeight, bottomSpace,
                                                                               tagSpan.Tag.Affinity ?? VST.PositionAffinity.Predecessor, adornmentInfo, providerTag);
                    adornmentInfo.Tag = tag;
                    yield return(new HexTagSpan <HexSpaceNegotiatingAdornmentTag>(tagSpan.Span, tagSpan.Flags, tag));
                }
            }
        }
예제 #4
0
        void AddMarkerElements(NormalizedHexBufferSpanCollection spans)
        {
            foreach (var tag in tagAggregator.GetTags(spans))
            {
                if (tag.Tag?.Type == null)
                {
                    continue;
                }
                if (!tag.Span.IntersectsWith(wpfHexView.HexViewLines.FormattedSpan))
                {
                    continue;
                }
                var markerElement = TryCreateMarkerElement(tag.Span, tag.Flags, tag.Tag);
                if (markerElement == null)
                {
                    continue;
                }
                var  layer = markerElement.ZIndex < 0 ? negativeTextMarkerAdornmentLayer : textMarkerAdornmentLayer;
                bool added = layer.AddAdornment(VSTE.AdornmentPositioningBehavior.TextRelative, markerElement.Span, null, markerElement, onRemovedDelegate);
                if (added)
                {
                    markerElements.Add(markerElement);
                }
            }
            var formattedEnd = wpfHexView.HexViewLines.FormattedSpan.End;

            foreach (var span in spans)
            {
                var overlap = wpfHexView.HexViewLines.FormattedSpan.Overlap(span);
                if (overlap == null)
                {
                    continue;
                }
                var pos = overlap.Value.Start;
                for (;;)
                {
                    var line = wpfHexView.WpfHexViewLines.GetWpfHexViewLineContainingBufferPosition(pos);
                    Debug.Assert(line != null);
                    if (line != null)
                    {
                        var taggerContext = new HexTaggerContext(line.BufferLine, line.BufferLine.TextSpan);
                        foreach (var tag in tagAggregator.GetLineTags(taggerContext))
                        {
                            if (tag.Tag?.Type == null)
                            {
                                continue;
                            }
                            var markerElement = TryCreateMarkerElement(line, tag.Span, tag.Tag);
                            if (markerElement == null)
                            {
                                continue;
                            }
                            var  layer = markerElement.ZIndex < 0 ? negativeTextMarkerAdornmentLayer : textMarkerAdornmentLayer;
                            bool added = layer.AddAdornment(VSTE.AdornmentPositioningBehavior.TextRelative, markerElement.Span, null, markerElement, onRemovedDelegate);
                            if (added)
                            {
                                markerElements.Add(markerElement);
                            }
                        }
                    }

                    pos = line.BufferEnd;
                    if (pos > overlap.Value.End || pos >= formattedEnd)
                    {
                        break;
                    }
                }
            }
        }