Пример #1
0
        void UpdateEnabled()
        {
            var newValue = wpfTextView.Options.IsShowStructureLinesEnabled();

            if (newValue == enabled)
            {
                return;
            }
            enabled = newValue;
            if (enabled)
            {
                if (layer == null)
                {
                    layer = wpfTextView.GetAdornmentLayer(PredefinedDnSpyAdornmentLayers.StructureVisualizer);
                }
                if (editorFormatMap == null)
                {
                    editorFormatMap = editorFormatMapService.GetEditorFormatMap(wpfTextView);
                }
                RegisterEvents();
                UpdateColorInfos();
                RepaintAllLines();
            }
            else
            {
                UnregisterEvents();
                RemoveAllLineElements();
                ClearXPosCache();
            }
        }
Пример #2
0
 void UpdateLineSeparator()
 {
     if (wpfTextView.Options.IsLineSeparatorEnabled())
     {
         Debug.Assert(tagAggregator == null);
         if (tagAggregator != null)
         {
             throw new InvalidOperationException();
         }
         if (adornmentLayer == null)
         {
             adornmentLayer = wpfTextView.GetAdornmentLayer(PredefinedDsAdornmentLayers.LineSeparator);
         }
         if (editorFormatMap == null)
         {
             editorFormatMap = editorFormatMapService.GetEditorFormatMap(wpfTextView);
         }
         tagAggregator = viewTagAggregatorFactoryService.CreateTagAggregator <ILineSeparatorTag>(wpfTextView);
         tagAggregator.BatchedTagsChanged     += TagAggregator_BatchedTagsChanged;
         wpfTextView.LayoutChanged            += WpfTextView_LayoutChanged;
         editorFormatMap.FormatMappingChanged += EditorFormatMap_FormatMappingChanged;
         UpdateLineSeparatorBrush();
         UpdateRange(new NormalizedSnapshotSpanCollection(wpfTextView.TextViewLines.FormattedSpan));
     }
     else
     {
         DisposeTagAggregator();
         wpfTextView.LayoutChanged -= WpfTextView_LayoutChanged;
         if (editorFormatMap != null)
         {
             editorFormatMap.FormatMappingChanged -= EditorFormatMap_FormatMappingChanged;
         }
         RemoveAllLineSeparatorElements();
     }
 }
Пример #3
0
        public IWpfTextViewMargin CreateMargin(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin marginContainer)
        {
            var buffer          = _vim.GetOrCreateVimBuffer(wpfTextViewHost.TextView);
            var editorFormatMap = _editorFormatMapService.GetEditorFormatMap(wpfTextViewHost.TextView);

            return(new CommandMargin(buffer, editorFormatMap, _optionsProviderFactories));
        }
        /// <summary>
        /// Creates a <see cref="MarginCore"/> for a given <see cref="IWpfTextView"/>.
        /// </summary>
        /// <param name="textView">The <see cref="IWpfTextView"/> to attach the margin to.</param>
        /// <param name="textDocumentFactoryService">Service that creates, loads, and disposes text documents.</param>
        /// <param name="vsServiceProvider">Visual Studio service provider.</param>
        /// <param name="formatMapService">Service that provides the <see cref="IEditorFormatMap"/>.</param>
        /// <param name="scrollMapFactoryService">Factory that creates or reuses an <see cref="IScrollMap"/> for an <see cref="ITextView"/>.</param>
        public MarginCore(IWpfTextView textView, ITextDocumentFactoryService textDocumentFactoryService, SVsServiceProvider vsServiceProvider, IEditorFormatMapService formatMapService, IScrollMapFactoryService scrollMapFactoryService)
        {
            Debug.WriteLine("Entering constructor.", Properties.Resources.ProductName);

            _textView = textView;
            if (!textDocumentFactoryService.TryGetTextDocument(_textView.TextDataModel.DocumentBuffer, out _textDoc))
            {
                Debug.WriteLine("Can not retrieve TextDocument. Margin is disabled.", Properties.Resources.ProductName);
                _isEnabled = false;
                return;
            }

            _formatMap      = formatMapService.GetEditorFormatMap(textView);
            _marginSettings = new MarginSettings(_formatMap);

            _scrollMap = scrollMapFactoryService.Create(textView);

            var dte = (DTE2)vsServiceProvider.GetService(typeof(DTE));

            _tfExt = (TeamFoundationServerExt)dte.GetObject(typeof(TeamFoundationServerExt).FullName);
            Debug.Assert(_tfExt != null, "_tfExt is null.");
            _tfExt.ProjectContextChanged += OnTfExtProjectContextChanged;

            UpdateMargin();
        }
