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;
        }
        private void SetVisualStudioMarginVisibility(Visibility visibility)
        {
            var visualStudioMargin =
                _marginContainer.GetTextViewMargin(PredefinedMarginNames.LineNumber);

            if (visualStudioMargin is IWpfTextViewMargin lineNumberMargin)
            {
                var element = lineNumberMargin.VisualElement;
                if (element.Visibility != visibility)
                {
                    if (element.Visibility == Visibility.Visible)
                    {
                        _width           = element.Width;
                        _minWidth        = element.MinWidth;
                        _maxWidth        = element.MaxWidth;
                        element.Width    = 0.0;
                        element.MinWidth = 0.0;
                        element.MaxWidth = 0.0;
                    }
                    else if (element.Visibility == Visibility.Hidden)
                    {
                        element.Width    = _width;
                        element.MinWidth = _minWidth;
                        element.MaxWidth = _maxWidth;
                    }
                    element.Visibility = visibility;
                    element.UpdateLayout();
                }
            }
        }
Exemple #3
0
 private void RemoveVerticalScrollBar(IWpfTextViewMargin container_margin)
 {
     if (container_margin.GetTextViewMargin(PredefinedMarginNames.VerticalScrollBar) is IWpfTextViewMargin realScrollBarMargin)
     {
         realScrollBarMargin.VisualElement.MinWidth = 0.0;
         realScrollBarMargin.VisualElement.Width    = 0.0;
     }
 }
 public IMouseProcessor GetAssociatedMouseProcessor(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin margin)
 {
     if (margin.GetTextViewMargin(PredefinedMarginNames.Glyph) == margin)
     {
         return(wpfTextViewHost.TextView.Properties.GetOrCreateSingletonProperty(typeof(GlyphTextMarkerServiceMouseProcessor), () => new GlyphTextMarkerServiceMouseProcessor(glyphTextMarkerServiceImpl, wpfTextViewHost, margin)));
     }
     return(null);
 }
        internal ScrollDiffMargin(IWpfTextView textView, UnifiedDiff unifiedDiff, IMarginCore marginCore, IWpfTextViewMargin containerMargin)
            : base(textView)
        {
            var scrollBarMargin = containerMargin.GetTextViewMargin(PredefinedMarginNames.VerticalScrollBar);
            // ReSharper disable once SuspiciousTypeConversion.Global
            _scrollBar = (IVerticalScrollBar)scrollBarMargin;

            ViewModel = new ScrollDiffMarginViewModel(marginCore, unifiedDiff, UpdateDiffDimensions);

            UserControl = new ScrollDiffMarginControl { DataContext = ViewModel, Width = MarginWidth, MaxWidth = MarginWidth, MinWidth = MarginWidth};
        }
        /// <summary>
        /// Creates an <see cref="IWpfTextViewMargin"/> for the given <see cref="IWpfTextViewHost"/>.
        /// </summary>
        /// <param name="wpfTextViewHost">The <see cref="IWpfTextViewHost"/> for which to create the <see cref="IWpfTextViewMargin"/>.</param>
        /// <param name="marginContainer">The margin that will contain the newly-created margin.</param>
        /// <returns>The <see cref="IWpfTextViewMargin"/>.
        /// The value may be null if this <see cref="IWpfTextViewMarginProvider"/> does not participate for this context.
        /// </returns>
        #endregion
        public IWpfTextViewMargin CreateMargin(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin marginContainer) {

            var scrollBar = marginContainer.GetTextViewMargin(PredefinedMarginNames.VerticalScrollBar) as IVerticalScrollBar;
            if (scrollBar == null) {
                return null;
            }

            return new DiagnosticStripeMargin(
                wpfTextViewHost.TextView,                  
                scrollBar, 
                _editorFormatMapService);
        }
Exemple #7
0
        /// <summary>
        /// Creates an <see cref="IWpfTextViewMargin"/> for the given <see cref="IWpfTextViewHost"/>.
        /// </summary>
        /// <param name="wpfTextViewHost">The <see cref="IWpfTextViewHost"/> for which to create the <see cref="IWpfTextViewMargin"/>.</param>
        /// <param name="marginContainer">The margin that will contain the newly-created margin.</param>
        /// <returns>The <see cref="IWpfTextViewMargin"/>.
        /// The value may be null if this <see cref="IWpfTextViewMarginProvider"/> does not participate for this context.
        /// </returns>
        public IWpfTextViewMargin CreateMargin(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin marginContainer)
        {
            // ReSharper disable once SuspiciousTypeConversion.Global
            if (!(marginContainer.GetTextViewMargin(PredefinedMarginNames.VerticalScrollBar) is IVerticalScrollBar scrollBar))
            {
                return(null);
            }

            return(new DiagnosticStripeMargin(
                       wpfTextViewHost.TextView,
                       scrollBar,
                       _editorFormatMapService));
        }
