Пример #1
0
        public InlineCommentMargin(
            IWpfTextViewHost wpfTextViewHost,
            IInlineCommentPeekService peekService,
            IEditorFormatMapService editorFormatMapService,
            IViewTagAggregatorFactoryService tagAggregatorFactory,
            Lazy <IPullRequestSessionManager> sessionManager)
        {
            textView            = wpfTextViewHost.TextView;
            this.sessionManager = sessionManager.Value;

            // Default to not show comment margin
            textView.Options.SetOptionValue(InlineCommentTextViewOptions.MarginEnabledId, false);

            marginGrid = new GlyphMarginGrid {
                Width = 17.0
            };
            var glyphFactory    = new InlineCommentGlyphFactory(peekService, textView);
            var editorFormatMap = editorFormatMapService.GetEditorFormatMap(textView);

            glyphMargin = new GlyphMargin <InlineCommentTag>(textView, glyphFactory, marginGrid, tagAggregatorFactory,
                                                             editorFormatMap, MarginPropertiesName);

            if (IsDiffView())
            {
                TrackCommentGlyph(wpfTextViewHost, marginGrid);
            }

            currentSessionSubscription = this.sessionManager.WhenAnyValue(x => x.CurrentSession)
                                         .Subscribe(x => RefreshCurrentSession().Forget());

            visibleSubscription = marginGrid.WhenAnyValue(x => x.IsVisible)
                                  .Subscribe(x => textView.Options.SetOptionValue(InlineCommentTextViewOptions.MarginVisibleId, x));

            textView.Options.OptionChanged += (s, e) => RefreshMarginVisibility();
        }
        public IWpfTextViewMargin CreateMargin(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin parent)
        {
            var textView        = wpfTextViewHost.TextView;
            var editorFormatMap = editorFormatMapService.GetEditorFormatMap(textView);
            var glyphFactory    = new InlineCommentGlyphFactory(peekService, textView, editorFormatMap);

            Func <Grid> gridFactory = () => new GlyphMarginGrid();

            return(CreateMargin(glyphFactory, gridFactory, wpfTextViewHost, parent, editorFormatMap));
        }