Пример #5
0
        public ITagger <T> CreateTagger <T>(ITextView textView, ITextBuffer buffer) where T : ITag
        {
            if (s_paramStorageClassification == null)
            {
                s_paramStorageClassification = ClassificationRegistry.GetClassificationType("ParamStorageClassificationVisualD");
            }

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

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

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

            return(ParamStorageAdornmentTagger.GetTagger(
                       (IWpfTextView)textView, FormatMapService.GetEditorFormatMap(textView),
                       new Lazy <ITagAggregator <ParamStorageTag> >(
                           () => BufferTagAggregatorFactoryService.CreateTagAggregator <ParamStorageTag>(textView.TextBuffer)))
                   as ITagger <T>);
        }
Пример #6
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();
        }
        private CharDisplayTaggerSource CreateCharDisplayTaggerSource(ITextView textView)
        {
            var editorFormatMap          = _editorFormatMapService.GetEditorFormatMap(textView);
            var classificationFormaptMap = _classificationFormatMapService.GetClassificationFormatMap(textView);

            return(new CharDisplayTaggerSource(textView, editorFormatMap, _controlCharUtil, classificationFormaptMap));
        }
        void UpdateEnabled()
        {
            var newValue = wpfTextView.Options.GetOptionValue(DefaultTextViewOptions.ShowBlockStructureId);

            if (newValue == enabled)
            {
                return;
            }
            enabled = newValue;
            if (enabled)
            {
                if (layer == null)
                {
                    layer = wpfTextView.GetAdornmentLayer(PredefinedAdornmentLayers.BlockStructure);
                }
                if (editorFormatMap == null)
                {
                    editorFormatMap = editorFormatMapService.GetEditorFormatMap(wpfTextView);
                }
                RegisterEvents();
                RefreshLinesAndColorInfos();
            }
            else
            {
                UnregisterEvents();
                RemoveAllLineElements();
                ClearXPosCache();
            }
        }
Пример #9
0
        public IWpfTextViewMargin?CreateMargin(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin marginContainer)
        {
            var textView        = wpfTextViewHost.TextView;
            var tagAggregator   = _tagAggregatorFactoryService.CreateTagAggregator <InheritanceMarginTag>(textView);
            var editorFormatMap = _editorFormatMapService.GetEditorFormatMap(textView);

            var document = wpfTextViewHost.TextView.TextBuffer.CurrentSnapshot.GetOpenDocumentInCurrentContextWithChanges();

            if (document == null)
            {
                return(null);
            }

            var optionService = document.Project.Solution.Workspace.Services.GetRequiredService <IOptionService>();
            var listener      = _listenerProvider.GetListener(FeatureAttribute.InheritanceMargin);

            return(new InheritanceMarginViewMargin(
                       textView,
                       _threadingContext,
                       _streamingFindUsagesPresenter,
                       _operationExecutor,
                       _classificationFormatMapService.GetClassificationFormatMap("tooltip"),
                       _classificationTypeMap,
                       tagAggregator,
                       editorFormatMap,
                       optionService,
                       listener,
                       document.Project.Language));
        }
Пример #10
0
        public void TextViewCreated(IWpfTextView textView)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            IEditorFormatMap formatMap = FormatMapService.GetEditorFormatMap(textView);

            ResourceDictionary mplContent      = formatMap.GetProperties("MplContent");
            ResourceDictionary mplCodeBrackets = formatMap.GetProperties("MplCodeBrackets");

            if (MplPackage.Options.SolarizedTheme)
            {
                if (MplPackage.Options.DarkThemesList.Contains(MplPackage.GetThemeName()))
                {
                    //dark theme
                    textView.Background = Constants.backgroundDarkBrush;
                }
                else
                {
                    //light theme
                    textView.Background = Constants.backgroundLightBrush;
                }

                formatMap.BeginBatchUpdate();

                mplContent[EditorFormatDefinition.ForegroundColorId] = MplPackage.MplContentColor;
                mplContent[EditorFormatDefinition.ForegroundBrushId] = new SolidColorBrush(MplPackage.MplContentColor);
                formatMap.SetProperties("MplContent", mplContent);

                mplCodeBrackets[EditorFormatDefinition.ForegroundColorId] = MplPackage.MplEmphasizedColor;
                mplCodeBrackets[EditorFormatDefinition.ForegroundBrushId] = new SolidColorBrush(MplPackage.MplEmphasizedColor);
                formatMap.SetProperties("MplCodeBrackets", mplCodeBrackets);

                formatMap.EndBatchUpdate();
            }
        }
