Inheritance: IWpfTextViewMarginProvider
        /// <summary>
        /// Constructor for the CaretMarginElement.
        /// </summary>
        /// <param name="textView">ITextView to which this CaretMargenElement will be attached.</param>
        /// <param name="factory">Instance of the CaretMarginFactory that is creating the margin.</param>
        /// <param name="verticalScrollbar">Vertical scrollbar of the ITextViewHost that contains <paramref name="textView"/>.</param>
        public CaretMarginElement(IWpfTextView textView, CaretMarginFactory factory, IVerticalScrollBar verticalScrollbar)
        {
            this.textView = textView;
            this.layer    = textView.GetAdornmentLayer("CaretAdornmentLayer");

            factory.LoadOption(textView.Options, CaretMarginElement.EnabledOptionId.Name);
            factory.LoadOption(textView.Options, CaretMarginElement.CaretColorId.Name);
            factory.LoadOption(textView.Options, CaretMarginElement.MatchColorId.Name);
            factory.LoadOption(textView.Options, CaretMarginElement.AdornmentMatchColorId.Name);
            factory.LoadOption(textView.Options, CaretMarginElement.MarginWidthId.Name);

            this.scrollBar = verticalScrollbar;

            //Make our width big enough to see, but not so big that it consumes a lot of
            //real-estate.
            this.Width = textView.Options.GetOptionValue(CaretMarginElement.MarginWidthId);

            this.caretBrush          = GetBrush(CaretMarginElement.CaretColorId);
            this.matchBrush          = GetBrush(CaretMarginElement.MatchColorId);
            this.adornmentMatchBrush = GetBrush(CaretMarginElement.AdornmentMatchColorId);

            this.textView.Closed += OnClosed;

            this.OnOptionsChanged(null, null);
            this.textView.Options.OptionChanged += this.OnOptionsChanged;

            this.UpdateEventHandlers(null);

            this.IsVisibleChanged += delegate(object sender, DependencyPropertyChangedEventArgs e)
            {
                this.UpdateEventHandlers(null);
            };
        }
        /// <summary>
        /// Constructor for the CaretMargin.
        /// </summary>
        /// <param name="textViewHost">The IWpfTextViewHost in which this margin will be displayed.</param>
        /// <param name="navigator">Instance of an ITextStructureNavigator used to define words in the host's TextView. Created from the
        /// ITextStructureNavigatorFactory service.</param>
        public CaretMargin(IWpfTextViewHost textViewHost, IVerticalScrollBar scrollBar, CaretMarginFactory factory)
        {
            // Validate
            if (textViewHost == null)
                throw new ArgumentNullException("textViewHost");

            this.caretMarginElement = new CaretMarginElement(textViewHost.TextView, factory, scrollBar);
        }
Exemple #3
0
        /// <summary>
        /// Constructor for the CaretMargin.
        /// </summary>
        /// <param name="textViewHost">The IWpfTextViewHost in which this margin will be displayed.</param>
        /// <param name="navigator">Instance of an ITextStructureNavigator used to define words in the host's TextView. Created from the
        /// ITextStructureNavigatorFactory service.</param>
        public CaretMargin(IWpfTextViewHost textViewHost, IVerticalScrollBar scrollBar, CaretMarginFactory factory)
        {
            // Validate
            if (textViewHost == null)
            {
                throw new ArgumentNullException("textViewHost");
            }

            this.caretMarginElement = new CaretMarginElement(textViewHost.TextView, factory, scrollBar);
        }