コード例 #1
0
        /// <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();
        }
コード例 #2
0
 public VerticalScrollBarMargin(IScrollMapFactoryService scrollMapFactoryService, IWpfTextViewHost wpfTextViewHost)
 {
     if (scrollMapFactoryService == null)
     {
         throw new ArgumentNullException(nameof(scrollMapFactoryService));
     }
     this.wpfTextViewHost = wpfTextViewHost ?? throw new ArgumentNullException(nameof(wpfTextViewHost));
     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();
 }
コード例 #3
0
        /// <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();
        }