Пример #11
0
    //</Snippet3>

    //<Snippet4>
    public void TextViewCreated(IWpfTextView textView)
    {
        IEditorFormatMap formatMap = FormatMapService.GetEditorFormatMap(textView);

        ResourceDictionary regularCaretProperties   = formatMap.GetProperties("Caret");
        ResourceDictionary overwriteCaretProperties = formatMap.GetProperties("Overwrite Caret");
        ResourceDictionary indicatorMargin          = formatMap.GetProperties("Indicator Margin");
        ResourceDictionary visibleWhitespace        = formatMap.GetProperties("Visible Whitespace");
        ResourceDictionary selectedText             = formatMap.GetProperties("Selected Text");
        ResourceDictionary inactiveSelectedText     = formatMap.GetProperties("Inactive Selected Text");

        formatMap.BeginBatchUpdate();

        regularCaretProperties[EditorFormatDefinition.ForegroundBrushId] = Brushes.Magenta;
        formatMap.SetProperties("Caret", regularCaretProperties);

        overwriteCaretProperties[EditorFormatDefinition.ForegroundBrushId] = Brushes.Turquoise;
        formatMap.SetProperties("Overwrite Caret", overwriteCaretProperties);

        indicatorMargin[EditorFormatDefinition.BackgroundColorId] = Colors.LightGreen;
        formatMap.SetProperties("Indicator Margin", indicatorMargin);

        visibleWhitespace[EditorFormatDefinition.ForegroundColorId] = Colors.Red;
        formatMap.SetProperties("Visible Whitespace", visibleWhitespace);

        selectedText[EditorFormatDefinition.BackgroundBrushId] = Brushes.LightPink;
        formatMap.SetProperties("Selected Text", selectedText);

        inactiveSelectedText[EditorFormatDefinition.BackgroundBrushId] = Brushes.DeepPink;
        formatMap.SetProperties("Inactive Selected Text", inactiveSelectedText);

        formatMap.EndBatchUpdate();
    }
Пример #12
0
        private IBlockCaret CreateBlockCaret(IWpfTextView textView)
        {
            var classificationFormaptMap = _classificationFormatMapService.GetClassificationFormatMap(textView);
            var formatMap = _formatMapService.GetEditorFormatMap(textView);

            return(new BlockCaret(textView, BlockCaretAdornmentLayerName, classificationFormaptMap, formatMap, _controlCharUtil, _protectedOperations));
        }
Пример #13
0
        public void UpdateColors()
        {
            var classificationFormatMap = _classificationFormatMapService.GetClassificationFormatMap(category: "text");
            var editorFormatMap         = _editorFormatMapService.GetEditorFormatMap(category: "text");

            UpdateClassificationColors(classificationFormatMap);
            UpdateEditorColors(editorFormatMap);
        }
 public IWpfTextViewMargin CreateMargin(IWpfTextViewHost textViewHost, IWpfTextViewMargin containerMargin)
 {
     return(new RelativeNumber(
                textViewHost.TextView,
                FormatMapService.GetEditorFormatMap(textViewHost.TextView),
                containerMargin,
                OutliningManagerService.GetOutliningManager(textViewHost.TextView)));
 }
Пример #15
0
        // TODO: Do we need this?
        public void TextViewCreated(IWpfTextView textView)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            var formatMap       = FormatMapService.GetEditorFormatMap(textView);
            var mplContent      = formatMap.GetProperties("MplContent");
            var mplCodeBrackets = formatMap.GetProperties("MplCodeBrackets");
        }
