/// <summary> /// Adds Parent-Child relationship between person and child with the provided parent-child relationship type. /// </summary> public void AddChild(Person person, Person child, ParentChildModifier parentChildType) { //add child relationship to person person.Relationships.Add(new ChildRelationship(child, parentChildType)); //add person as parent of child child.Relationships.Add(new ParentRelationship(person, parentChildType)); //add the child to the main people list if (!this.Contains(child)) { this.Add(child); } }
public ParentRelationship(Person personId, ParentChildModifier parentChildType) { RelationshipType = RelationshipType.Parent; RelationTo = personId; parentChildModifier = parentChildType; }
/// <summary> /// Performs the business logic for adding the Child relationship between the person and the child. /// In the case of existing people, do not hook up other siblings etc. Allow the user to do this manually. /// </summary> public static void AddExistingChild(PeopleCollection family, Person person, Person child, ParentChildModifier modifier) { if (person != child) { family.AddChild(person, child, modifier); } }
public ChildRelationship(Person person, ParentChildModifier parentChildType) { RelationshipType = RelationshipType.Child; RelationTo = person; parentChildModifier = parentChildType; }
/// <summary> /// Performs the business logic for updating the Parent relationship between the child and the parent. /// </summary> public static void UpdateParentChildStatus(PeopleCollection family, Person parent, Person child, ParentChildModifier modifier) { foreach (Relationship relationship in parent.Relationships) { if (relationship.RelationshipType == RelationshipType.Child && relationship.RelationTo.Equals(child)) { ((ChildRelationship)relationship).ParentChildModifier = modifier; break; } } foreach (Relationship relationship in child.Relationships) { if (relationship.RelationshipType == RelationshipType.Parent && relationship.RelationTo.Equals(parent)) { ((ParentRelationship)relationship).ParentChildModifier = modifier; break; } } }
/// <summary> /// Performs the business logic for adding the Child relationship between the person and the child. /// </summary> public static void AddChild(PeopleCollection family, Person person, Person child, ParentChildModifier modifier) { if (person != child) { switch (person.Spouses.Count) { // Single parent, add the child to the person case 0: family.AddChild(person, child, modifier); break; // Has existing spouse, add the child to the person's spouse as well. case 1: family.AddChild(person, child, modifier); family.AddChild(person.Spouses[0], child, modifier); break; } // Add the new child as a sibling to any existing natural children of the natural parents. foreach (Person existingSibling in person.NaturalChildren) { if (existingSibling != child) { family.AddSibling(existingSibling, child); } } } }
/// <summary> /// Performs the business logic for adding the Parent relationship between the person and the parent. /// In the case of existing people, do not hook up other siblings etc. Allow the user to do this manually. /// </summary> public static void AddExistingParent(PeopleCollection family, Person person, Person parent, ParentChildModifier modifier) { family.AddChild(parent, person, modifier); //Setter for property change notification person.HasParents = true; }
public ParentRelationship(Shape personId, ParentChildModifier parentChildType) { RelationshipType = RelationshipType.Parent; this.RelationTo = personId; this.parentChildModifier = parentChildType; }
public ChildRelationship(Shape person, ParentChildModifier parentChildType) { RelationshipType = RelationshipType.Child; this.RelationTo = person; this.parentChildModifier = parentChildType; }
/// <summary> /// Adds Parent-Child relationship between person, spouse, and child with the provided parent-child relationship type. /// </summary> public void AddChild(Person person, Person spouse, Person child, ParentChildModifier parentChildType) { AddChild(person, child, parentChildType); AddChild(spouse, child, parentChildType); }
/// <summary> /// Imports the families (FAM tags) from the GEDCOM XML file. /// </summary> private void ImportFamilies() { // Get list of families. XmlNodeList list = doc.SelectNodes("/root/FAM"); foreach (XmlNode node in list) { // Get family (husband, wife and children) IDs from the GEDCOM file. string husband = GetHusbandID(node); string wife = GetWifeID(node); string[] children = GetChildrenIDs(node); //get the child modifier if present string[,] children1 = GetChildrenIDsAndModifiers(node); // Get the Person objects for the husband and wife, // required for marriage info and adding children. Person husbandPerson = people.Find(husband); Person wifePerson = people.Find(wife); // Add any marriage / divorce details. ImportMarriage(husbandPerson, wifePerson, node, doc); int i = 0; // Import the children. foreach (string child in children) { // Get the Person object for the child. Person childPerson = people.Find(child); string husbandChildModifier = children1[1, i]; string wifeChildModifier = children1[2, i]; ParentChildModifier husbandModifier = ParentChildModifier.Natural; ParentChildModifier wifeModifier = ParentChildModifier.Natural; if (husbandChildModifier == "Adopted") { husbandModifier = ParentChildModifier.Adopted; } if (husbandChildModifier == "Foster") { husbandModifier = ParentChildModifier.Foster; } if (wifeChildModifier == "Adopted") { wifeModifier = ParentChildModifier.Adopted; } if (wifeChildModifier == "Foster") { wifeModifier = ParentChildModifier.Foster; } if (husbandPerson != null && wifePerson != null & childPerson != null) { people.AddChild(husbandPerson, childPerson, husbandModifier); people.AddChild(wifePerson, childPerson, wifeModifier); List <Person> firstParentChildren = new List <Person>(husbandPerson.NaturalChildren); List <Person> secondParentChildren = new List <Person>(wifePerson.NaturalChildren); // Combined children list that is returned. List <Person> naturalChildren = new List <Person>(); // Go through and add the children that have both parents. foreach (Person child1 in firstParentChildren) { if (secondParentChildren.Contains(child1)) { naturalChildren.Add(child1); } } // Go through and add natural siblings foreach (Person s in naturalChildren) { if (s != childPerson && wifeModifier == ParentChildModifier.Natural && husbandModifier == ParentChildModifier.Natural) { people.AddSibling(childPerson, s); } } } if (husbandPerson == null && wifePerson != null & childPerson != null) { people.AddChild(wifePerson, childPerson, wifeModifier); // Go through and add natural siblings foreach (Person s in wifePerson.NaturalChildren) { if (s != childPerson && wifeModifier == ParentChildModifier.Natural) { people.AddSibling(childPerson, s); } } } if (husbandPerson != null && wifePerson == null & childPerson != null) { people.AddChild(husbandPerson, childPerson, husbandModifier); // Go through and add natural siblings foreach (Person s in husbandPerson.NaturalChildren) { if (s != childPerson && husbandModifier == ParentChildModifier.Natural) { people.AddSibling(childPerson, s); } } } i++; } } }