static void Main(string[] args) { GedcomFile file = GedcomReader.ToGedcomFile(@"F:\export-BloodTree.ged"); foreach (GedcomIndividual indi in file.Individuals) { Console.WriteLine(indi.ToString()); } Console.ReadLine(); }
private void LoadFile(string filename) { this.filename = filename; this.Enabled = false; Progress progress = new Progress(); progress.Canceled += Progress_Canceled; progress.Show(); familyTreeView.Nodes.Clear(); progress.ReportProgress(2); this.file = GedcomReader.ToGedcomFile(filename); progress.ReportProgress(5); double increaseValue = (double)95 / file.Families.Count; double currentValue = 5; foreach (GedcomFamily family in file.Families) { if (this.progressCanceled) { break; } if (family.Children.Count == 0) { progress.ReportProgress(string.Concat("Load family ", family.Identifier)); } TreeNode famNode = new TreeNode("Familie") { ImageIndex = 3, SelectedImageIndex = 3 }; TreeNode husband = new TreeNode() { ImageIndex = 1, SelectedImageIndex = 1, Tag = family.Husband }; husband.Text = family.Husband != null?family.Husband.Name.ToString() : string.Empty; TreeNode wife = new TreeNode() { ImageIndex = 0, SelectedImageIndex = 0, Tag = family.Wife }; wife.Text = family.Wife != null?family.Wife.Name.ToString() : string.Empty; famNode.Nodes.AddRange(new TreeNode[] { husband, wife }); DateTime marriage = new DateTime(); if (family.Marriage != null && family.Marriage.Date?.Content != null && DateTime.TryParse(family.Marriage.Date.Content, out marriage)) { famNode.Nodes.Add(Guid.NewGuid().ToString(), "Heirat: " + marriage.ToShortDateString(), 2, 2); } if (family.Children.Count > 0) { progress.ReportProgress(string.Concat("Load family ", family.Identifier, " (", family.Children.Count, " children)")); TreeNode children = new TreeNode("Kinder") { ImageIndex = 3, SelectedImageIndex = 3 }; children.Nodes.AddRange(family.Children.Select(p => new TreeNode(p.Name.ToString() ) { ImageIndex = p.Sex.Content.ToLower().Equals("m") ? 1 : 0, SelectedImageIndex = p.Sex.Content.ToLower().Equals("m") ? 1 : 0, Tag = p }).ToArray()); famNode.Nodes.Add(children); } familyTreeView.Nodes.Add(famNode); progress.ReportProgress((int)currentValue); Application.DoEvents(); currentValue += increaseValue; famNode.ExpandAll(); } if (!this.progressCanceled) { familyTreeView.Nodes[0].EnsureVisible(); progress.ReportProgress(100); statusLabel.Text = string.Format("GEDCOM Source: {0} ({1})", this.file.Head.Source.Name, this.file.Head.Source.Version); } progress.Close(); this.Enabled = true; this.progressCanceled = false; if (!this.Focused) { this.Focus(); } }