Пример #16
0
 private ToastNotificationService GetOrCreate(IWpfTextView wpfTextView)
 {
     return(wpfTextView.Properties.GetOrCreateSingletonProperty(Key, () =>
     {
         var editorFormatMap = _editorFormatMapService.GetEditorFormatMap(wpfTextView);
         return new ToastNotificationService(wpfTextView, editorFormatMap);
     }));
 }
 public StringIndentationTaggerProvider(
     IThreadingContext threadingContext,
     IEditorFormatMapService editorFormatMapService,
     IGlobalOptionService globalOptions,
     IAsynchronousOperationListenerProvider listenerProvider)
     : base(threadingContext, globalOptions, listenerProvider.GetListener(FeatureAttribute.StringIndentation))
 {
     _editorFormatMap = editorFormatMapService.GetEditorFormatMap("text");
 }
 public LineSeparatorTaggerProvider(
     IEditorFormatMapService editorFormatMapService,
     IForegroundNotificationService notificationService,
     [ImportMany] IEnumerable <Lazy <IAsynchronousOperationListener, FeatureMetadata> > asyncListeners)
     : base(new AggregateAsynchronousOperationListener(asyncListeners, FeatureAttribute.LineSeparators), notificationService)
 {
     _editorFormatMap = editorFormatMapService.GetEditorFormatMap("text");
     _editorFormatMap.FormatMappingChanged += OnFormatMappingChanged;
     _lineSeparatorTag = new LineSeparatorTag(_editorFormatMap);
 }
Пример #19
0
        public VsSettings(IWpfTextView textView)
        {
            Debug.Assert(IsInitialized);

            this.textView   = textView;
            editorFormatMap = editorFormatMapService.GetEditorFormatMap(textView);
            ReloadColors();

            editorFormatMap.FormatMappingChanged += OnFormatItemsChanged;
        }
Пример #20
0
 public StringIndentationTaggerProvider(
     IThreadingContext threadingContext,
     IEditorFormatMapService editorFormatMapService,
     IGlobalOptionService globalOptions,
     [Import(AllowDefault = true)] ITextBufferVisibilityTracker?visibilityTracker,
     IAsynchronousOperationListenerProvider listenerProvider)
     : base(threadingContext, globalOptions, visibilityTracker, listenerProvider.GetListener(FeatureAttribute.StringIndentation))
 {
     _editorFormatMap = editorFormatMapService.GetEditorFormatMap("text");
 }
        public void TextViewCreated(IWpfTextView rpTextView)
        {
            new EditorBackground(rpTextView);

            //去掉断点边栏的背景
            var rProperties = EditorFormatMapService.GetEditorFormatMap(rpTextView).GetProperties("Indicator Margin");

            rProperties["BackgroundColor"] = Colors.Transparent;
            rProperties["Background"]      = Brushes.Transparent;
        }
Пример #22
0
 public LineSeparatorTaggerProvider(
     IEditorFormatMapService editorFormatMapService,
     IForegroundNotificationService notificationService,
     IAsynchronousOperationListenerProvider listenerProvider)
     : base(listenerProvider.GetListener(FeatureAttribute.LineSeparators), notificationService)
 {
     _editorFormatMap = editorFormatMapService.GetEditorFormatMap("text");
     _editorFormatMap.FormatMappingChanged += OnFormatMappingChanged;
     _lineSeparatorTag = new LineSeparatorTag(_editorFormatMap);
 }
 public LineSeparatorTaggerProvider(
     IThreadingContext threadingContext,
     IEditorFormatMapService editorFormatMapService,
     IAsynchronousOperationListenerProvider listenerProvider)
     : base(threadingContext, listenerProvider.GetListener(FeatureAttribute.LineSeparators))
 {
     _editorFormatMap = editorFormatMapService.GetEditorFormatMap("text");
     _editorFormatMap.FormatMappingChanged += OnFormatMappingChanged;
     _lineSeparatorTag = new LineSeparatorTag(_editorFormatMap);
 }
Пример #24
0
        public IWpfTextViewMargin CreateMargin(IWpfTextViewHost textViewHost, IWpfTextViewMargin containerMargin)
        {
            if (!VisualDHelper.setFactory(editorFactory))
            {
                return(null);
            }

            //MessageBox.Show("CreateMargin");
            return(new CoverageMargin(textViewHost.TextView, FormatMapService.GetEditorFormatMap(textViewHost.TextView)));
        }
        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));
        }