Exemple #8
0
        private void HideVSLineNumbers()
        {
            var lineNumberMargin = containerMargin.GetTextViewMargin(PredefinedMarginNames.LineNumber) as IWpfTextViewMargin;

            if (lineNumberMargin == null)
            {
                return;
            }
            lineNumberMargin.VisualElement.Visibility = Visibility.Hidden;
            lineNumberMargin.VisualElement.Width      = 0.0;
            lineNumberMargin.VisualElement.MinWidth   = 0.0;
            lineNumberMargin.VisualElement.MaxWidth   = 0.0;
            lineNumberMargin.VisualElement.UpdateLayout();
        }
Exemple #9
0
        internal ScrollDiffMargin(IWpfTextView textView, IMarginCore marginCore, IWpfTextViewMargin containerMargin)
            : base(textView)
        {
            var scrollBarMargin = containerMargin.GetTextViewMargin(PredefinedMarginNames.VerticalScrollBar);

            // ReSharper disable once SuspiciousTypeConversion.Global
            _scrollBar = (IVerticalScrollBar)scrollBarMargin;

            ViewModel = new ScrollDiffMarginViewModel(marginCore, UpdateDiffDimensions);

            UserControl = new ScrollDiffMarginControl {
                DataContext = ViewModel, Width = MarginWidth, MaxWidth = MarginWidth, MinWidth = MarginWidth
            };
        }
 public IGuidObjectsProvider Create(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin margin, string marginName)
 {
     if (wpfTextViewHost == null)
     {
         throw new ArgumentNullException(nameof(wpfTextViewHost));
     }
     if (margin == null)
     {
         throw new ArgumentNullException(nameof(margin));
     }
     if (marginName == null)
     {
         throw new ArgumentNullException(nameof(marginName));
     }
     if (margin.GetTextViewMargin(marginName) != margin)
     {
         throw new ArgumentException();
     }
     return(new GuidObjectsProvider(wpfTextViewHost, margin, marginName, marginContextMenuHandlerProviders));
 }
        /// <summary>
        /// Creates a <see cref="ScrollbarMargin"/> for a given <see cref="IWpfTextView"/>.
        /// </summary>
        /// <param name="textView">The <see cref="IWpfTextView"/> to attach the margin to.</param>
        /// <param name="marginContainer">Margin container. Is defined in the <see cref="ScrollbarMarginFactory"/> by the <see cref="MarginContainerAttribute"/>.</param>
        /// <param name="marginCore">The class which receives, processes and provides necessary data for <see cref="ScrollbarMargin"/>.</param>
        public ScrollbarMargin(IWpfTextView textView, IWpfTextViewMargin marginContainer, MarginCore marginCore)
        {
            Debug.WriteLine("Entering constructor.", MarginName);

            _textView   = textView;
            _marginCore = marginCore;

            InitializeLayout();

            ITextViewMargin scrollBarMargin = marginContainer.GetTextViewMargin(PredefinedMarginNames.VerticalScrollBar);

            // ReSharper disable once SuspiciousTypeConversion.Global - scrollBarMargin is IVerticalScrollBar.
            _scrollBar = (IVerticalScrollBar)scrollBarMargin;

            marginCore.MarginRedraw += OnMarginCoreMarginRedraw;

            if (marginCore.IsActivated)
            {
                DrawMargins(marginCore.GetChangedLines());
            }
        }
