コード例 #1
0
 public void SetInputSource(string path, ISourceLineStatistics line, ISourceLinesQueryResult lines)
 {
     Caption = $"Hot Lines - {Path.GetFileName(path)}";
     ClearEditor();
     CreateEditor(path);
     _textView.SetCaretPos((int)line.StartLine, (int)line.StartColumn);
     _windowControl.View.Content = _textViewHost;
     new HotLineAdornment(_textViewHost.TextView, line, lines);
 }
コード例 #2
0
        public HotLineAdornment(IWpfTextView view, ISourceLineStatistics line, ISourceLinesQueryResult queryResult)
        {
            _view = view ?? throw new ArgumentNullException(nameof(view));

            Foo(line, queryResult);

            _layer = view.GetAdornmentLayer("HotLineAdornment");
            _view.LayoutChanged += OnLayoutChanged;

            _pen = new Pen(Brushes.Blue, 0.5);
            _pen.Freeze();
        }
コード例 #3
0
        public void ShowSourceFile(ISession session, ISourceLineStatistics line, ISourceLinesQueryResult lines)
        {
            var path = session.GetSourceFilePath(line.SourceFileId);

            if (string.IsNullOrEmpty(path))
            {
                ShowMessage(MessageDialogType.Warning, "Source file is missing");
                return;
            }
            if (!File.Exists(Path.GetFullPath(path)))
            {
                if (ShowMessage(MessageDialogType.Question, "Source file not found. Would you like to locate it yourself?") == 6) // Yes
                {
                    var fileName = Path.GetFileName(path);
                    using (var openFileDialog = new OpenFileDialog {
                        Filter = $"{fileName}|{fileName}"
                    })
                    {
                        if (openFileDialog.ShowDialog() == DialogResult.OK)
                        {
                            path = openFileDialog.FileName;
                            session.SetSourceFilePath(line.SourceFileId, path);
                        }
                        else
                        {
                            return;
                        }
                    }
                }
                else
                {
                    return;
                }
            }
            var x = GetToolWindow <HotLinesToolWindow>();

            x.SetInputSource(path, line, lines);
            x.Show();
        }
コード例 #4
0
        private void Foo(ISourceLineStatistics lineToShow, ISourceLinesQueryResult queryResult)
        {
            var fileId = lineToShow.SourceFileId;

            _linesToAdorn = new List <LineData>();
            foreach (var line in queryResult.Lines.Where(l => l.SourceFileId == fileId))
            {
                var exists = false;
                foreach (var ld in _linesToAdorn)
                {
                    if (ld.EndColumn == line.EndColumn && ld.EndLine == line.EndLine && ld.StartColumn == line.StartColumn && ld.StartLine == line.StartLine)
                    {
                        exists    = true;
                        ld.Value += GetValue(queryResult.StatisticsType, queryResult.Inclusive, line);
                        break;
                    }
                }

                if (exists == false)
                {
                    _linesToAdorn.Add(new LineData
                    {
                        StartLine   = line.StartLine,
                        StartColumn = line.StartColumn,
                        EndLine     = line.EndLine,
                        EndColumn   = line.EndColumn,
                        Value       = GetValue(queryResult.StatisticsType, queryResult.Inclusive, line)
                    });
                }
            }

            var maxValue = _linesToAdorn.Max(data => data.Value);

            foreach (var ld in _linesToAdorn)
            {
                ld.Intensity = ld.Value * 100.0 / maxValue;
            }
        }
コード例 #5
0
        private void UpdateControls(IActiveSession activeSession, bool updateTreeInput)
        {
            ListsGrid1.RowDefinitions.Clear();
            ListsGrid1.Children.Clear();

            var row     = 0;
            var methods =
                activeSession.SessionModel.GetTopMethods(activeSession.CurrentThreadId, activeSession.StatisticsType);

            if (methods.Methods.Count > 0)
            {
                ListsGrid1.RowDefinitions.Add(new RowDefinition
                {
                    Height = new GridLength(1, GridUnitType.Star)
                });
                _topMethods.SetInputSource(methods);
                ListsGrid1.Children.Add(_topMethods);
                Grid.SetRow(_topMethods, row++);
                Grid.SetColumn(_topMethods, 0);

                ListsGrid1.RowDefinitions.Add(new RowDefinition
                {
                    Height = GridLength.Auto
                });
                var splitter = new GridSplitter
                {
                    Height = 5,
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    VerticalAlignment   = VerticalAlignment.Center,
                };
                ListsGrid1.Children.Add(splitter);
                Grid.SetRow(splitter, row++);
                Grid.SetColumn(splitter, 0);
                Grid.SetColumn(splitter, 0);
            }

            ListsGrid1.RowDefinitions.Add(new RowDefinition
            {
                Height = new GridLength(1, GridUnitType.Star)
            });
            ListsGrid1.Children.Add(_callTree);
            Grid.SetRow(_callTree, row);
            Grid.SetColumn(_callTree, 0);
            if (updateTreeInput)
            {
                _callTree.SetItemsSource(activeSession.SessionModel.GetCallTree(activeSession.CurrentThreadId),
                                         activeSession.StatisticsType);
            }
            else
            {
                _callTree.StatisticsType = activeSession.StatisticsType;
            }


            ListsGrid2.RowDefinitions.Clear();
            ListsGrid2.Children.Clear();

            row = 0;
            var paths = activeSession.SessionModel.GetHotPathes(activeSession.CurrentThreadId, activeSession.StatisticsType);

            if (paths.Methods.Count > 0)
            {
                ListsGrid2.RowDefinitions.Add(new RowDefinition
                {
                    Height = new GridLength(1, GridUnitType.Star)
                });
                _hotPathes.SetItemsSource(paths);
                ListsGrid2.Children.Add(_hotPathes);
                Grid.SetRow(_hotPathes, row);
                Grid.SetColumn(_hotPathes, 0);
            }

            _sourceLines = activeSession.SessionModel.GetTopLines(activeSession.CurrentThreadId, activeSession.StatisticsType);
            TopLines.SetItemsSource(_sourceLines);
        }