public SimpleScrollBar(IWpfTextViewHost host, IWpfTextViewMargin containerMargin, FrameworkElement container,
            IScrollMapFactoryService scrollMapFactoryService)
        {
            _textView = host.TextView;

            _realScrollBarMargin =
                containerMargin.GetTextViewMargin(PredefinedMarginNames.VerticalScrollBar) as IWpfTextViewMargin;
            if (_realScrollBarMargin != null)
            {
                _realScrollBar = _realScrollBarMargin as IVerticalScrollBar;
                if (_realScrollBar != null)
                {
                    _realScrollBarMargin.VisualElement.IsVisibleChanged += OnScrollBarIsVisibleChanged;
                    _realScrollBar.TrackSpanChanged += OnScrollBarTrackSpanChanged;
                }
            }
            ResetTrackSpan();

            _scrollMapFactory = scrollMapFactoryService;
            _useElidedCoordinates = false;
            ResetScrollMap();

            _scrollMap.MappingChanged += delegate { RaiseTrackChangedEvent(); };

            container.SizeChanged += OnContainerSizeChanged;
        }
        public SonarIssueTextViewMargin(IEnumerable<SonarIssue> sonarIssues, IWpfTextViewHost textViewHost,
            IWpfTextViewMargin containerMargin, IScrollMapFactoryService scrollMapFactoryService)
        {
            _sonarIssues = sonarIssues;

            Width = textViewHost
                .TextView
                .Options
                .GetOptionValue(DefaultTextViewHostOptions.ChangeTrackingMarginWidthOptionId);

            _scrollBar = new SimpleScrollBar(textViewHost, containerMargin, this, scrollMapFactoryService);

            _scrollBarOnTrackSpanChanged = (sender, args) => DrawMargins();
            _scrollBar.TrackSpanChanged += _scrollBarOnTrackSpanChanged;
        }
 public VerticalScrollBarMargin(IScrollMapFactoryService scrollMapFactoryService, IWpfTextViewHost wpfTextViewHost)
 {
     if (scrollMapFactoryService == null)
     {
         throw new ArgumentNullException(nameof(scrollMapFactoryService));
     }
     if (wpfTextViewHost == null)
     {
         throw new ArgumentNullException(nameof(wpfTextViewHost));
     }
     this.wpfTextViewHost = wpfTextViewHost;
     this.scrollMap       = scrollMapFactoryService.Create(wpfTextViewHost.TextView, true);
     IsVisibleChanged    += VerticalScrollBarMargin_IsVisibleChanged;
     wpfTextViewHost.TextView.Options.OptionChanged += Options_OptionChanged;
     SetResourceReference(StyleProperty, typeof(ScrollBar));
     HorizontalAlignment = HorizontalAlignment.Center;
     Orientation         = System.Windows.Controls.Orientation.Vertical;
     SmallChange         = 1;
     UpdateVisibility();
 }
            public SimpleScrollBar(IWpfTextViewHost host, IWpfTextViewMargin containerMargin, IScrollMapFactoryService scrollMapFactory, FrameworkElement container, bool useElidedCoordinates)
            {
                _textView = host.TextView;

                _realScrollBarMargin = containerMargin.GetTextViewMargin(PredefinedMarginNames.VerticalScrollBar) as IWpfTextViewMargin;
                if (_realScrollBarMargin != null)
                {
                    _realScrollBar = _realScrollBarMargin as IVerticalScrollBar;
                    if (_realScrollBar != null)
                    {
                        _realScrollBarMargin.VisualElement.IsVisibleChanged += OnScrollBarIsVisibleChanged;
                        _realScrollBar.TrackSpanChanged += OnScrollBarTrackSpanChanged;
                    }
                }
                this.ResetTrackSpan();

                _scrollMapFactory     = scrollMapFactory;
                _useElidedCoordinates = useElidedCoordinates;
                this.ResetScrollMap();

                _scrollMap.MappingChanged += delegate { this.RaiseTrackChangedEvent(); };

                container.SizeChanged += OnContainerSizeChanged;
            }
        public SimpleScrollBar(IWpfTextView textView, IWpfTextViewMargin containerMargin, IScrollMapFactoryService scrollMapFactory)
        {
            _textView = textView;
            _textView.LayoutChanged += OnLayoutChanged;
            Width = Options.ScrollBarWidth;

            _realScrollBarMargin = containerMargin.GetTextViewMargin(PredefinedMarginNames.VerticalScrollBar) as IWpfTextViewMargin;

            if (_realScrollBarMargin != null)
            {
                _realScrollBar = _realScrollBarMargin as IVerticalScrollBar;
                if (_realScrollBar != null)
                {
                    _realScrollBarMargin.VisualElement.IsVisibleChanged += OnScrollBarIsVisibleChanged;
                    _realScrollBar.TrackSpanChanged += OnScrollBarTrackSpanChanged;
                }
            }
            ResetTrackSpan();

            _scrollMapFactory = scrollMapFactory;
            ResetScrollMap();

            _scrollMap.MappingChanged += delegate { RaiseTrackChangedEvent(); };
        }
        /// <summary>
        /// Creates a <see cref="MarginCore"/> for a given <see cref="IWpfTextView"/>.
        /// </summary>
        /// <param name="textView">The <see cref="IWpfTextView"/> to attach the margin to.</param>
        /// <param name="textDocumentFactoryService">Service that creates, loads, and disposes text documents.</param>
        /// <param name="vsServiceProvider">Visual Studio service provider.</param>
        /// <param name="formatMapService">Service that provides the <see cref="IEditorFormatMap"/>.</param>
        /// <param name="scrollMapFactoryService">Factory that creates or reuses an <see cref="IScrollMap"/> for an <see cref="ITextView"/>.</param>
        public MarginCore(IWpfTextView textView, ITextDocumentFactoryService textDocumentFactoryService, SVsServiceProvider vsServiceProvider, IEditorFormatMapService formatMapService, IScrollMapFactoryService scrollMapFactoryService)
        {
            Debug.WriteLine("Entering constructor.", Properties.Resources.ProductName);

            _textView = textView;
            if (!textDocumentFactoryService.TryGetTextDocument(_textView.TextDataModel.DocumentBuffer, out _textDoc))
            {
                Debug.WriteLine("Can not retrieve TextDocument. Margin is disabled.", Properties.Resources.ProductName);
                _isEnabled = false;
                return;
            }

            _formatMap      = formatMapService.GetEditorFormatMap(textView);
            _marginSettings = new MarginSettings(_formatMap);

            _scrollMap = scrollMapFactoryService.Create(textView);

            var dte = (DTE2)vsServiceProvider.GetService(typeof(DTE));

            _tfExt = (TeamFoundationServerExt)dte.GetObject(typeof(TeamFoundationServerExt).FullName);
            Debug.Assert(_tfExt != null, "_tfExt is null.");
            _tfExt.ProjectContextChanged += OnTfExtProjectContextChanged;

            UpdateMargin();
        }
 public SonarIssueTextViewMarginProvider(SonarIssuesServiceFactory sonarIssuesServiceFactory,
     IScrollMapFactoryService scrollMapFactoryService)
 {
     _sonarIssuesService = sonarIssuesServiceFactory.Create();
     _scrollMapFactoryService = scrollMapFactoryService;
 }
Esempio n. 8
0
 VerticalScrollBarMarginProvider(IScrollMapFactoryService scrollMapFactoryService)
 {
     this.scrollMapFactoryService = scrollMapFactoryService;
 }
		public SimpleScrollBar(IWpfTextView textView, IWpfTextViewMargin containerMargin, IScrollMapFactoryService scrollMapFactory)
		{
			_textView = textView;
			_textView.LayoutChanged += OnLayoutChanged;
			Width = Options.ScrollBarWidth;

			_realScrollBarMargin = containerMargin.GetTextViewMargin(PredefinedMarginNames.VerticalScrollBar) as IWpfTextViewMargin;

			if (_realScrollBarMargin != null)
			{
				_realScrollBar = _realScrollBarMargin as IVerticalScrollBar;
				if (_realScrollBar != null)
				{
					_realScrollBarMargin.VisualElement.IsVisibleChanged += OnScrollBarIsVisibleChanged;
					_realScrollBar.TrackSpanChanged += OnScrollBarTrackSpanChanged;
				}
			}
			ResetTrackSpan();

			_scrollMapFactory = scrollMapFactory;
			ResetScrollMap();

			_scrollMap.MappingChanged += delegate { RaiseTrackChangedEvent(); };
		}
        /// <summary>
        /// Creates a <see cref="MarginCore"/> for a given <see cref="IWpfTextView"/>.
        /// </summary>
        /// <param name="textView">The <see cref="IWpfTextView"/> to attach the margin to.</param>
        /// <param name="textDocumentFactoryService">Service that creates, loads, and disposes text documents.</param>
        /// <param name="vsServiceProvider">Visual Studio service provider.</param>
        /// <param name="formatMapService">Service that provides the <see cref="IEditorFormatMap"/>.</param>
        /// <param name="scrollMapFactoryService">Factory that creates or reuses an <see cref="IScrollMap"/> for an <see cref="ITextView"/>.</param>
        public MarginCore(IWpfTextView textView, ITextDocumentFactoryService textDocumentFactoryService, SVsServiceProvider vsServiceProvider, IEditorFormatMapService formatMapService, IScrollMapFactoryService scrollMapFactoryService)
        {
            Debug.WriteLine("Entering constructor.", Properties.Resources.ProductName);

            _textView = textView;
            if (!textDocumentFactoryService.TryGetTextDocument(_textView.TextBuffer, out _textDoc))
            {
                Debug.WriteLine("Can not retrieve TextDocument. Margin is disabled.", Properties.Resources.ProductName);
                _isEnabled = false;
                return;
            }

            _formatMap = formatMapService.GetEditorFormatMap(textView);
            _marginSettings = new MarginSettings(_formatMap);

            _scrollMap = scrollMapFactoryService.Create(textView);

            var dte = (DTE2)vsServiceProvider.GetService(typeof(DTE));
            _tfExt = dte.GetObject(typeof(TeamFoundationServerExt).FullName);
            Debug.Assert(_tfExt != null, "_tfExt is null.");
            _tfExt.ProjectContextChanged += OnTfExtProjectContextChanged;

            UpdateMargin();
        }