Пример #1
0
        private void RepaintComplexity(ITextSnapshot textSnapshot)
        {
            layer.RemoveAllAdornments();
            options.LoadSettingsFromStorage();

            foreach (var pair in methodToText)
            {
                var geometry        = view.TextViewLines.GetMarkerGeometry(textSnapshot.GetLineFromLineNumber(pair.Key.Decleration.Line).Extent);
                var isMethodVisible = geometry != null;
                if (!isMethodVisible)
                {
                    continue;
                }

                string methodText = methodToText[pair.Key];

                var complexityViewModel = new ComplexityViewModel(options);
                var complexityView      = new ComplexityView
                {
                    DataContext = complexityViewModel
                };
                new Task(() => complexityViewModel.UpdateComplexity(complexityCalculator.Calculate(methodText))).Start();

                Canvas.SetLeft(complexityView, geometry.Bounds.Left);
                Canvas.SetTop(complexityView, geometry.Bounds.Top);

                layer.AddAdornment(AdornmentPositioningBehavior.ViewportRelative, null, null, complexityView, null);
            }
        }
Пример #2
0
        private void RepaintComplexity(ITextSnapshot textSnapshot)
        {
            layer.RemoveAllAdornments();
            options.LoadSettingsFromStorage();

            foreach (var pair in syntaxNodes)
            {
                var line            = textSnapshot.GetLineFromLineNumber(pair.Key.Declaration.Line);
                var geometry        = view.TextViewLines.GetMarkerGeometry(line.Extent);
                var isMethodVisible = geometry != null;
                if (!isMethodVisible)
                {
                    continue;
                }

                var complexityViewModel = new ComplexityViewModel(options);
                var complexityView      = new ComplexityView
                {
                    DataContext = complexityViewModel
                };
                CreateTask(complexityViewModel, pair.Key).Start();

                Canvas.SetLeft(complexityView, geometry.Bounds.Left);
                Canvas.SetTop(complexityView, geometry.Bounds.Top);

                layer.AddAdornment(AdornmentPositioningBehavior.ViewportRelative, null, null, complexityView, null);
            }
        }