/// <summary> /// Create the family section (the FAM tags) in the GEDCOM file. /// </summary> private void ExportFamilies() { // Exporting families is more difficult since need to export each // family group. A family group consists of one or more parents, // marriage / divorce information and children. The FamilyMap class // creates a list of family groups from the People collection. FamilyMap map = new FamilyMap(); map.Create(people); // Created the family groups, now export each family. foreach (Family family in map.Values) { ExportFamily(family); } }
/// <summary> /// Export each person to the GEDCOM file. /// </summary> private void ExportPeople() { FamilyMap map = new FamilyMap(); map.Create(people); foreach (Person person in people) { string id = idMap.Get(person.Id); // Start of a new individual record. WriteLine(0, string.Format(CultureInfo.InvariantCulture, "@{0}@", id), "INDI"); // Export details. // Restriction. ExportRestriction(person); if (person.Restriction == Restriction.Private) { WriteLine(1, "NAME", Microsoft.FamilyShowLib.Properties.Resources.PrivateRecord); } else { // Name. ExportName(person); // Surname if (!string.IsNullOrEmpty(person.LastName)) { WriteLine(2, "SURN", person.LastName); } // Prefix. if (!string.IsNullOrEmpty(person.Suffix)) { WriteLine(2, "NPFX", person.Suffix); } // Gender. ExportGender(person); // Birth and death info. ExportEvent("BIRT", "", person.BirthDateDescriptor, person.BirthDate, person.BirthPlace, person.BirthCitation, person.BirthCitationNote, person.BirthCitationActualText, person.BirthLink, person.BirthSource); ExportEvent("DEAT", "", person.DeathDateDescriptor, person.DeathDate, person.DeathPlace, person.DeathCitation, person.DeathCitationNote, person.DeathCitationActualText, person.BirthLink, person.BirthSource); ExportEvent("BURI", "", person.BurialDateDescriptor, person.BurialDate, person.BurialPlace, person.BurialCitation, person.BurialCitationNote, person.BurialCitationActualText, person.BirthLink, person.BirthSource); ExportEvent("CREM", "", person.CremationDateDescriptor, person.CremationDate, person.CremationPlace, person.CremationCitation, person.CremationCitationNote, person.CremationCitationActualText, person.BirthLink, person.BirthSource); ExportEvent("EDUC", person.Education, "", null, "", person.EducationCitation, person.EducationCitationNote, person.EducationCitationActualText, person.EducationLink, person.EducationSource); ExportEvent("OCCU", person.Occupation, "", null, "", person.OccupationCitation, person.OccupationCitationNote, person.OccupationCitationActualText, person.OccupationLink, person.OccupationSource); ExportEvent("RELI", person.Religion, "", null, "", person.ReligionCitation, person.ReligionCitationNote, person.ReligionCitationActualText, person.ReligionLink, person.ReligionSource); // Photo file names, files themselves cannot be exported as GEDCOM is simply a text file. ExportPhotos(person); ExportAttachments(person); // Notes. if (!string.IsNullOrEmpty(person.Note)) { WriteLine(1, "NOTE", person.Note); } int i = 1; //current family number //Write a FAMC or FAMS tag for every family which contains the person foreach (Family family in map.Values) { //FAMC for children foreach (Person child in family.Children) { if (person.Id == child.Id) { WriteLine(1, "FAMC", string.Format(CultureInfo.InvariantCulture, "@F{0}@", i)); } } //FAMS for parents/spouses if (person.Id == family.ParentLeft.Id) { WriteLine(1, "FAMS", string.Format(CultureInfo.InvariantCulture, "@F{0}@", i)); } if (person.Id == family.ParentRight.Id) { WriteLine(1, "FAMS", string.Format(CultureInfo.InvariantCulture, "@F{0}@", i)); } i++; } } } }