Пример #1
0
        /// <summary>
        ///   Creates a <see cref="GitDiffMargin" /> for a given <see cref="IWpfTextView" /> .
        /// </summary>
        /// <param name="textView"> The <see cref="IWpfTextView" /> to attach the margin to. </param>
        internal DiffMargin(IWpfTextView textView, DiffMarginFactory factory)
        {
            _textView = textView;
            _classificationFormatMap = factory.ClassificationFormatMapService.GetClassificationFormatMap(textView);
            _editorFormatMap         = factory.EditorFormatMapService.GetEditorFormatMap(textView);

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

            _textView.Options.OptionChanged += HandleOptionChanged;

            _gitDiffBarControl             = new DiffMarginControl();
            _viewModel                     = new DiffMarginViewModel(this, _textView, factory.TextDocumentFactoryService, new GitCommands());
            _gitDiffBarControl.DataContext = _viewModel;
            _gitDiffBarControl.Width       = MarginWidth;
            UpdateVisibility();
        }
        /// <summary>
        ///   Creates a <see cref="GitDiffMargin" /> for a given <see cref="IWpfTextView" /> .
        /// </summary>
        /// <param name="textView"> The <see cref="IWpfTextView" /> to attach the margin to. </param>
        internal DiffMargin(IWpfTextView textView, DiffMarginFactory factory)
        {
            _textView = textView;
            _classificationFormatMap = factory.ClassificationFormatMapService.GetClassificationFormatMap(textView);
            _editorFormatMap = factory.EditorFormatMapService.GetEditorFormatMap(textView);

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

            _textView.Options.OptionChanged += HandleOptionChanged;

            _gitDiffBarControl = new DiffMarginControl();
            _viewModel = new DiffMarginViewModel(this, _textView, factory.TextDocumentFactoryService, new GitCommands());
            _gitDiffBarControl.DataContext = _viewModel;
            _gitDiffBarControl.Width = MarginWidth;
            UpdateVisibility();
        }