Пример #26
0
        public Dashboard(
            DashboardViewModel model,
            IEditorFormatMapService editorFormatMapService,
            IWpfTextView textView)
        {
            _model = model;
            InitializeComponent();

            _tabNavigableChildren = new UIElement[] { this.OverloadsCheckbox, this.CommentsCheckbox, this.StringsCheckbox, this.FileRenameCheckbox, this.PreviewChangesCheckbox, this.ApplyButton, this.CloseButton }.ToList();

            _textView        = textView;
            this.DataContext = model;

            this.Visibility = textView.HasAggregateFocus ? Visibility.Visible : Visibility.Collapsed;

            _textView.GotAggregateFocus         += OnTextViewGotAggregateFocus;
            _textView.LostAggregateFocus        += OnTextViewLostAggregateFocus;
            _textView.VisualElement.SizeChanged += OnElementSizeChanged;
            this.SizeChanged += OnElementSizeChanged;

            PresentationSource.AddSourceChangedHandler(this, OnPresentationSourceChanged);

            try
            {
                _findAdornmentLayer = textView.GetAdornmentLayer("FindUIAdornmentLayer");
                ((UIElement)_findAdornmentLayer).LayoutUpdated += FindAdornmentCanvas_LayoutUpdated;
            }
            catch (ArgumentOutOfRangeException)
            {
                // Find UI doesn't exist in ETA.
            }

            // Once the Dashboard is loaded, the visual tree is completely created and the
            // UIAutomation system has discovered and connected the AutomationPeer to the tree,
            // allowing us to raise the AutomationFocusChanged event and have it process correctly.
            // for us to set up the AutomationPeer
            this.Loaded += Dashboard_Loaded;

            if (editorFormatMapService != null)
            {
                _textFormattingMap = editorFormatMapService.GetEditorFormatMap("text");
                _textFormattingMap.FormatMappingChanged += UpdateBorderColors;
                UpdateBorderColors(this, eventArgs: null);
            }

            ResolvableConflictBorder.StrokeThickness = RenameFixupTagDefinition.StrokeThickness;
            ResolvableConflictBorder.StrokeDashArray = new DoubleCollection(RenameFixupTagDefinition.StrokeDashArray);

            UnresolvableConflictBorder.StrokeThickness = RenameConflictTagDefinition.StrokeThickness;
            UnresolvableConflictBorder.StrokeDashArray = new DoubleCollection(RenameConflictTagDefinition.StrokeDashArray);

            this.Focus();
            textView.Caret.IsHidden         = false;
            ShouldReceiveKeyboardNavigation = false;
        }
Пример #27
0
        public ErrorMarkFactory(IWpfTextView view, IViewTagAggregatorFactoryService tagAggregatorFactoryService, IEditorFormatMapService editorFormatMapService)
        {
            _squiggleTagger              = tagAggregatorFactoryService.CreateTagAggregator <IErrorTag>(view);
            _squiggleTagger.TagsChanged += OnTagsChanged;

            _editorFormatMap = editorFormatMapService.GetEditorFormatMap(view);
            _editorFormatMap.FormatMappingChanged += OnFormatMappingChanged;

            _view         = view;
            _view.Closed += OnClosed;
        }
Пример #28
0
 public EditorFormatMapCoverageColoursManager(
     ICoverageColoursProvider coverageColoursProvider,
     ICoverageColours coverageColours,
     IEditorFormatMapService editorFormatMapService
     )
 {
     this.coverageColoursProvider = coverageColoursProvider;
     this.coverageColours         = coverageColours;
     editorFormatMap = editorFormatMapService.GetEditorFormatMap("text");
     coverageColours.ColoursChanged += CoverageColours_ColoursChanged;
 }
Пример #29
0
        IWpfTextViewMargin IWpfTextViewMarginProvider.CreateMargin(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin marginContainer)
        {
            if (!_isVisualAssistInstalled || !_isRegistryFixedNeeded)
            {
                return(null);
            }

            var editorFormatMap = _editorFormatMapService.GetEditorFormatMap(wpfTextViewHost.TextView);

            return(new VisualAssistMargin(this, editorFormatMap));
        }
 public DiagnosticsSuggestionTaggerProvider(
     IEditorFormatMapService editorFormatMapService,
     IDiagnosticService diagnosticService,
     IForegroundNotificationService notificationService,
     [ImportMany] IEnumerable <Lazy <IAsynchronousOperationListener, FeatureMetadata> > listeners)
     : base(diagnosticService, notificationService, listeners)
 {
     _editorFormatMap = editorFormatMapService.GetEditorFormatMap("text");
     _editorFormatMap.FormatMappingChanged += OnFormatMappingChanged;
     _suggestionTag = new SuggestionTag(_editorFormatMap);
 }
