Exemplo n.º 1
0
        private IEnumerable <Commit> GetSimplifiedCommits()
        {
            foreach (var commit in Commits)
            {
                if (commit.ParentIds.Count() == 1 && commit.ChildIds.Count() == 1 && !this.Refs.Any(r => r.Id == commit.Id))
                {
                    var cid = commit.ChildIds[0];
                    var pid = commit.ParentIds[0];

                    var parent = Commits.Where(c => c.Id == pid).FirstOrDefault();
                    var child  = Commits.Where(c => c.Id == cid).FirstOrDefault();

                    if (parent != null && child != null)
                    {
                        int x1 = GetLane(parent.Id);
                        int x2 = GetLane(commit.Id);
                        int x3 = GetLane(child.Id);

                        if (x1 == x2 && x2 == x3)
                        {
                            commit.deleted = true;
                            parent.ChildIds[parent.ChildIds.IndexOf(commit.Id)] = cid;
                            child.ParentIds[child.ParentIds.IndexOf(commit.Id)] = pid;
                        }
                        //commit.ChildIds.Clear();
                        //commit.ParentIds.Clear();
                    }
                }
            }

            return(commits.Where(c => !c.deleted));
        }
Exemplo n.º 2
0
        void UpdateContent(Tuple <double, double, double, double> screenBoundaries)
        {
            if (Model.Commits.Count == 0)
            {
                return;
            }
            List <CommitNodeViewModel>  badCommits  = Commits.Where(commit => commit.Location.X > screenBoundaries.Item3 || commit.Location.X + 251 < screenBoundaries.Item1).ToList();
            List <BranchLabelViewModel> badBranches = Branches.Where(branch => branch.Location.X > screenBoundaries.Item3 || branch.Location.X + 251 < screenBoundaries.Item1 && branch.HitTestVisible).ToList();
            List <Edge> badEdges = Edges.Where(edge => (edge.Sink.X < screenBoundaries.Item1 - 251 && edge.Source.X < screenBoundaries.Item1 - 251) || (edge.Sink.X > screenBoundaries.Item3 + 300 && edge.Source.X > screenBoundaries.Item3 + 300)).ToList();

            foreach (var edge in badEdges)
            {
                Edges.Remove(edge); View.Children.Remove(edge);
            }
            foreach (var bb in badBranches)
            {
                View.Children.Remove(bb.Control); Branches.Remove(bb); bb.UnsubscribeModel();
            }
            List <Point> badCommitLocations = badCommits.Select(commit => commit.Location).ToList();

            foreach (var bc in badCommits)
            {
                View.Children.Remove(bc.Control); Commits.Remove(bc); bc.UnsubscribeModel();
            }
            List <Point>            commitLocations = Commits.Select(commit => commit.Location).ToList();
            List <Point>            branchLocations = Branches.Select(branch => branch.Location).ToList();
            List <CommitNodeModel>  newCommits = new List <CommitNodeModel>();
            List <BranchLabelModel> newBranches = new List <BranchLabelModel>();
            int f, c;

            for (f = 0; f < Model.Commits.Count; f++)
            {
                if (Model.Commits[f].Location.X + 251 >= screenBoundaries.Item1)
                {
                    break;
                }
            }
            for (c = f; c < Model.Commits.Count; c++)
            {
                if (Model.Commits[c].Location.X <= screenBoundaries.Item3)
                {
                    if (!commitLocations.Contains(Model.Commits[c].Location))
                    {
                        newCommits.Add(Model.Commits[c]);
                    }
                }
                else
                {
                    break;
                }
            }
            foreach (CommitNodeModel m in newCommits)
            {
                CommitNodeView      v  = new CommitNodeView();
                CommitNodeViewModel vm = new CommitNodeViewModel(m, v);
                v.Update();
                Commits.Add(vm);
                View.Children.Add(v);
            }
            for (c = 0; c < Model.Branches.Count; c++)
            {
                if (!branchLocations.Contains(Model.Branches[c].Location) && newCommits.Any(commit => commit.Commit == Model.Branches[c].Branch.Tip))
                {
                    newBranches.Add(Model.Branches[c]);
                }
            }
            foreach (BranchLabelModel m in newBranches)
            {
                BranchLabelView      v  = new BranchLabelView();
                BranchLabelViewModel vm = new BranchLabelViewModel(m, v);
                View.Children.Add(v);
                Branches.Add(vm);
            }
            foreach (var m in newCommits)
            {
                foreach (var pair in Model.Edges[m])
                {
                    Point source = new Point(pair.Item2.Location.X, pair.Item2.Location.Y + 20);
                    Point sink   = new Point(pair.Item1.Location.X + pair.Item1.MaxWidth, pair.Item1.Location.Y + 20);
                    if (!Edges.Any(edge => edge.Source == source && edge.Sink == sink))
                    {
                        Edge edge = new Edge()
                        {
                            Source = source, Sink = sink, StrokeThickness = 2, Stroke = new SolidColorBrush(Colors.Gray)
                        };
                        Edges.Add(edge);
                        View.Children.Add(edge);
                    }
                }
            }
        }
Exemplo n.º 3
0
 /// <summary>
 ///     Get commits for a specific commit type.
 /// </summary>
 /// <param name="type">Type of commit to get.</param>
 /// <returns>List of commits that match.</returns>
 public IEnumerable <ConventionalCommit> GetCommits(ConventionalTypes type)
 {
     return(Commits.Where(commit => commit.Type == type));
 }