Exemplo n.º 1
0
        public void AddDecorationError(BasePropertyDeclarationSyntax _property, string textFull, string toolTipText, FixErrorCallback errorCallback)
        {
            var lineSpan = tree.GetLineSpan(_property.Span, usePreprocessorDirectives: false);
            int lineNumber = lineSpan.StartLinePosition.Line;
            var line = _textView.TextSnapshot.GetLineFromLineNumber(lineNumber);
            var textViewLine = _textView.GetTextViewLineContainingBufferPosition(line.Start);
            int startSpace = textFull.Length - textFull.TrimStart().Length;
            int endSpace = textFull.Length - textFull.TrimEnd().Length;

            SnapshotSpan span = new SnapshotSpan(_textView.TextSnapshot, Span.FromBounds(line.Start.Position + startSpace, line.End.Position - endSpace));
            Geometry g = _textView.TextViewLines.GetMarkerGeometry(span);
            if (g != null)
            {
                rects.Add(g.Bounds);

                GeometryDrawing drawing = new GeometryDrawing(_brush, _pen, g);
                drawing.Freeze();

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

                Image image = new Image();
                image.Source = drawingImage;
                //image.Visibility = Visibility.Hidden;

                Canvas.SetLeft(image, g.Bounds.Left);
                Canvas.SetTop(image, g.Bounds.Top);
                _layer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, null, image, (t, ui) =>
                {
                    rects.Remove(g.Bounds);
                });

                DrawIcon(span, g.Bounds.Left - 30, g.Bounds.Top, toolTipText, errorCallback);
            }
        }
Exemplo n.º 2
0
        private void DrawIcon(SnapshotSpan span, double x, double y, string toolTipText, FixErrorCallback errorCallback)
        {
            //draw a square with the created brush and pen
            System.Windows.Rect r = new System.Windows.Rect(0, 0, 16, 16);
            Geometry g = new System.Windows.Media.RectangleGeometry(r);
            rects.Add(g.Bounds);
            GeometryDrawing drawing = new GeometryDrawing(_brush, _pen, g);
            drawing.Freeze();

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

            Image _image = new Image();
            _image.ToolTip = toolTipText;
            _image.Cursor = Cursors.Arrow;
            Helper.Imaging.GetImage(this, _image, "NeosSdiMef.Images.repair.png");
            _image.Stretch = Stretch.Fill;

            _image.MouseLeftButtonDown += new MouseButtonEventHandler(Error_MouseLeftButtonUp);
            _image.Tag = errorCallback;
            Canvas.SetLeft(_image, x);
            Canvas.SetTop(_image, y);

            _layer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, null, _image, (t, ui) =>
            {
                rects.Remove(g.Bounds);
            });
        }