Пример #31
0
        public MarginCore(IWpfTextView textView, IClassificationFormatMapService classificationFormatMapService, IEditorFormatMapService editorFormatMapService)
        {
            _textView = textView;

            _classificationFormatMap = classificationFormatMapService.GetClassificationFormatMap(textView);

            _editorFormatMap = editorFormatMapService.GetEditorFormatMap(textView);
            _editorFormatMap.FormatMappingChanged += HandleFormatMappingChanged;

            _textView.Options.OptionChanged += HandleOptionChanged;

            _textView.Closed += (sender, e) =>
            {
                _editorFormatMap.FormatMappingChanged -= HandleFormatMappingChanged;
            };

            UpdateBrushes();
        }
        public HistorySelectionTextAdornment(IWpfTextView textView, IEditorFormatMapService editorFormatMapService, IRHistoryProvider historyProvider) {
            _textView = textView;
            _layer = textView.GetAdornmentLayer("HistorySelectionTextAdornment");

            _editorFormatMap = editorFormatMapService.GetEditorFormatMap(_textView);
            _history = historyProvider.GetAssociatedRHistory(_textView);

            // Advise to events
            _editorFormatMap.FormatMappingChanged += OnFormatMappingChanged;
            _textView.VisualElement.GotKeyboardFocus += OnGotKeyboardFocus;
            _textView.VisualElement.LostKeyboardFocus += OnLostKeyboardFocus;
            _textView.LayoutChanged += OnLayoutChanged;
            _textView.Closed += OnClosed;
            _history.SelectionChanged += OnSelectionChanged;

            _activeVisualToolset = CreateVisualToolset(ActiveSelectionPropertiesName, SystemColors.HighlightColor);
            _inactiveVisualToolset = CreateVisualToolset(InactiveSelectionPropertiesName, SystemColors.GrayTextColor);
            Redraw();
        }
Пример #33
0
        public MarginCore(IWpfTextView textView, ITextDocumentFactoryService textDocumentFactoryService, IClassificationFormatMapService classificationFormatMapService, IEditorFormatMapService editorFormatMapService, IGitCommands gitCommands)
        {
            _textView = textView;

            _classificationFormatMap = classificationFormatMapService.GetClassificationFormatMap(textView);

            _editorFormatMap = editorFormatMapService.GetEditorFormatMap(textView);
            _editorFormatMap.FormatMappingChanged += HandleFormatMappingChanged;

            _gitCommands = gitCommands;

            _parser = new DiffUpdateBackgroundParser(textView.TextBuffer, textView.TextDataModel.DocumentBuffer, TaskScheduler.Default, textDocumentFactoryService, GitCommands);
            _parser.ParseComplete += HandleParseComplete;
            _parser.RequestParse(false);

            _textView.Closed += (sender, e) =>
            {
                _editorFormatMap.FormatMappingChanged -= HandleFormatMappingChanged;
                _parser.ParseComplete -= HandleParseComplete;
            };

            UpdateBrushes();
        }
        public DiagnosticStripeMargin(IWpfTextView textView, IVerticalScrollBar scrollBar,
            IEditorFormatMapService editorFormatMapService) {

            _textView          = textView;
            _isDisposed        = false;
            _scrollBar         = scrollBar;
            _editorFormatMap   = editorFormatMapService.GetEditorFormatMap(textView);
            _diagnosticService = DiagnosticService.GetOrCreate(textView);

            ClipToBounds      = true;
            Background        = null;
            VerticalAlignment = VerticalAlignment.Stretch;
            Focusable         = false;
            Width             = 10;

            RenderOptions.SetEdgeMode(this, System.Windows.Media.EdgeMode.Aliased);

            _diagnosticService.DiagnosticsChanging += OnDiagnosticsChanging;
            _diagnosticService.DiagnosticsChanged  += OnDiagnosticsChanged;
            _editorFormatMap.FormatMappingChanged  += OnFormatMappingChanged;
            _scrollBar.TrackSpanChanged            += OnTrackSpanChanged;
            _textView.LayoutChanged                += OnTextViewLayoutChanged;
            _textView.Closed                       += OnTextViewClosed;
        }
