Beispiel #1
0
        private void ViewClosed(object sender, EventArgs e)
        {
            if (_codingConventionsCancellationTokenSource != default(CancellationTokenSource))
            {
                _codingConventionsCancellationTokenSource.Cancel();
            }

            _view.LayoutChanged -= OnViewLayoutChanged;
            _view.Closed        -= ViewClosed;
            if (_settingsChanged != null)
            {
                _settingsChanged.PropertyChanged -= SettingsChanged;
                _settingsChanged = null;
            }

            if (_guidelineBrush != null)
            {
                _guidelineBrush.BrushChanged -= GuidelineBrushChanged;
                _guidelineBrush = null;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Creates editor column guidelines
        /// </summary>
        /// <param name="view">The <see cref="IWpfTextView"/> upon which the adornment will be drawn</param>
        /// <param name="settings">The guideline settings.</param>
        /// <param name="guidelineBrush">The guideline brush.</param>
        /// <param name="codingConventionsManager">The coding conventions manager for handling .editorconfig settings.</param>
        /// <param name="telemetry">Telemetry interface.</param>
        public ColumnGuideAdornment(IWpfTextView view, ITextEditorGuidesSettings settings, GuidelineBrush guidelineBrush, ICodingConventionsManager codingConventionsManager)
        {
            _view           = view;
            _guidelineBrush = guidelineBrush;
            _guidelineBrush.BrushChanged += GuidelineBrushChanged;
            _strokeParameters             = StrokeParameters.FromBrush(_guidelineBrush.Brush);

            if (codingConventionsManager != null && view.TryGetTextDocument(out var textDocument))
            {
                _codingConventionsCancellationTokenSource = new CancellationTokenSource();
                var fireAndForgetTask = LoadGuidelinesFromEditorConfigAsync(codingConventionsManager, textDocument.FilePath);
            }

            InitializeGuidelines(settings.GuideLinePositionsInChars);

            _view.LayoutChanged += OnViewLayoutChanged;
            _settingsChanged     = settings as INotifyPropertyChanged;
            if (_settingsChanged != null)
            {
                _settingsChanged.PropertyChanged += SettingsChanged;
            }

            _view.Closed += ViewClosed;
        }