private void UpdateCommits(
            IReadOnlyList <Commit> sourceCommits,
            RepositoryViewModel repositoryViewModel)
        {
            List <CommitViewModel> commits = repositoryViewModel.Commits;
            var commitsById = repositoryViewModel.CommitsById;

            SetNumberOfItems(
                commits,
                sourceCommits.Count,
                i => new CommitViewModel(
                    branchService, diffService, themeService, repositoryCommands, commitsService, tagService));

            commitsById.Clear();
            int graphWidth = repositoryViewModel.GraphWidth;

            int index = 0;

            foreach (Commit commit in sourceCommits)
            {
                CommitViewModel commitViewModel = commits[index];
                commitsById[commit.Id] = commitViewModel;

                commitViewModel.Commit   = commit;
                commitViewModel.RowIndex = index++;

                commitViewModel.BranchViewModel = GetBranchViewModel(repositoryViewModel, commit.Branch);

                int x = commitViewModel.BranchViewModel?.X ?? -20;
                int y = Converters.ToY(commitViewModel.RowIndex);

                commitViewModel.XPoint = commitViewModel.IsEndPoint
                                        ? 3 + x
                                        : commitViewModel.IsMergePoint ? 2 + x : 4 + x;

                commitViewModel.GraphWidth = graphWidth;
                commitViewModel.Width      = repositoryViewModel.Width - 35;

                commitViewModel.Rect = new Rect(0, y, commitViewModel.Width, CommitHeight);

                commitViewModel.Brush      = themeService.GetBranchBrush(commit.Branch);
                commitViewModel.BrushInner = commitViewModel.Brush;
                commitViewModel.SetNormal(GetSubjectBrush(commit));
                commitViewModel.BranchToolTip = GetBranchToolTip(commit.Branch);

                if (commitViewModel.IsMergePoint &&
                    !commit.HasSecondParent &&
                    (commit == commit.Branch.TipCommit || commit == commit.Branch.FirstCommit))
                {
                    commitViewModel.BrushInner = themeService.Theme.GetDarkerBrush(commitViewModel.Brush);
                }

                commitViewModel.NotifyAll();
            }
        }
Exemplo n.º 2
0
        private void UpdateStatusIndicators()
        {
            Repository repository = repositoryService.Repository;

            CurrentBranchName  = repository.CurrentBranch.Name;
            CurrentBranchBrush = themeService.GetBranchBrush(repository.CurrentBranch);

            IEnumerable <Branch> remoteAheadBranches = repository.Branches
                                                       .Where(b => b.RemoteAheadCount > 0).ToList();

            string remoteAheadText = remoteAheadBranches.Any()
                                ? "Branches with remote commits:\n" : null;

            foreach (Branch branch in remoteAheadBranches)
            {
                remoteAheadText += $"\n    {branch.RemoteAheadCount}\t{branch.Name}";
            }

            RemoteAheadText = remoteAheadText;

            IEnumerable <Branch> localAheadBranches = repository.Branches
                                                      .Where(b => b.IsLocal && (b.IsRemote || b.IsLocalPart) && b.LocalAheadCount > 0).ToList();

            string localAheadText = localAheadBranches.Any()
                                ? "Branches with local commits:\n" : null;

            foreach (Branch branch in localAheadBranches)
            {
                localAheadText += $"\n    {branch.LocalAheadCount}\t{branch.Name}";
            }

            LocalAheadText = localAheadText;

            Commit uncommitted = repository.UnComitted;

            UnCommited = uncommitted;

            ConflictsText = repository.Status.Conflicted > 0
                                ? $"Conflicts in {repository.Status.Conflicted} files\""
                                : null;
        }