Пример #35
0
#pragma warning restore 0169

		public WpfTextView(ITextViewModel textViewModel, ITextViewRoleSet roles, IEditorOptions parentOptions, IEditorOptionsFactoryService editorOptionsFactoryService, ICommandService commandService, ISmartIndentationService smartIndentationService, IFormattedTextSourceFactoryService formattedTextSourceFactoryService, IViewClassifierAggregatorService viewClassifierAggregatorService, ITextAndAdornmentSequencerFactoryService textAndAdornmentSequencerFactoryService, IClassificationFormatMapService classificationFormatMapService, IEditorFormatMapService editorFormatMapService, IAdornmentLayerDefinitionService adornmentLayerDefinitionService, ILineTransformProviderService lineTransformProviderService, ISpaceReservationStackProvider spaceReservationStackProvider, IWpfTextViewConnectionListenerServiceProvider wpfTextViewConnectionListenerServiceProvider, IBufferGraphFactoryService bufferGraphFactoryService, Lazy<IWpfTextViewCreationListener, IDeferrableContentTypeAndTextViewRoleMetadata>[] wpfTextViewCreationListeners) {
			if (textViewModel == null)
				throw new ArgumentNullException(nameof(textViewModel));
			if (roles == null)
				throw new ArgumentNullException(nameof(roles));
			if (parentOptions == null)
				throw new ArgumentNullException(nameof(parentOptions));
			if (editorOptionsFactoryService == null)
				throw new ArgumentNullException(nameof(editorOptionsFactoryService));
			if (commandService == null)
				throw new ArgumentNullException(nameof(commandService));
			if (smartIndentationService == null)
				throw new ArgumentNullException(nameof(smartIndentationService));
			if (formattedTextSourceFactoryService == null)
				throw new ArgumentNullException(nameof(formattedTextSourceFactoryService));
			if (viewClassifierAggregatorService == null)
				throw new ArgumentNullException(nameof(viewClassifierAggregatorService));
			if (textAndAdornmentSequencerFactoryService == null)
				throw new ArgumentNullException(nameof(textAndAdornmentSequencerFactoryService));
			if (classificationFormatMapService == null)
				throw new ArgumentNullException(nameof(classificationFormatMapService));
			if (editorFormatMapService == null)
				throw new ArgumentNullException(nameof(editorFormatMapService));
			if (adornmentLayerDefinitionService == null)
				throw new ArgumentNullException(nameof(adornmentLayerDefinitionService));
			if (lineTransformProviderService == null)
				throw new ArgumentNullException(nameof(lineTransformProviderService));
			if (spaceReservationStackProvider == null)
				throw new ArgumentNullException(nameof(spaceReservationStackProvider));
			if (wpfTextViewCreationListeners == null)
				throw new ArgumentNullException(nameof(wpfTextViewCreationListeners));
			if (wpfTextViewConnectionListenerServiceProvider == null)
				throw new ArgumentNullException(nameof(wpfTextViewConnectionListenerServiceProvider));
			if (bufferGraphFactoryService == null)
				throw new ArgumentNullException(nameof(bufferGraphFactoryService));
			mouseHoverHelper = new MouseHoverHelper(this);
			physicalLineCache = new PhysicalLineCache(32);
			visiblePhysicalLines = new List<PhysicalLine>();
			invalidatedRegions = new List<SnapshotSpan>();
			this.formattedTextSourceFactoryService = formattedTextSourceFactoryService;
			zoomLevel = ZoomConstants.DefaultZoom;
			DsImage.SetZoom(VisualElement, zoomLevel / 100);
			this.adornmentLayerDefinitionService = adornmentLayerDefinitionService;
			this.lineTransformProviderService = lineTransformProviderService;
			this.wpfTextViewCreationListeners = wpfTextViewCreationListeners.Where(a => roles.ContainsAny(a.Metadata.TextViewRoles)).ToArray();
			recreateLineTransformProvider = true;
			normalAdornmentLayerCollection = new AdornmentLayerCollection(this, LayerKind.Normal);
			overlayAdornmentLayerCollection = new AdornmentLayerCollection(this, LayerKind.Overlay);
			underlayAdornmentLayerCollection = new AdornmentLayerCollection(this, LayerKind.Underlay);
			IsVisibleChanged += WpfTextView_IsVisibleChanged;
			Properties = new PropertyCollection();
			TextViewModel = textViewModel;
			BufferGraph = bufferGraphFactoryService.CreateBufferGraph(TextViewModel.VisualBuffer);
			Roles = roles;
			Options = editorOptionsFactoryService.GetOptions(this);
			Options.Parent = parentOptions;
			ViewScroller = new ViewScroller(this);
			hasKeyboardFocus = IsKeyboardFocusWithin;
			oldViewState = new ViewState(this);
			aggregateClassifier = viewClassifierAggregatorService.GetClassifier(this);
			textAndAdornmentSequencer = textAndAdornmentSequencerFactoryService.Create(this);
			classificationFormatMap = classificationFormatMapService.GetClassificationFormatMap(this);
			editorFormatMap = editorFormatMapService.GetEditorFormatMap(this);
			spaceReservationStack = spaceReservationStackProvider.Create(this);

			textLayer = new TextLayer(GetAdornmentLayer(PredefinedAdornmentLayers.Text));
			Selection = new TextSelection(this, GetAdornmentLayer(PredefinedAdornmentLayers.Selection), editorFormatMap);
			TextCaret = new TextCaret(this, GetAdornmentLayer(PredefinedAdornmentLayers.Caret), smartIndentationService, classificationFormatMap);

			Children.Add(underlayAdornmentLayerCollection);
			Children.Add(normalAdornmentLayerCollection);
			Children.Add(overlayAdornmentLayerCollection);
			Cursor = Cursors.IBeam;
			Focusable = true;
			FocusVisualStyle = null;
			InitializeOptions();

			Options.OptionChanged += EditorOptions_OptionChanged;
			TextBuffer.ChangedLowPriority += TextBuffer_ChangedLowPriority;
			TextViewModel.DataModel.ContentTypeChanged += DataModel_ContentTypeChanged;
			aggregateClassifier.ClassificationChanged += AggregateClassifier_ClassificationChanged;
			textAndAdornmentSequencer.SequenceChanged += TextAndAdornmentSequencer_SequenceChanged;
			classificationFormatMap.ClassificationFormatMappingChanged += ClassificationFormatMap_ClassificationFormatMappingChanged;
			editorFormatMap.FormatMappingChanged += EditorFormatMap_FormatMappingChanged;
			spaceReservationStack.GotAggregateFocus += SpaceReservationStack_GotAggregateFocus;
			spaceReservationStack.LostAggregateFocus += SpaceReservationStack_LostAggregateFocus;

			UpdateBackground();
			CreateFormattedLineSource(ViewportWidth);
			InitializeZoom();
			UpdateRemoveExtraTextLineVerticalPixels();

			if (Roles.Contains(PredefinedTextViewRoles.Interactive))
				RegisteredCommandElement = commandService.Register(VisualElement, this);
			else
				RegisteredCommandElement = NullRegisteredCommandElement.Instance;

			wpfTextViewConnectionListenerServiceProvider.Create(this);
			NotifyTextViewCreated(TextViewModel.DataModel.ContentType, null);
		}
