How can I visually display a genealogy tree in C#

2.6k views Asked by At

I would like to display the members of a family in a visual genealogy tree, like this one or similar: http://s12.postimg.org/y9lcyjhvx/Untitled.png

I don't know where to start or what I could use, or even if possible with C# windows forms.

Could someone help please?

1

There are 1 answers

1
daniel.wirtz On

Have you looked up this thread? Genealogy Tree Control

Basically it's suggesting to use Geni, which might be suitable for you, too

Edit: if you want to go "on foot", you can do a lot of things depending on your experience level. at first, you need a suitable data structure, e.g.

public class Genealogy {
    Person me;

    [...]
}

public class Person {
    Person father, mother;

    [...]
}

this allows (very basic) to mirror your genealogy. next, for visualization, you can at first try to fuzz around with the TreeView class. this will give you a simple textual representation of your hierarchy if you implement the right interfaces. if you want more advanced visualization, you will probably have to create your own UserControl-derived class, in which you will perform all the rendering of your tree. (then, the control can be placed on the usual windows form elements etc.) then, you can follow a recursive principle like

public class Genealogy {
    Person me;

    public void draw() {
        // Plots me!
        me.draw(0, 0);
    }
}

public class Person {
    Person father, mother;

    public void draw(int x, int y) {
        // Plot parents
        father.draw(x - width/2, y - height);
        mother.draw(x + width/2, y - height);

        // Plot the person image + name at (x,y)
        [...]
    }
}

i dont have the commands for UI-drawing in my head right now, but this is the essential strategy i would pursue. of course, you'll want to add margins, line and everything to spice up your tree.