/// <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());
            }
        }
Beispiel #2
0
        /// <summary>
        /// Creates a <see cref="EditorMargin"/> for a given <see cref="IWpfTextView"/>.
        /// </summary>
        /// <param name="textView">The <see cref="IWpfTextView"/> to attach the margin to.</param>
        /// <param name="undoHistoryRegistry">Maintains the relationship between text buffers and <see cref="ITextUndoHistory"/> objects.</param>
        /// <param name="marginCore">The class which receives, processes and provides necessary data for <see cref="EditorMargin"/>.</param>
        public EditorMargin(IWpfTextView textView, ITextUndoHistoryRegistry undoHistoryRegistry, MarginCore marginCore)
        {
            Debug.WriteLine("Entering constructor.", MarginName);

            if (!marginCore.IsEnabled)
            {
                return;
            }

            InitializeLayout();

            _textView   = textView;
            _marginCore = marginCore;

            undoHistoryRegistry.TryGetHistory(textView.TextBuffer, out _undoHistory);

            marginCore.MarginRedraw    += OnMarginCoreMarginRedraw;
            marginCore.ExceptionThrown += OnMarginCoreExceptionThrown;

            if (marginCore.IsActivated)
            {
                DrawMargins(marginCore.GetChangedLines());
            }
        }
        /// <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());
        }
Beispiel #4
0
        /// <summary>
        /// Creates an <see cref="IWpfTextViewMargin"/> for the given <see cref="IWpfTextViewHost"/>.
        /// </summary>
        /// <param name="textViewHost">The <see cref="IWpfTextViewHost"/> for which to create the <see cref="IWpfTextViewMargin"/>.</param>
        /// <param name="marginContainer">The container that will contain the newly-created margin.</param>
        /// <returns>The <see cref="ScrollbarMargin"/> instance.</returns>
        public override IWpfTextViewMargin CreateMargin(IWpfTextViewHost textViewHost, IWpfTextViewMargin marginContainer)
        {
            MarginCore marginCore = GetMarginCore(textViewHost);

            return(new ScrollbarMargin(textViewHost.TextView, marginContainer, marginCore));
        }
        /// <summary>
        /// Creates a <see cref="EditorMargin"/> for a given <see cref="IWpfTextView"/>.
        /// </summary>
        /// <param name="textView">The <see cref="IWpfTextView"/> to attach the margin to.</param>
        /// <param name="undoHistoryRegistry">Maintains the relationship between text buffers and <see cref="ITextUndoHistory"/> objects.</param>
        /// <param name="marginCore">The class which receives, processes and provides necessary data for <see cref="EditorMargin"/>.</param>
        public EditorMargin(IWpfTextView textView, ITextUndoHistoryRegistry undoHistoryRegistry, MarginCore marginCore)
        {
            Debug.WriteLine("Entering constructor.", MarginName);

            if (!marginCore.IsEnabled)
                return;

            InitializeLayout();

            _textView = textView;
            _marginCore = marginCore;

            undoHistoryRegistry.TryGetHistory(textView.TextBuffer, out _undoHistory);

            marginCore.MarginRedraw += OnMarginCoreMarginRedraw;
            marginCore.ExceptionThrown += OnMarginCoreExceptionThrown;

            if (marginCore.IsActivated)
                DrawMargins(marginCore.GetChangedLines());
        }