private void AllocateLines() { foreach (var item in DrawableNodes) { foreach (var it in item.Node.Children) { var child = DrawableNodes.SingleOrDefault(n => n.Node == it); var line = new DrawableLine() { From = new Point(item.X + NodeThickness / 2, item.Y + NodeThickness / 2), To = new Point(child.X + NodeThickness / 2, child.Y + NodeThickness / 2) }; DrawableLines.Add(line); } } }
private void AllocateNodes(List <IGeneticTreeNode> nodes, int generation = 0) { foreach (var gene in Generations) { foreach (var node in gene.Nodes) { DrawableNodes.Add(new DrawableNode() { Node = node, X = (1 / (double)gene.Nodes.Count / 2) * Surface.Width + (Surface.Width * ((double)GetIndexInGeneration(gene, node) / (double)gene.Nodes.Count)), Y = Surface.Height * (1 - ((double)gene.Level / (double)Generations.Count)) - (1 / (double)Generations.Count) * Surface.Height, NodeThickness = NodeThickness }); } } }