Пример #36
0
        /// <summary>
        /// Creates a <see cref="MarginCore"/> for a given <see cref="IWpfTextView"/>.
        /// </summary>
        /// <param name="textView">The <see cref="IWpfTextView"/> to attach the margin to.</param>
        /// <param name="textDocumentFactoryService">Service that creates, loads, and disposes text documents.</param>
        /// <param name="vsServiceProvider">Visual Studio service provider.</param>
        /// <param name="formatMapService">Service that provides the <see cref="IEditorFormatMap"/>.</param>
        /// <param name="scrollMapFactoryService">Factory that creates or reuses an <see cref="IScrollMap"/> for an <see cref="ITextView"/>.</param>
        public MarginCore(IWpfTextView textView, ITextDocumentFactoryService textDocumentFactoryService, SVsServiceProvider vsServiceProvider, IEditorFormatMapService formatMapService, IScrollMapFactoryService scrollMapFactoryService)
        {
            Debug.WriteLine("Entering constructor.", Properties.Resources.ProductName);

            _textView = textView;
            if (!textDocumentFactoryService.TryGetTextDocument(_textView.TextBuffer, out _textDoc))
            {
                Debug.WriteLine("Can not retrieve TextDocument. Margin is disabled.", Properties.Resources.ProductName);
                _isEnabled = false;
                return;
            }

            _formatMap = formatMapService.GetEditorFormatMap(textView);
            _marginSettings = new MarginSettings(_formatMap);

            _scrollMap = scrollMapFactoryService.Create(textView);

            var dte = (DTE2)vsServiceProvider.GetService(typeof(DTE));
            _tfExt = dte.GetObject(typeof(TeamFoundationServerExt).FullName);
            Debug.Assert(_tfExt != null, "_tfExt is null.");
            _tfExt.ProjectContextChanged += OnTfExtProjectContextChanged;

            UpdateMargin();
        }