2013-08-31 27 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#窗體中使用哪些方法?.... –