コード例 #1
0
        private void RenderAdornment(FileLineExtension fileLineExtension)
        {
            NSView view;

            if (fileLineExtension is ExceptionCaughtButton button)
            {
                view = CreateButton(cocoaViewFactory, button);
            }
            else if (fileLineExtension is ExceptionCaughtMiniButton miniButton)
            {
                view = CreateMiniButton(cocoaViewFactory, miniButton);
            }
            else
            {
                return;
            }
            if (extension != fileLineExtension)
            {
                extension = fileLineExtension;
                var newSpan = textView.TextSnapshot.SpanFromMDColumnAndLine(extension.Line, extension.Column, extension.Line, extension.Column);
                trackingSpan = textView.TextSnapshot.CreateTrackingSpan(newSpan, SpanTrackingMode.EdgeInclusive);
            }
            var span = trackingSpan.GetSpan(textView.TextSnapshot);

            if (textView.TextViewLines == null)
            {
                return;
            }
            if (!textView.TextViewLines.FormattedSpan.IntersectsWith(span))
            {
                return;
            }
            var charBound = textView.TextViewLines.GetCharacterBounds(span.End);

            view.SetFrameOrigin(new CGPoint(
                                    Math.Round(charBound.Left),
                                    Math.Round(charBound.TextTop + charBound.TextHeight / 2 - view.Frame.Height / 2)));
            _exceptionCaughtLayer.RemoveAllAdornments();
            _exceptionCaughtLayer.AddAdornment(XPlatAdornmentPositioningBehavior.TextRelative, span, null, view, null);
        }
コード例 #2
0
        void UpdateAdornmentLayout(PinnedWatch watch, NSView view, SnapshotSpan span)
        {
            try {
                if (!textView.TextViewLines.IntersectsBufferSpan(span))
                {
                    layer.RemoveAdornment(view);
                    return;
                }

                var charBound = textView.TextViewLines.GetCharacterBounds(span.End);
                var origin    = new CGPoint(
                    Math.Round(charBound.Left),
                    Math.Round(charBound.TextTop + charBound.TextHeight / 2 - view.Frame.Height / 2));
                view.SetFrameOrigin(origin);

                if (view.Superview == null || view.VisibleRect() == CGRect.Empty)
                {
                    layer.RemoveAdornment(view);
                    layer.AddAdornment(XPlatAdornmentPositioningBehavior.TextRelative, span, watch, view, null);
                }
            } catch (Exception ex) {
                view.SetFrameOrigin(default);
コード例 #3
0
        // Draw the adornment
        private void RenderAdornment()
        {
            Debug.Assert(_adornmentLayer.IsEmpty, "An adornment already exists");

            if (_trackingPoint != null && _brush != null && !_textView.IsClosed && _textView.TextViewLines != null)
            {
                // map up from the subject buffer
                SnapshotSpan?span = TranslatedSpan;

                // check that the span is visible
                if (span.HasValue && _textView.TextViewLines.FormattedSpan.Contains(span.Value.Start))
                {
#if !WINDOWS
                    TextBounds textBounds = _textView.TextViewLines.GetCharacterBounds(span.Value.Start);
                    var        nsview     = new AppKit.NSView();
                    nsview.WantsLayer = true;
                    var color = ((SolidColorBrush)_brush).Color;
                    nsview.Layer.BackgroundColor = new CoreGraphics.CGColor(color.R / 255f, color.G / 255f, color.B / 255f);
                    nsview.Frame = new CoreGraphics.CGRect(textBounds.Left, textBounds.TextBottom, textBounds.Width, 2);
                    _adornmentLayer.AddAdornment(XPlatAdornmentPositioningBehavior.TextRelative, span, null, nsview, null);
#endif
                }
            }
        }