Exemple #12
0
        public IWpfTextViewMargin CreateMargin(IWpfTextViewHost textViewHost, IWpfTextViewMargin containerMargin)
        {
            if (textViewHost.TextView.Roles.ContainsAny(RejectedRoles))
            {
                return(null);
            }

            DTE dte = (DTE)ServiceProvider.GetService(typeof(DTE));

            // Hide the real scroll bar
            IWpfTextViewMargin realScrollBar =
                containerMargin.GetTextViewMargin(PredefinedMarginNames.VerticalScrollBar) as IWpfTextViewMargin;

            if (realScrollBar != null)
            {
                realScrollBar.VisualElement.MinWidth = 0.0;
                realScrollBar.VisualElement.Width    = 0.0;
            }

            IWpfTextView textView = textViewHost.TextView;

            SimpleScrollBar scrollBar = new SimpleScrollBar(
                textView,
                containerMargin,
                _scrollMapFactory);

            ProgressiveScroll progressiveScroll = new ProgressiveScroll(
                containerMargin,
                textView,
                _outliningManagerService.GetOutliningManager(textView),
                _tagAggregatorFactoryService.CreateTagAggregator <ChangeTag>(textView),
                _tagAggregatorFactoryService.CreateTagAggregator <IVsVisibleTextMarkerTag>(textView),
                _tagAggregatorFactoryService.CreateTagAggregator <IErrorTag>(textView),
                dte.Debugger,
                scrollBar,
                new ColorSet(FormatMapService.GetEditorFormatMap(textView)));

            return(progressiveScroll);
        }
		public IWpfTextViewMargin CreateMargin(IWpfTextViewHost textViewHost, IWpfTextViewMargin containerMargin)
		{
			if (textViewHost.TextView.Roles.ContainsAny(RejectedRoles))
			{
				return null;
			}

			DTE dte = (DTE) ServiceProvider.GetService(typeof (DTE));

			// Hide the real scroll bar
			IWpfTextViewMargin realScrollBar =
				containerMargin.GetTextViewMargin(PredefinedMarginNames.VerticalScrollBar) as IWpfTextViewMargin;
			if (realScrollBar != null)
			{
				realScrollBar.VisualElement.MinWidth = 0.0;
				realScrollBar.VisualElement.Width = 0.0;
			}

			IWpfTextView textView = textViewHost.TextView;

			SimpleScrollBar scrollBar = new SimpleScrollBar(
				textView,
				containerMargin,
				_scrollMapFactory);

			ProgressiveScroll progressiveScroll = new ProgressiveScroll(
				containerMargin,
				textView,
				_outliningManagerService.GetOutliningManager(textView),
				_tagAggregatorFactoryService.CreateTagAggregator<ChangeTag>(textView),
				_tagAggregatorFactoryService.CreateTagAggregator<IVsVisibleTextMarkerTag>(textView),
				_tagAggregatorFactoryService.CreateTagAggregator<IErrorTag>(textView),
				dte.Debugger,
				scrollBar,
				new ColorSet(FormatMapService.GetEditorFormatMap(textView)));

			return progressiveScroll;
		}
        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(); };
        }
            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;
            }
 private void RemoveVerticalScrollBar(IWpfTextViewMargin container_margin)
 {
     var realScrollBarMargin = container_margin.GetTextViewMargin(PredefinedMarginNames.VerticalScrollBar) as IWpfTextViewMargin;
     if (realScrollBarMargin != null)
     {
         realScrollBarMargin.VisualElement.MinWidth = 0.0;
         realScrollBarMargin.VisualElement.Width = 0.0;
     }
 }
        /// <summary>
        /// Creates a <see cref="ScrollbarMargin"/> for a given <see cref="IWpfTextView"/>.
        /// </summary>
        /// <param name="textView">The <see cref="IWpfTextView"/> to attach the margin to.</param>
        /// <param name="marginContainer">Margin container. Is defined in the <see cref="ScrollbarMarginFactory"/> by the <see cref="MarginContainerAttribute"/>.</param>
        /// <param name="marginCore">The class which receives, processes and provides necessary data for <see cref="ScrollbarMargin"/>.</param>
        public ScrollbarMargin(IWpfTextView textView, IWpfTextViewMargin marginContainer, MarginCore marginCore)
        {
            Debug.WriteLine("Entering constructor.", MarginName);

            _textView = textView;
            _marginCore = marginCore;

            InitializeLayout();

            ITextViewMargin scrollBarMargin = marginContainer.GetTextViewMargin(PredefinedMarginNames.VerticalScrollBar);
            // ReSharper disable once SuspiciousTypeConversion.Global - scrollBarMargin is IVerticalScrollBar.
            _scrollBar = (IVerticalScrollBar)scrollBarMargin;

            marginCore.MarginRedraw += OnMarginCoreMarginRedraw;

            if (marginCore.IsActivated)
                DrawMargins(marginCore.GetChangedLines());
        }
		public IMouseProcessor GetAssociatedMouseProcessor(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin margin) {
			if (margin.GetTextViewMargin(PredefinedMarginNames.Glyph) == margin)
				return wpfTextViewHost.TextView.Properties.GetOrCreateSingletonProperty(typeof(GlyphTextMarkerServiceMouseProcessor), () => new GlyphTextMarkerServiceMouseProcessor(glyphTextMarkerServiceImpl, wpfTextViewHost, margin));
			return null;
		}
		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(); };
		}
		public IGuidObjectsProvider Create(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin margin, string marginName) {
			if (wpfTextViewHost == null)
				throw new ArgumentNullException(nameof(wpfTextViewHost));
			if (margin == null)
				throw new ArgumentNullException(nameof(margin));
			if (marginName == null)
				throw new ArgumentNullException(nameof(marginName));
			if (margin.GetTextViewMargin(marginName) != margin)
				throw new ArgumentException();
			return new GuidObjectsProvider(wpfTextViewHost, margin, marginName, marginContextMenuHandlerProviders);
		}