Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Indent"/> class.
        /// </summary>
        /// <param name="view">Text view to create the adornment for</param>
        //Ignoring warning since this adornment is always on UI thread
#pragma warning disable VSTHRD010
        public Indent(IWpfTextView view, ITextDocumentFactoryService textDocumentFactory)
        {
            if (view == null)
            {
                throw new ArgumentNullException(nameof(view));
            }
            if (textDocumentFactory == null)
            {
                throw new ArgumentNullException(nameof(textDocumentFactory));
            }
            layer = view.GetAdornmentLayer("Indent");

            this.view = view;
            this.view.LayoutChanged += OnLayoutChanged;
            drawer = new BackgroundTextIndexDrawer(layer, this.view);

            colorGetter = new RainbowBrushGetter(OptionsManager.brushes.Get(), OptionsManager.errorBrush.Get());
            validator   = new IndentValidator(
                OptionsManager.indentSize.Get()
                );


            bool result = textDocumentFactory.TryGetTextDocument(this.view.TextBuffer, out ITextDocument textDocument);

            if (result)
            {
                string   filePath      = textDocument.FilePath;
                string[] filePathSplit = filePath.Split('.');
                string   extension     = filePathSplit[filePathSplit.Length - 1];
                if (OptionsManager.fileExtensionsDictionary.Get().ContainsKey(extension))
                {
                    validator = new IndentValidator(OptionsManager.fileExtensionsDictionary.Get()[extension]);
                }
            }

            if (OptionsManager.highlightingMode.Get() == HighlightingMode.Alternating)
            {
                decorator = new AlternatingLineDecorator(
                    drawer, colorGetter, validator)
                {
                    detectErrors = OptionsManager.detectErrors.Get()
                };
            }
            if (OptionsManager.highlightingMode.Get() == HighlightingMode.Monocolor)
            {
                decorator = new MonocolorLineDecorator(
                    drawer, colorGetter, validator)
                {
                    detectErrors = OptionsManager.detectErrors.Get()
                };
            }
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Indent"/> class.
        /// </summary>
        /// <param name="view">Text view to create the adornment for</param>
        //Ignoring warning since this adornment is always on UI thread
#pragma warning disable VSTHRD010
        public Indent(IWpfTextView view)
        {
            if (view == null)
            {
                throw new ArgumentNullException("view");
            }
            this.layer = view.GetAdornmentLayer("Indent");

            this.view = view;
            this.view.LayoutChanged += this.OnLayoutChanged;
            this.drawer              = new BackgroundTextIndexDrawer(this.layer, this.view);

            this.colorGetter = new RainbowBrushGetter()
            {
                brushes = OptionsManager.GetColors()
            };
            this.validator = new IndentValidator(
                OptionsManager.GetIndentSize()
                );
            this.decorator = new LineDecorator(
                this.drawer, this.colorGetter, this.validator
                );
        }
Пример #3
0
#pragma warning restore CA1051 // Do not declare visible instance fields

        public LineDecoratorBase(IBackgroundTextIndexDrawer drawer, IRainbowBrushGetter colorGetter, IIndentValidator validator)
        {
            this.drawer      = drawer;
            this.colorGetter = colorGetter;
            this.validator   = validator;
        }
Пример #4
0
 public MonocolorLineDecorator(IBackgroundTextIndexDrawer drawer, IRainbowBrushGetter colorGetter, IIndentValidator validator) : base(drawer, colorGetter, validator)
 {
 }