private void CreateSiblingEdges(GraphNode <GedcomIndividualRecord> node, GedcomFamilyRecord family) { GedcomIndividualRecord indi = node.Data; foreach (string childID in family.Children) { if (childID != indi.XRefID) { GedcomIndividualRecord child = Database[childID] as GedcomIndividualRecord; if (child != null) { GraphNode <GedcomIndividualRecord> sibling = new GraphNode <GedcomIndividualRecord>(); sibling.Data = child; node.Edges.Add(sibling); } else { System.Diagnostics.Debug.WriteLine("child in family points to non individual record"); } } } foreach (GraphNode <GedcomIndividualRecord> sibling in node.Edges) { sibling.Edges.Add(node); foreach (GraphNode <GedcomIndividualRecord> sibling2 in node.Edges) { if (sibling2 != sibling) { sibling.Edges.Add(sibling2); } } } }
private void CreateAncestorEdges(GraphNode <GedcomIndividualRecord> node, GedcomFamilyRecord family) { GedcomIndividualRecord husb = null; GedcomIndividualRecord wife = null; if (!string.IsNullOrEmpty(family.Husband)) { husb = Database[family.Husband] as GedcomIndividualRecord; if (husb == null) { System.Diagnostics.Debug.WriteLine("Husband points to non individual record"); } } if (!string.IsNullOrEmpty(family.Wife)) { wife = Database[family.Wife] as GedcomIndividualRecord; if (wife == null) { System.Diagnostics.Debug.WriteLine("Wife points to non individual record"); } } if (husb != null) { GraphNode <GedcomIndividualRecord> father = CreateNode(husb, GraphType.Ancestors); node.Edges.Add(father); } if (wife != null) { GraphNode <GedcomIndividualRecord> mother = CreateNode(wife, GraphType.Ancestors); node.Edges.Add(mother); } }
private void Sealing_can_be_added_to_family_record_directly() { var family = new GedcomFamilyRecord(); family.SpouseSealing = new GedcomSpouseSealingRecord(); Assert.NotNull(family.SpouseSealing); }
public void GedComComparison_GedcomFamilyRecord_IsEquivalentTo_ExpectAreEqual() { // Arrange var object1 = new GedcomFamilyRecord { Database = new GedcomDatabase() }; var object2 = new GedcomFamilyRecord { Database = new GedcomDatabase() }; // Act and Assert Assert.True(object1.IsEquivalentTo(object2)); Assert.True(object2.IsEquivalentTo(object1)); }
private GedcomFamilyRecord GenerateFamilyRecord() { var famRecord = new GedcomFamilyRecord { NumberOfChildren = 2, Husband = "@I1@", Wife = "@I2@", StartStatus = MarriageStartStatus.Partners }; famRecord.Children.Add("@I3@"); famRecord.Events.Add(new GedcomFamilyEvent { EventType = GedcomEventType.MARR }); famRecord.SubmitterRecords.Add("@I4@"); return(famRecord); }
private void CreateDecendantEdges(GraphNode <GedcomIndividualRecord> node, GedcomFamilyRecord family) { GedcomIndividualRecord indi = node.Data; foreach (string childID in family.Children) { // should never happen, best to check anyway if (childID != indi.XRefID) { GedcomIndividualRecord child = Database[childID] as GedcomIndividualRecord; if (child != null) { GraphNode <GedcomIndividualRecord> decendant = CreateNode(child, GraphType.Decendants); node.Edges.Add(decendant); } else { System.Diagnostics.Debug.WriteLine("child in family points to non individual record"); } } } }
private void FillView() { if (_indi != null) { GedcomName name = _indi.GetName(); HusbandNameEntry.Text = name.Name; GedcomIndividualEvent birth = _indi.Birth; if (birth != null) { GedcomPlace place = birth.Place; if (place != null) { HusbandBornInEntry.Text = place.Name; } GedcomDate date = birth.Date; if (date != null) { HusbandDateBornEntry.Text = date.DateString; } } GedcomIndividualEvent death = _indi.Death; if (death != null) { GedcomPlace place = death.Place; if (place != null) { HusbandDiedInEntry.Text = place.Name; } GedcomDate date = death.Date; if (date != null) { HusbandDateDiedEntry.Text = date.DateString; } } ParentsButton.Sensitive = false; if (_indi.ChildIn.Count == 0) { ParentsButton.Label = "Parents"; ParentsButton.Image = Gtk.Image.NewFromIconName(Gtk.Stock.GoUp, Gtk.IconSize.Button); } else { GedcomFamilyLink link = _indi.ChildIn[0]; _parentalFamily = _database[link.Family] as GedcomFamilyRecord; if (_parentalFamily == null) { System.Diagnostics.Debug.WriteLine("Family link points to non family record"); } else { GedcomIndividualRecord husb = null; GedcomIndividualRecord wife = null; if (!string.IsNullOrEmpty(_parentalFamily.Husband)) { husb = _database[_parentalFamily.Husband] as GedcomIndividualRecord; } if (!string.IsNullOrEmpty(_parentalFamily.Wife)) { wife = _database[_parentalFamily.Wife] as GedcomIndividualRecord; } StringBuilder sb = new StringBuilder(); GedcomName husbandName = null; if (husb != null) { husbandName = husb.GetName(); } if (husbandName != null) { sb.Append(husbandName.Given); } GedcomName wifeName = null; if (wife != null) { wifeName = wife.GetName(); } if (wifeName != null) { if (sb.Length > 0) { sb.Append(" & "); } sb.Append(wifeName.Given); } if (husbandName != null) { if (sb.Length > 0) { sb.Append(" "); } sb.Append(husbandName.Surname); } if (sb.Length == 0) { sb.Append("Parents"); } ParentsButton.Label = sb.ToString(); ParentsButton.Image = Gtk.Image.NewFromIconName(Gtk.Stock.GoUp, Gtk.IconSize.Button); ParentsButton.Sensitive = true; } } HusbandFamiliesButton.Image = Gtk.Image.NewFromIconName(Gtk.Stock.DialogInfo, Gtk.IconSize.Button); HusbandFamiliesButton.Label = string.Format("Families ({0})", _indi.SpouseIn.Count); // set sensitivity on source buttons for birth/death HusbandBorn_Changed(this, EventArgs.Empty); HusbandDied_Changed(this, EventArgs.Empty); } }
/// <summary> /// Appends the family. /// </summary> /// <param name="family">The family.</param> /// <param name="root">The root.</param> protected void AppendFamily(GedcomFamilyRecord family, XmlNode root) { family.GenerateXML(root); }
/// <summary> /// Initializes a new instance of the <see cref="GedcomFamilyRecordComparisonTest"/> class. /// Comparison tests for GedcomFamilyRecord. /// </summary> public GedcomFamilyRecordComparisonTest() { famRec1 = GenerateFamilyRecord(); famRec2 = GenerateFamilyRecord(); }
private void AppendFamilyDetails(GedcomFamilyLink link, XmlNode root, int generation) { string famID = link.Family; if (!processed.Contains(famID)) { processed.Add(famID); GedcomFamilyRecord fam = Database[famID] as GedcomFamilyRecord; if (fam != null) { foreach (GedcomFamilyEvent famEvent in fam.Events) { famEvent.EventXRefID = Database.GenerateXref("EVENT"); AppendEvent(famEvent, root); AppendSources(famEvent, root); } AppendFamily(fam, root); if (!string.IsNullOrEmpty(fam.Husband)) { GedcomIndividualRecord husb = Database[fam.Husband] as GedcomIndividualRecord; if (husb != null) { AppendIndividualDetails(husb, root, generation); } else { throw new Exception("Husband points to non individual record"); } } if (!string.IsNullOrEmpty(fam.Wife)) { GedcomIndividualRecord wife = Database[fam.Wife] as GedcomIndividualRecord; if (wife != null) { AppendIndividualDetails(wife, root, generation); } else { throw new Exception("Husband points to non individual record"); } } foreach (string childID in fam.Children) { GedcomIndividualRecord child = Database[childID] as GedcomIndividualRecord; if (child != null) { int childGeneration = generation - 1; AppendIndividualDetails(child, root, childGeneration); } else { throw new Exception("Child points to non individual record"); } } } else { throw new Exception("Family link points to non family record"); } } }
private GraphNode <GedcomIndividualRecord> CreateNode(GedcomIndividualRecord indi, GraphType type) { GraphNode <GedcomIndividualRecord> node = new GraphNode <GedcomIndividualRecord>(); node.Data = indi; // System.Console.WriteLine("Create node for: " + indi.XRefID); if (type == GraphType.Ancestors || type == GraphType.Siblings) { foreach (GedcomFamilyLink famLink in indi.ChildIn) { GedcomFamilyRecord family = Database[famLink.Family] as GedcomFamilyRecord; if (family != null) { switch (type) { case GraphType.Ancestors: CreateAncestorEdges(node, family); break; case GraphType.Siblings: CreateSiblingEdges(node, family); break; default: System.Diagnostics.Debug.WriteLine("Invalid graph type"); break; } } else { System.Diagnostics.Debug.WriteLine("Family link points to non family record"); } } } else { foreach (GedcomFamilyLink famLink in indi.SpouseIn) { GedcomFamilyRecord family = Database[famLink.Family] as GedcomFamilyRecord; if (family != null) { switch (type) { case GraphType.Decendants: CreateDecendantEdges(node, family); break; default: System.Diagnostics.Debug.WriteLine("Invalid graph type"); break; } } else { System.Diagnostics.Debug.WriteLine("Family link points to non family record"); } } } return(node); }