Exemple #1
0
        public IWpfTextViewMargin CreateMargin(IWpfTextViewHost textViewHost, IWpfTextViewMargin containerMargin)
        {
            CodeMarkManager codeMarkManager = textViewHost.TextView.Properties.GetOrCreateSingletonProperty <CodeMarkManager>
                                                  (delegate { return(new CodeMarkManager()); });

            return(new CoverageMargin(textViewHost, ServiceProvider, CoverageProviderBroker));
        }
Exemple #2
0
        public CoverageMargin(IWpfTextViewHost textViewHost, SVsServiceProvider serviceProvider,
                              ICoverageProviderBroker coverageProviderBroker)
        {
            ITextDocument document;

            _textViewHost = textViewHost;

            _dte = (DTE)serviceProvider.GetService(typeof(DTE));

            _documentName = CoverageProvider.GetFileName(_textViewHost.TextView.TextBuffer);

            _codeMarkManager = new CodeMarkManager();

            _coverageProvider = coverageProviderBroker.GetCoverageProvider(_textViewHost.TextView, _dte, serviceProvider);

            _codeMarks = GetAllCodeMarksForMargin();

            _textViewHost.TextView.LayoutChanged += TextViewLayoutChanged;

            _textViewHost.TextView.GotAggregateFocus += TextViewGotAggregateFocus;

            _textViewHost.TextView.ViewportHeightChanged += TextViewViewportHeightChanged;

            _textViewHost.TextView.TextBuffer.Changed += TextBufferChanged;
            _textViewHost.TextView.Closed             += TextViewClosed;

            //create a canvas to hold the margin UI and set its properties
            _marginCanvas = new Canvas();

            _marginCanvas.Background = Brushes.Transparent;

            ClipToBounds = true;
            Background   = Brushes.Transparent;
            BorderBrush  = Brushes.Transparent;

            Width = (_textViewHost.TextView.ZoomLevel / 100) * _marginWidth;

            BorderThickness = new Thickness(0.5);

            // add margin canvas to the children list
            Child = _marginCanvas;

            UpdateCodeMarks(_coverageProvider.GetCoveredLines(_textViewHost.TextView));
        }