void AddParentAndChildrenFacts(Individual child, Individual parent, ParentalRelationship.ParentalRelationshipType prType) { if (parent != null) { string parentComment; string childrenComment; if (prType == ParentalRelationship.ParentalRelationshipType.UNKNOWN) { parentComment = $"Child of {parent.IndividualID}: {parent.Name}"; childrenComment = $"Parent of {child.IndividualID}: {child.Name}"; } else { string titlecase = EnhancedTextInfo.ToTitleCase(prType.ToString().ToLower()); parentComment = $"{titlecase} child of {parent.IndividualID}: {parent.Name}"; childrenComment = $"{titlecase} parent of {child.IndividualID}: {child.Name}"; } Fact parentFact = new Fact(parent.IndividualID, Fact.PARENT, child.BirthDate, child.BirthLocation, parentComment, true, true); child.AddFact(parentFact); Fact childrenFact = new Fact(child.IndividualID, Fact.CHILDREN, child.BirthDate, child.BirthLocation, childrenComment, true, true); parent.AddFact(childrenFact); } }
public Family(XmlNode node) : this(string.Empty) { if (node != null) { XmlNode eHusband = node.SelectSingleNode("HUSB"); XmlNode eWife = node.SelectSingleNode("WIFE"); this.FamilyID = node.Attributes["ID"].Value; string husbandID = eHusband == null || eHusband.Attributes["REF"] == null ? null : eHusband.Attributes["REF"].Value; string wifeID = eWife == null || eWife.Attributes["REF"] == null ? null : eWife.Attributes["REF"].Value; FamilyTree ft = FamilyTree.Instance; this.Husband = ft.GetIndividual(husbandID); this.Wife = ft.GetIndividual(wifeID); if (Husband != null && Wife != null) { Wife.MarriedName = Husband.Surname; } if (Husband != null) { Husband.FamiliesAsParent.Add(this); } if (Wife != null) { Wife.FamiliesAsParent.Add(this); } // now iterate through child elements of eChildren // finding all individuals XmlNodeList list = node.SelectNodes("CHIL"); foreach (XmlNode n in list) { if (n.Attributes["REF"] != null) { Individual child = ft.GetIndividual(n.Attributes["REF"].Value); if (child != null) { XmlNode fatherNode = node.SelectSingleNode("CHIL/_FREL"); XmlNode motherNode = node.SelectSingleNode("CHIL/_MREL"); ParentalRelationship.ParentalRelationshipType father = ParentalRelationship.GetRelationshipType(fatherNode); ParentalRelationship.ParentalRelationshipType mother = ParentalRelationship.GetRelationshipType(motherNode); Children.Add(child); ParentalRelationship parent = new ParentalRelationship(this, father, mother); child.FamiliesAsChild.Add(parent); AddParentAndChildrenFacts(child, Husband, father); AddParentAndChildrenFacts(child, Wife, mother); } else { ft.XmlErrorBox.AppendText("Child not found in family :" + FamilyRef + "\n"); } } else { ft.XmlErrorBox.AppendText("Child without a reference found in family : " + FamilyRef + "\n"); } } AddFacts(node, Fact.ANNULMENT); AddFacts(node, Fact.DIVORCE); AddFacts(node, Fact.DIVORCE_FILED); AddFacts(node, Fact.ENGAGEMENT); AddFacts(node, Fact.MARRIAGE); AddFacts(node, Fact.MARRIAGE_BANN); AddFacts(node, Fact.MARR_CONTRACT); AddFacts(node, Fact.MARR_LICENSE); AddFacts(node, Fact.MARR_SETTLEMENT); AddFacts(node, Fact.SEPARATION); AddFacts(node, Fact.CENSUS); AddFacts(node, Fact.CUSTOM_EVENT); AddFacts(node, Fact.CUSTOM_FACT); AddFacts(node, Fact.REFERENCE); AddFacts(node, Fact.UNKNOWN); //TODO: need to think about family facts having AGE tags in GEDCOM if (HasGoodChildrenStatus) { CheckChildrenStatusCounts(); } } }