Drawing a Family Tree
-
I am trying to draw a Family tree onto a panel by adding several custom panels that contain the data about each person in the tree. I have all the panels displaying but my formula for working out where to place each custom panel is placing them incorrectly. This is my formula. child is the custom panel one generation back in the tree and the index is set according to its vertical position in the generation (i.e the one nearest the top of the panel is 1 and the next lowest 2 and then next lowest 3 etc..) generation is the generation the the animal belongs to (1 being the initial person, 2 being the parents, 3 the grandparens) pw = the custom panel width, hg = the gap between generations, pd = the custom panel height, paneldepth = the main panel height I want the tree to draw left to right. The x co-ordinate works fine its the y co-ordinate that doesnt work, it causes earlier generation to be too close together. // Set Panel Location int x = child.Location.X + pw + hg; int y = ((paneldepth / (generation + 1)) * ((2 * child.Index) - 1)) - (pd / 2); parentpanel.Location = new Point(x, y); Can anyone suggest a formula that might work?