Ejemplo n.º 1
0
        private void BlameFile_MouseMove(object sender, MouseEventArgs e)
        {
            if (_blame == null)
            {
                return;
            }

            int line = BlameFile.GetLineFromVisualPosY(e.Y);

            if (line >= _blame.Lines.Count)
            {
                return;
            }

            GitBlameHeader blameHeader = _blame.FindHeaderForCommitGuid(_blame.Lines[line].CommitGuid);

            if (blameHeader != _lastBlameHeader)
            {
                BlameCommitter.ClearHighlighting();
                BlameFile.ClearHighlighting();
                int startLine = -1;
                int prevLine  = -1;
                for (int i = 0; i < _blame.Lines.Count; i++)
                {
                    if (_blame.Lines[i].CommitGuid == blameHeader.CommitGuid)
                    {
                        if (prevLine != i - 1 && startLine != -1)
                        {
                            BlameCommitter.HighlightLines(startLine, prevLine, Color.FromArgb(225, 225, 225));
                            BlameFile.HighlightLines(startLine, prevLine, Color.FromArgb(225, 225, 225));
                            startLine = -1;
                        }

                        prevLine = i;
                        if (startLine == -1)
                        {
                            startLine = i;
                        }
                    }
                }

                if (startLine != -1)
                {
                    BlameCommitter.HighlightLines(startLine, prevLine, Color.FromArgb(225, 225, 225));
                    BlameFile.HighlightLines(startLine, prevLine, Color.FromArgb(225, 225, 225));
                }

                BlameCommitter.Refresh();
                BlameFile.Refresh();
                _lastBlameHeader = blameHeader;
            }
        }
Ejemplo n.º 2
0
        private void HighlightLinesForCommit([CanBeNull] GitBlameCommit commit)
        {
            if (commit == _highlightedCommit)
            {
                return;
            }

            _highlightedCommit = commit;

            BlameCommitter.ClearHighlighting();
            BlameFile.ClearHighlighting();

            if (commit == null)
            {
                return;
            }

            int startLine = -1;
            int prevLine  = -1;

            for (int i = 0; i < _blame.Lines.Count; i++)
            {
                if (ReferenceEquals(_blame.Lines[i].Commit, commit))
                {
                    if (prevLine != i - 1 && startLine != -1)
                    {
                        BlameCommitter.HighlightLines(startLine, prevLine, SystemColors.ControlLight);
                        BlameFile.HighlightLines(startLine, prevLine, SystemColors.ControlLight);
                        startLine = -1;
                    }

                    prevLine = i;
                    if (startLine == -1)
                    {
                        startLine = i;
                    }
                }
            }

            if (startLine != -1)
            {
                BlameCommitter.HighlightLines(startLine, prevLine, SystemColors.ControlLight);
                BlameFile.HighlightLines(startLine, prevLine, SystemColors.ControlLight);
            }

            BlameCommitter.Refresh();
            BlameFile.Refresh();
        }