private void GenerateNodes() { string[] files = ((FSFolder)fso).GetFiles(); string[] folders = ((FSFolder)fso).GetFolders(); int N = files.Length + folders.Length; int L = (GraphFileManager.MaxDepth - depth) * 100; double step = 2 * Math.PI / (depth == 0 ? N : N + 1); if (N == 0) { return; } nodes = new IGraphComponent[N]; int index = 0; for (int i = 0; i < files.Length; ++i, ++index) { Vector2 pos = (new Vector2((float)Math.Cos(step * (index + 1) + angle), (float)Math.Sin(step * (index + 1) + angle))) * (files.Length * 15 + 50) + Position; nodes[index] = new GraphLeaf(new FSFile(files[i]), pos); } for (int i = 0; i < folders.Length; ++i, ++index) { Vector2 pos = (new Vector2((float)Math.Cos(step * (index + 1) + angle), (float)Math.Sin(step * (index + 1) + angle))) * L + Position; nodes[index] = new GraphComposite(new FSFolder(folders[i]), pos, depth + 1, Math.Atan2(pos.Y - Position.Y, pos.X - Position.X) + Math.PI); } }
public FileManager(string dir) { Dir = dir; Root = new GraphComposite(new FSFolder(dir), new Vector2(0, 0), 0, 0); }