コード例 #1
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="AdornmentTagger" /> class.
        /// </summary>
        AdornmentTagger(ITagAggregator <TagData> dataTagger, AdornmentTaggerScope scope)
        {
            this.scope = scope;

            snapshot = view.TextBuffer.CurrentSnapshot;

            view.LayoutChanged      += HandleLayoutChanged;
            view.TextBuffer.Changed += HandleBufferChanged;

            this.dataTagger = dataTagger;

            this.dataTagger.TagsChanged += HandleDataTagsChanged;
        }
コード例 #2
0
ファイル: Mixin.cs プロジェクト: beyaz/HideUnobtrusiveCodes
        /// <summary>
        ///     Determines whether [is intersect with disabled spans] [the specified scope].
        /// </summary>
        public static bool IsIntersectWithDisabledSpans(AdornmentTaggerScope scope, SnapshotSpan span)
        {
            if (scope.DisabledSnapshotSpans.Any(x => IntersectsWith(x, span)))
            {
                return(true);
            }

            if (scope.EditedSpans != null)
            {
                if (scope.EditedSpans.Any(x => IntersectsWith(x, span)))
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #3
0
        /// <summary>
        ///     Creates a tag provider for the specified view and buffer.
        /// </summary>
        public ITagger <T> CreateTagger <T>(ITextView textView, ITextBuffer buffer) where T : ITag
        {
            Trace(nameof(CreateTagger));

            if (textView == null)
            {
                throw new ArgumentNullException("textView");
            }

            if (buffer == null)
            {
                throw new ArgumentNullException("buffer");
            }

            if (buffer != textView.TextBuffer)
            {
                return(null);
            }

            var textBlockStyler = MyUtil.GetTextBlockStyler(FormatMapService.GetEditorFormatMap(textView));

            // FormatMapService.GetEditorFormatMap("text").GetProperties("Comment")["ForegroundColor"]

            var scope = new AdornmentTaggerScope
            {
                TextBlockStyler = textBlockStyler,
                WpfTextView     = (IWpfTextView)textView
            };

            ITagAggregator <TagData> CreateTagAggregator()
            {
                AdornmentTagger.scopeStatic = scope;
                var value = BufferTagAggregatorFactoryService.CreateTagAggregator <TagData>(textView.TextBuffer);

                AdornmentTagger.scopeStatic = null;

                return(value);
            }

            return(AdornmentTagger.GetTagger(new Lazy <ITagAggregator <TagData> >(CreateTagAggregator), scope) as ITagger <T>);
        }
コード例 #4
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="Tagger" /> class.
        /// </summary>
        public Tagger(ITextBuffer buffer)
        {
            buffer.Changed += (sender, args) => HandleBufferChanged(args);

            scope = AdornmentTagger.scopeStatic ?? throw new ArgumentNullException(nameof(AdornmentTagger.scopeStatic));
        }
コード例 #5
0
 /// <summary>
 ///     Gets the tagger.
 /// </summary>
 internal static ITagger <IntraTextAdornmentTag> GetTagger(Lazy <ITagAggregator <TagData> > tagger, AdornmentTaggerScope scope)
 {
     return(scope.WpfTextView.Properties.GetOrCreateSingletonProperty(() => new AdornmentTagger(tagger.Value, scope)));
 }