Beispiel #1
0
 public GraphEdge(GraphLink link)
     : base(link.FromVersion, link.ToVersion, new GraphArrow(link), new NullArrow(link))
 {
     Link = link;
 }
Beispiel #2
0
 public NullArrow(GraphLink link)
     : base(link)
 {
 }
Beispiel #3
0
 public GraphArrow(GraphLink link)
 {
     Link = link;
 }
Beispiel #4
0
        private IGraph CreateDotGraph()
        {
            List <GraphNode> definitions = new List <GraphNode>();
            List <GraphLink> links       = new List <GraphLink>();

            int?limit  = (RevisionLimit != -1) ? RevisionLimit : (int?)null;
            var result = _areaVM.Area.GetDAG(limit);

            int nextColourIndex = 0;

            Color[] colours = new Color[] { Colors.DarkOrange, Colors.Green, Colors.Blue, Colors.Cyan, Colors.Magenta, Colors.Red };
            Dictionary <Guid, Tuple <Color, Branch> > branchInfoMap = new Dictionary <Guid, Tuple <Color, Branch> >();

            foreach (var x in result.Objects)
            {
                Tuple <Color, Branch> branchInfo;
                if (!branchInfoMap.TryGetValue(x.Object.Branch, out branchInfo))
                {
                    Color colour;
                    if (x.Object.Parent == null)
                    {
                        colour = Colors.White;
                    }
                    else
                    {
                        colour          = colours[nextColourIndex];
                        nextColourIndex = (nextColourIndex + 1) % colours.Length;
                    }
                    branchInfo = new Tuple <Color, Branch>(colour, _areaVM.Area.GetBranch(x.Object.Branch));
                    branchInfoMap.Add(x.Object.Branch, branchInfo);
                }

                Color nodeColor = branchInfo.Item1;

                string nodeLabel = x.Object.ID.ToString().Substring(0, 8);
                nodeLabel += string.Format("\n{0}", x.Object.Author);
                if (ShowMessages)
                {
                    nodeLabel += string.Format("\n{0}", x.Object.Message);
                }
                var mappedHeads = _areaVM.Area.MapVersionToHeads(x.Object.ID);
                if (mappedHeads.Count > 0)
                {
                    foreach (var y in mappedHeads)
                    {
                        nodeLabel += string.Format("\nHead of \"{0}\"", y.Name);
                    }
                }

                GraphNode node = new GraphNode(x.Object, nodeLabel, nodeColor);
                definitions.Add(node);
                if (x != null)
                {
                    foreach (var y in x.Links)
                    {
                        if (result.Lookup.ContainsKey(y.Source))
                        {
                            Tuple <Version, int> source = result.Lookup[y.Source];
                            int    linkToID             = source.Item2;
                            Color  linkColor            = branchInfo.Item1;
                            string linkLabel            = $"\"{branchInfo.Item2.Name}\"";

                            GraphLink link = new GraphLink(source.Item2, node, linkLabel, linkColor, y.Merge);
                            links.Add(link);
                        }
                    }
                }
            }

            Graph <GraphNode> graph = new Graph <GraphNode>();

            definitions.ForEach(x => graph.AddVertex(x));

            links.ForEach(x =>
            {
                GraphNode fromNode = definitions[x.FromVersionID];
                x.FromVersion      = fromNode;
                Debug.Assert(fromNode != x.ToVersion);
                Debug.Assert(fromNode != null);
                Debug.Assert(x.ToVersion != null);

                GraphEdge edge = new GraphEdge(x);
                graph.AddEdge(edge);
            });
            return(graph);
        }