Example #1
0
        public static GraphData RadialHierarchicalLayout(string dir, Dictionary <string, Node> dict)
        {
            string dirPath = Util.PathFromDirFile(dir, "");
            List <DirNode.PathNodePair> inputNodes = new List <DirNode.PathNodePair>();

            foreach (var d in dict)
            {
                if (d.Key.StartsWith(dirPath))
                {
                    string path = d.Key.Substring(dirPath.Length);
                    inputNodes.Add(new DirNode.PathNodePair(path, d.Value));
                }
                else
                {
                    inputNodes.Add(new DirNode.PathNodePair(d.Key, d.Value));
                }
            }

            DirNode hierarchy = DirNode.Create(inputNodes);

            double maxSize = 0;

            foreach (var d in dict)
            {
                string file = Util.FileFromPath(d.Key);
                d.Value.size         = Util.MeasureTextBlock(file);
                d.Value.size.Width  += 10;
                d.Value.size.Height += 10;
                maxSize              = Math.Max(maxSize, Math.Max(d.Value.size.Width, d.Value.size.Height));
            }

            SetRadialPositions(hierarchy, maxSize, 2 * Math.PI / hierarchy.width);

            return(NormalizeNodePositions(dict, new Size(maxSize, maxSize)));
        }