2013-08-31 32 views

回答

3

你看了这个帖子? Genealogy Tree Control

基本上它的建议使用Geni,这可能是适合你的,太

编辑: 如果你想去“跑路”,你可以根据你的经验等级做了很多的事情。首先,你需要一个合适的数据结构,例如

public class Genealogy { 
    Person me; 

    [...] 
} 

public class Person { 
    Person father, mother; 

    [...] 
} 

这允许(非常基本)反映你的家谱。接下来,为了可视化,您可以首先尝试使用TreeView类进行模拟。 如果你实现了正确的接口,这将给你一个你的层次结构的简单文本表示。 如果您想要更高级的可视化,您可能必须创建自己的UserControl派生类,在其中您将执行树的所有渲染。 (然后,控制可以放在一般的Windows窗体元素等) 然后,你可以按照喜欢

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) 
     [...] 
    } 
} 

递归原理我没有对UI拉在我的头上,现在的命令,但这是我追求的基本策略。当然,你会想要添加边距,线条和所有东西来增加你的树。

+0

是的,我做了,它并没有帮助我。你有没有读过我的问题?为了得到这样的结果,我应该在C#窗体中使用哪些方法?.... –