【发布时间】:2013-08-31 06:51:03
【问题描述】:
我想在视觉家谱树中显示一个家庭的成员,比如这个或类似的:http://s12.postimg.org/y9lcyjhvx/Untitled.png
我不知道从哪里开始或我可以使用什么,或者即使可能使用 C# windows 窗体。
有人可以帮忙吗?
【问题讨论】:
标签: c# sql winforms tree genealogy
我想在视觉家谱树中显示一个家庭的成员,比如这个或类似的:http://s12.postimg.org/y9lcyjhvx/Untitled.png
我不知道从哪里开始或我可以使用什么,或者即使可能使用 C# windows 窗体。
有人可以帮忙吗?
【问题讨论】:
标签: c# sql winforms tree genealogy
你查过这个帖子吗? Genealogy Tree Control
基本上建议使用Geni,可能也适合你
编辑: 如果你想“步行”,你可以根据你的经验水平做很多事情。 首先,你需要一个合适的数据结构,例如
public class Genealogy {
Person me;
[...]
}
public class Person {
Person father, mother;
[...]
}
这允许(非常基本的)反映您的家谱。 接下来,为了可视化,您可以首先尝试使用TreeView 类进行模糊测试。 如果您实现正确的接口,这将为您提供层次结构的简单文本表示。 如果您想要更高级的可视化,您可能必须创建自己的 UserControl 派生类,您将在其中执行树的所有渲染。 (然后,可以将控件放置在通常的窗口表单元素等上) 然后,您可以遵循递归原则,例如
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 的命令,但这是我将追求的基本策略。当然,您需要添加边距、线条和所有内容来为您的树增添趣味。
【讨论】: