Example #1
0
        public string[] ExportPlaces(PeopleCollection peopleCollection, string fileName, bool hideliving, bool times, bool lifespans, bool places, bool burials, bool deaths, bool cremations, bool births, bool marriages)
        {
            string PlacesFileName = Path.GetFileNameWithoutExtension(fileName);

            TextWriter tw = new StreamWriter(fileName);

            #region styles

            // Write text necessary for kml file.
            // Uses Google Earths's male and female icons.
            tw.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                         "<kml xmlns=\"http://www.opengis.net/kml/2.2\" xmlns:gx=\"http://www.google.com/kml/ext/2.2\" xmlns:kml=\"http://www.opengis.net/kml/2.2\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n" +
                         "<Document>\n" +
                         "<name>" + PlacesFileName + "</name>\n" +

                         "<Style id=\"sn_man2\">\n" +
                         "<IconStyle>\n" +
                         "<scale>0.9</scale>\n" +
                         "<Icon>\n" +
                         "<href>http://maps.google.com/mapfiles/kml/shapes/man.png</href>\n" +
                         "</Icon>\n" +
                         "</IconStyle>\n" +
                         "<LabelStyle>\n" +
                         "<scale>0.9</scale>\n" +
                         "</LabelStyle>\n" +
                         "</Style>\n" +

                         "<Style id=\"sh_man0\">\n" +
                         "<IconStyle>\n" +
                         "	<scale>0.9</scale>\n"+
                         "<Icon>\n" +
                         "	<href>http://maps.google.com/mapfiles/kml/shapes/man.png</href>\n"+
                         "</Icon>\n" +
                         "</IconStyle>\n" +
                         "<LabelStyle>\n" +
                         "	<scale>0.9</scale>\n"+
                         "</LabelStyle>\n" +
                         "</Style>\n" +

                         "<StyleMap id=\"msn_man\">\n" +
                         "<Pair>\n" +
                         "	<key>normal</key>\n"+
                         "	<styleUrl>#sn_man2</styleUrl>\n"+
                         "</Pair>\n" +
                         "<Pair>\n" +
                         "	<key>highlight</key>\n"+
                         "	<styleUrl>#sh_man0</styleUrl>\n"+
                         "</Pair>\n" +
                         "</StyleMap>\n" +


                         "<Style id=\"sn_woman1\">\n" +
                         "	<IconStyle>\n"+
                         "		<scale>0.9</scale>\n"+
                         "		<Icon>\n"+
                         "			<href>http://maps.google.com/mapfiles/kml/shapes/woman.png</href>\n"+
                         "		</Icon>\n"+
                         "	</IconStyle>\n"+
                         "  <LabelStyle>\n" +
                         "  	<scale>0.9</scale>\n"+
                         "  </LabelStyle>\n" +
                         "</Style>\n" +


                         "<Style id=\"sh_woman0\">\n" +
                         "	 <IconStyle>\n"+
                         "		<scale>0.9</scale>\n"+
                         "      <Icon>\n" +
                         "			<href>http://maps.google.com/mapfiles/kml/shapes/woman.png</href>\n"+
                         "		</Icon>\n"+
                         "	 </IconStyle>\n"+
                         "	 <LabelStyle>\n"+
                         "		<scale>0.9</scale>\n"+
                         "	 </LabelStyle>\n"+
                         "</Style>\n" +

                         "<StyleMap id=\"msn_woman\">\n" +
                         "<Pair>\n" +
                         "		<key>normal</key>\n"+
                         "		<styleUrl>#sn_woman1</styleUrl>\n"+
                         "</Pair>\n" +
                         "<Pair>\n" +
                         "		<key>highlight</key>\n"+
                         "		<styleUrl>#sh_woman0</styleUrl>\n"+
                         "</Pair>\n" +
                         "</StyleMap>");

            #endregion

            int i = 0;  // Counter for all the places exported.

            if (places)
            {
                #region places with no time information

                tw.WriteLine("<Folder>\n" +
                             "<name>" + Microsoft.FamilyShowLib.Properties.Resources.People + "</name>\n" +
                             "<open>0</open>\n" +
                             "<Folder>\n" +
                             "<name>" + Microsoft.FamilyShowLib.Properties.Resources.Births + "</name>\n" +
                             "<open>0</open>");

                if (births)
                {
                    foreach (Person p in peopleCollection)
                    {
                        if (!(hideliving && p.IsLiving))
                        {
                            if (!string.IsNullOrEmpty(p.BirthPlace) && p.Restriction != Restriction.Private)
                            {
                                string name = string.Empty;

                                tw.WriteLine("<Placemark>\n" +
                                             "	<name>"+ p.FullName + "</name>\n" +
                                             "	<address>"+ p.BirthPlace + "</address>\n" +
                                             "	<description>"+ p.BirthPlace + "</description>");

                                if (p.Gender == Gender.Male)
                                {
                                    tw.WriteLine("<styleUrl>#msn_man</styleUrl>\n</Placemark>");
                                }
                                else
                                {
                                    tw.WriteLine("<styleUrl>#msn_woman</styleUrl>\n</Placemark>");
                                }

                                i++;
                            }
                        }
                    }

                    tw.WriteLine("</Folder>");
                }

                if (deaths)
                {
                    tw.WriteLine("<Folder>\n<name>" + Microsoft.FamilyShowLib.Properties.Resources.Deaths + "</name>\n" +
                                 "<open>0</open>");

                    foreach (Person p in peopleCollection)
                    {
                        if (!(hideliving && p.IsLiving))
                        {
                            if (!string.IsNullOrEmpty(p.DeathPlace) && p.Restriction != Restriction.Private)
                            {
                                tw.WriteLine("<Placemark>\n" +
                                             "<name>" + p.FullName + "</name>\n" +
                                             "<address>" + p.DeathPlace + "</address>\n" +
                                             "<description>" + p.DeathPlace + "</description>");

                                if (p.Gender == Gender.Male)
                                {
                                    tw.WriteLine("<styleUrl>#msn_man</styleUrl>\n</Placemark>");
                                }
                                else
                                {
                                    tw.WriteLine("<styleUrl>#msn_woman</styleUrl>\n</Placemark>");
                                }

                                i++;
                            }
                        }
                    }

                    tw.WriteLine("</Folder>");
                }

                if (burials)
                {
                    tw.WriteLine("<Folder>\n" +
                                 "<name>" + Microsoft.FamilyShowLib.Properties.Resources.Burials + "</name>\n" +
                                 "<open>0</open>");

                    foreach (Person p in peopleCollection)
                    {
                        if (!(hideliving && p.IsLiving))
                        {
                            if (!string.IsNullOrEmpty(p.BurialPlace) && p.Restriction != Restriction.Private)
                            {
                                tw.WriteLine("<Placemark>\n" +
                                             "<name>" + p.FullName + "</name>\n" +
                                             "<address>" + p.BurialPlace + "</address>\n" +
                                             "<description>" + p.BurialPlace + "</description>");

                                if (p.Gender == Gender.Male)
                                {
                                    tw.WriteLine("<styleUrl>#msn_man</styleUrl>\n</Placemark>");
                                }
                                else
                                {
                                    tw.WriteLine("<styleUrl>#msn_woman</styleUrl>\n</Placemark>");
                                }

                                i++;
                            }
                        }
                    }

                    tw.WriteLine("</Folder>");
                }

                if (cremations)
                {
                    tw.WriteLine("<Folder>\n" +
                                 "<name>" + Microsoft.FamilyShowLib.Properties.Resources.Cremations + "</name>\n" +
                                 "<open>0</open>");

                    foreach (Person p in peopleCollection)
                    {
                        if (!(hideliving && p.IsLiving))
                        {
                            if (!string.IsNullOrEmpty(p.CremationPlace) && p.Restriction != Restriction.Private)
                            {
                                tw.WriteLine("<Placemark>\n" +
                                             "<name>" + p.FullName + "</name>\n" +
                                             "<address>" + p.CremationPlace + "</address>\n" +
                                             "<description>" + p.CremationPlace + "</description>");

                                if (p.Gender == Gender.Male)
                                {
                                    tw.WriteLine("<styleUrl>#msn_man</styleUrl>\n</Placemark>");
                                }
                                else
                                {
                                    tw.WriteLine("<styleUrl>#msn_woman</styleUrl>\n</Placemark>");
                                }

                                i++;
                            }
                        }
                    }

                    tw.WriteLine("</Folder>");
                }

                if (marriages)
                {
                    tw.WriteLine("<Folder>\n" +
                                 "<name>" + Microsoft.FamilyShowLib.Properties.Resources.Marriages + "</name>\n" +
                                 "<open>0</open>");

                    foreach (Person p in peopleCollection)
                    {
                        if (!(hideliving && p.IsLiving))
                        {
                            if (p.Restriction != Restriction.Private)
                            {
                                foreach (Relationship rel in p.Relationships)
                                {
                                    if (rel.RelationshipType == RelationshipType.Spouse)
                                    {
                                        SpouseRelationship spouseRel = ((SpouseRelationship)rel);

                                        if (!string.IsNullOrEmpty(spouseRel.MarriagePlace))
                                        {
                                            tw.WriteLine("<Placemark>\n" +
                                                         "<name>" + p.FullName + "</name>\n" +
                                                         "<address>" + spouseRel.MarriagePlace + "</address>\n" +
                                                         "<description>" + spouseRel.MarriagePlace + "</description>");


                                            if (p.Gender == Gender.Male)
                                            {
                                                tw.WriteLine("<styleUrl>#msn_man</styleUrl>\n</Placemark>");
                                            }
                                            else
                                            {
                                                tw.WriteLine("<styleUrl>#msn_woman</styleUrl>\n</Placemark>");
                                            }

                                            i++;
                                        }
                                    }
                                }
                            }
                        }
                    }

                    tw.WriteLine("</Folder>");
                }

                #endregion
            }
            else if (times)
            {
                #region place with time information

                tw.WriteLine("<Folder>\n" +
                             "<name>" + Microsoft.FamilyShowLib.Properties.Resources.Events + "</name>\n" +
                             "<open>0</open>");

                if (births)
                {
                    tw.WriteLine("<Folder>\n" +
                                 "<name>" + Microsoft.FamilyShowLib.Properties.Resources.Births + "</name>\n" +
                                 "<open>0</open>");

                    foreach (Person p in peopleCollection)
                    {
                        if (!(hideliving && p.IsLiving))
                        {
                            if (!string.IsNullOrEmpty(p.BirthPlace) && p.Restriction != Restriction.Private)
                            {
                                tw.WriteLine("<Placemark>\n" +
                                             "	<name>"+ p.FullName + "</name>\n" +
                                             "	<address>"+ p.BirthPlace + "</address>\n" +
                                             "	<description>"+ p.BirthPlace + "</description>\n" +
                                             "   <TimeStamp>\n<when>" + p.YearOfBirth + "</when>\n</TimeStamp>");

                                if (p.Gender == Gender.Male)
                                {
                                    tw.WriteLine("<styleUrl>#msn_man</styleUrl>\n</Placemark>");
                                }
                                else
                                {
                                    tw.WriteLine("<styleUrl>#msn_woman</styleUrl>\n</Placemark>");
                                }

                                i++;
                            }
                        }
                    }

                    tw.WriteLine("</Folder>");
                }

                if (deaths)
                {
                    tw.WriteLine("<Folder>\n" +
                                 "<name>" + Microsoft.FamilyShowLib.Properties.Resources.Deaths + "</name>\n" +
                                 "<open>0</open>");

                    foreach (Person p in peopleCollection)
                    {
                        if (!(hideliving && p.IsLiving))
                        {
                            if (!string.IsNullOrEmpty(p.DeathPlace) && p.Restriction != Restriction.Private)
                            {
                                tw.WriteLine("<Placemark>\n" +
                                             "<name>" + p.FullName + "</name>\n" +
                                             "<address>" + p.DeathPlace + "</address>\n" +
                                             "<description>" + p.DeathPlace + "</description>\n" +
                                             "<TimeStamp>\n<when>" + p.YearOfDeath + "</when>\n</TimeStamp>");

                                if (p.Gender == Gender.Male)
                                {
                                    tw.WriteLine("<styleUrl>#msn_man</styleUrl>\n</Placemark>");
                                }
                                else
                                {
                                    tw.WriteLine("<styleUrl>#msn_woman</styleUrl>\n</Placemark>");
                                }

                                i++;
                            }
                        }
                    }

                    tw.WriteLine("</Folder>");
                }

                if (deaths)
                {
                    tw.WriteLine("<Folder>\n" +
                                 "<name>" + Microsoft.FamilyShowLib.Properties.Resources.Burials + "</name>\n" +
                                 "<open>0</open>");

                    foreach (Person p in peopleCollection)
                    {
                        if (!(hideliving && p.IsLiving))
                        {
                            string year = string.Empty;

                            if (p.BurialDate != null)
                            {
                                year = p.BurialDate.Value.Year.ToString();
                            }

                            if (!string.IsNullOrEmpty(p.BurialPlace) && p.Restriction != Restriction.Private && !string.IsNullOrEmpty(year))
                            {
                                tw.WriteLine("<Placemark>\n" +
                                             "<name>" + p.FullName + "</name>\n" +
                                             "<address>" + p.BurialPlace + "</address>\n" +
                                             "<description>" + p.BurialPlace + "</description>\n" +
                                             "<TimeStamp>\n<when>" + year + "</when>\n</TimeStamp>");

                                if (p.Gender == Gender.Male)
                                {
                                    tw.WriteLine("<styleUrl>#msn_man</styleUrl>\n</Placemark>");
                                }
                                else
                                {
                                    tw.WriteLine("<styleUrl>#msn_woman</styleUrl>\n</Placemark>");
                                }

                                i++;
                            }
                        }
                    }

                    tw.WriteLine("</Folder>");
                }

                if (cremations)
                {
                    tw.WriteLine("<Folder>\n" +
                                 "<name>" + Microsoft.FamilyShowLib.Properties.Resources.Cremations + "</name>\n" +
                                 "<open>0</open>");

                    foreach (Person p in peopleCollection)
                    {
                        if (!(hideliving && p.IsLiving))
                        {
                            string year = string.Empty;

                            if (p.CremationDate != null)
                            {
                                year = p.CremationDate.Value.Year.ToString();
                            }

                            if (!string.IsNullOrEmpty(p.CremationPlace) && p.Restriction != Restriction.Private && !string.IsNullOrEmpty(year))
                            {
                                tw.WriteLine("<Placemark>\n" +
                                             "<name>" + p.FullName + "</name>\n" +
                                             "<address>" + p.CremationPlace + "</address>\n" +
                                             "<description>" + p.CremationPlace + "</description>\n" +
                                             "<TimeStamp>\n<when>" + year + "</when>\n</TimeStamp>");

                                if (p.Gender == Gender.Male)
                                {
                                    tw.WriteLine("<styleUrl>#msn_man</styleUrl>\n</Placemark>");
                                }
                                else
                                {
                                    tw.WriteLine("<styleUrl>#msn_woman</styleUrl>\n</Placemark>");
                                }

                                i++;
                            }
                        }
                    }

                    tw.WriteLine("</Folder>");
                }

                if (marriages)
                {
                    tw.WriteLine("<Folder>\n" +
                                 "<name>" + Microsoft.FamilyShowLib.Properties.Resources.Marriages + "</name>\n" +
                                 "<open>0</open>");

                    foreach (Person p in peopleCollection)
                    {
                        if (!(hideliving && p.IsLiving))
                        {
                            if (p.Restriction != Restriction.Private)
                            {
                                foreach (Relationship rel in p.Relationships)
                                {
                                    if (rel.RelationshipType == RelationshipType.Spouse)
                                    {
                                        SpouseRelationship spouseRel = ((SpouseRelationship)rel);

                                        if (!string.IsNullOrEmpty(spouseRel.MarriagePlace))
                                        {
                                            string date = string.Empty;

                                            if (spouseRel.MarriageDate != null)
                                            {
                                                date = spouseRel.MarriageDate.Value.Year.ToString();
                                            }

                                            tw.WriteLine("<Placemark>\n" +
                                                         "<name>" + p.FullName + "</name>\n" +
                                                         "<address>" + spouseRel.MarriagePlace + "</address>\n" +
                                                         "<description>" + spouseRel.MarriagePlace + "</description>\n" +
                                                         "<TimeStamp>\n<when>" + date + "</when>\n</TimeStamp>");


                                            if (p.Gender == Gender.Male)
                                            {
                                                tw.WriteLine("<styleUrl>#msn_man</styleUrl>\n</Placemark>");
                                            }
                                            else
                                            {
                                                tw.WriteLine("<styleUrl>#msn_woman</styleUrl>\n</Placemark>");
                                            }

                                            i++;
                                        }
                                    }
                                }
                            }
                        }
                    }

                    tw.WriteLine("</Folder>");
                }
                #endregion
            }
            else if (lifespans)
            {
                #region lifespans

                tw.WriteLine("<Folder>\n" +
                             "<name>" + Microsoft.FamilyShowLib.Properties.Resources.People + "</name>\n" +
                             "<open>0</open>");

                foreach (Person p in peopleCollection)
                {
                    if (!(hideliving && p.IsLiving))
                    {
                        if (p.Restriction != Restriction.Private)
                        {
                            string place = string.Empty;

                            if (!string.IsNullOrEmpty(p.BirthPlace) && string.IsNullOrEmpty(place))
                            {
                                place = p.BirthPlace;
                            }

                            if (!string.IsNullOrEmpty(p.DeathPlace) && string.IsNullOrEmpty(place))
                            {
                                place = p.DeathPlace;
                            }

                            tw.WriteLine("<Placemark>\n" +
                                         "<name>" + p.FullName + "</name>\n" +
                                         "<address>" + place + "</address>\n" +
                                         "<description>" + place + "</description>\n" +
                                         "<TimeSpan>");
                            if (!string.IsNullOrEmpty(p.YearOfBirth))
                            {
                                tw.WriteLine("<begin>" + p.YearOfBirth + "</begin>");
                            }
                            if (!string.IsNullOrEmpty(p.YearOfBirth))
                            {
                                tw.WriteLine("<end>" + p.YearOfDeath + "</end>");
                            }

                            tw.WriteLine("</TimeSpan>");

                            if (p.Gender == Gender.Male)
                            {
                                tw.WriteLine("<styleUrl>#msn_man</styleUrl>\n</Placemark>");
                            }
                            else
                            {
                                tw.WriteLine("<styleUrl>#msn_woman</styleUrl>\n</Placemark>");
                            }

                            i++;
                        }
                    }
                }

                #endregion
            }

            tw.WriteLine("</Folder>\n" +
                         "</Document>\n" +
                         "</kml>");

            tw.Close();

            string[] summary = new string[2];

            summary[0] = i.ToString() + " " + Microsoft.FamilyShowLib.Properties.Resources.PlacesExported;
            summary[1] = fileName.ToString();

            if (i == 0)
            {
                File.Delete(fileName);
                summary[0] = Microsoft.FamilyShowLib.Properties.Resources.NoPlaces;
                summary[1] = "No file";
            }

            return(summary);
        }
Example #2
0
        /// <summary>
        /// Update the marriage / divorce information for the two people.
        /// </summary>
        private static void ImportMarriage(Person husband, Person wife, XmlNode node, XmlDocument doc)
        {
            // Return right away if there are not two people.
            if (husband == null || wife == null)
            {
                return;
            }

            // See if a marriage (or divorce) is specified.
            if (node.SelectSingleNode("MARR") != null || node.SelectSingleNode("DIV") != null)
            {
                string   marriageDateDescriptor     = GetValueDateDescriptor(node, "MARR/DATE");
                DateTime?marriageDate               = GetValueDate(node, "MARR/DATE");
                string   marriagePlace              = GetValue(node, "MARR/PLAC");
                string   marriageSource             = GetValueId(node, "MARR/SOUR");
                string   marriageCitation           = GetValue(node, "MARR/SOUR/PAGE");
                string   marriageCitationActualText = GetValue(node, "MARR/SOUR/DATA/TEXT");

                string marriageCitationNote = ImportEventNote(node, "MARR/SOUR/NOTE", doc);
                string marriageLink         = string.Empty;

                if (GetValue(node, "MARR/SOUR/OBJE/FORM") == "URL")  //get correct link if present
                {
                    marriageLink = GetValue(node, "MARR/SOUR/OBJE/TITL");
                }

                if (string.IsNullOrEmpty(marriageLink))  //if no link see if there is one in the note
                {
                    marriageLink = GetLink(marriageCitationNote);
                }

                string   divorceDateDescriptor     = GetValueDateDescriptor(node, "DIV/DATE");
                DateTime?divorceDate               = GetValueDate(node, "DIV/DATE");
                string   divorceSource             = GetValueId(node, "DIV/SOUR");
                string   divorceCitation           = GetValue(node, "DIV/SOUR/PAGE");
                string   divorceCitationActualText = GetValue(node, "DIV/SOUR/DATA/TEXT");

                string divorceCitationNote = ImportEventNote(node, "DIV/SOUR/NOTE", doc);
                string divorceLink         = string.Empty;

                if (GetValue(node, "DIV/SOUR/OBJE/FORM") == "URL")  //get correct link if present
                {
                    divorceLink = GetValue(node, "DIV/SOUR/OBJE/TITL");
                }

                if (string.IsNullOrEmpty(divorceLink))  //if no link see if there is one in the note
                {
                    divorceLink = GetLink(divorceCitationNote);
                }

                SpouseModifier modifier = GetDivorced(node) ? SpouseModifier.Former : SpouseModifier.Current;

                // Add info to husband.
                if (husband.GetSpouseRelationship(wife) == null)
                {
                    SpouseRelationship husbandMarriage = new SpouseRelationship(wife, modifier);

                    husbandMarriage.MarriageDate           = marriageDate;
                    husbandMarriage.MarriageDateDescriptor = marriageDateDescriptor;
                    husbandMarriage.MarriagePlace          = marriagePlace;

                    husbandMarriage.MarriageCitation           = marriageCitation;
                    husbandMarriage.MarriageSource             = marriageSource;
                    husbandMarriage.MarriageLink               = marriageLink;
                    husbandMarriage.MarriageCitationNote       = marriageCitationNote;
                    husbandMarriage.MarriageCitationActualText = marriageCitationActualText;

                    husbandMarriage.DivorceDate           = divorceDate;
                    husbandMarriage.DivorceDateDescriptor = divorceDateDescriptor;

                    husbandMarriage.DivorceCitation           = divorceCitation;
                    husbandMarriage.DivorceSource             = divorceSource;
                    husbandMarriage.DivorceLink               = divorceLink;
                    husbandMarriage.DivorceCitationNote       = divorceCitationNote;
                    husbandMarriage.DivorceCitationActualText = divorceCitationActualText;

                    husband.Relationships.Add(husbandMarriage);
                }

                // Add info to wife.
                if (wife.GetSpouseRelationship(husband) == null)
                {
                    SpouseRelationship wifeMarriage = new SpouseRelationship(husband, modifier);
                    wifeMarriage.MarriageDate           = marriageDate;
                    wifeMarriage.MarriageDateDescriptor = marriageDateDescriptor;
                    wifeMarriage.MarriagePlace          = marriagePlace;

                    wifeMarriage.MarriageCitation           = marriageCitation;
                    wifeMarriage.MarriageSource             = marriageSource;
                    wifeMarriage.MarriageLink               = marriageLink;
                    wifeMarriage.MarriageCitationNote       = marriageCitationNote;
                    wifeMarriage.MarriageCitationActualText = marriageCitationActualText;

                    wifeMarriage.DivorceDate           = divorceDate;
                    wifeMarriage.DivorceDateDescriptor = divorceDateDescriptor;

                    wifeMarriage.DivorceCitation           = divorceCitation;
                    wifeMarriage.DivorceSource             = divorceSource;
                    wifeMarriage.DivorceLink               = divorceLink;
                    wifeMarriage.DivorceCitationNote       = divorceCitationNote;
                    wifeMarriage.DivorceCitationActualText = divorceCitationActualText;

                    wife.Relationships.Add(wifeMarriage);
                }
            }
            else
            {
                SpouseRelationship wifeMarriage    = new SpouseRelationship(husband, SpouseModifier.Current);
                SpouseRelationship husbandMarriage = new SpouseRelationship(wife, SpouseModifier.Current);

                wife.Relationships.Add(wifeMarriage);
                husband.Relationships.Add(husbandMarriage);
            }
        }
Example #3
0
        /// <summary>
        /// Export marriage / divorce information.
        /// </summary>
        private void ExportMarriage(Person partnerLeft, Person partnerRight, SpouseRelationship relationship)
        {
            // PartnerLeft.
            if (partnerLeft != null && partnerLeft.Gender == Gender.Male)
            {
                WriteLine(1, "HUSB", string.Format(CultureInfo.InvariantCulture,
                                                   "@{0}@", idMap.Get(partnerLeft.Id)));
            }

            if (partnerLeft != null && partnerLeft.Gender == Gender.Female)
            {
                WriteLine(1, "WIFE", string.Format(CultureInfo.InvariantCulture,
                                                   "@{0}@", idMap.Get(partnerLeft.Id)));
            }

            if (!partnerLeft.Spouses.Contains(partnerRight))
            {
                return;
            }

            // PartnerRight.
            if (partnerRight != null && partnerRight.Gender == Gender.Male)
            {
                WriteLine(1, "HUSB", string.Format(CultureInfo.InvariantCulture,
                                                   "@{0}@", idMap.Get(partnerRight.Id)));
            }

            if (partnerRight != null && partnerRight.Gender == Gender.Female)
            {
                WriteLine(1, "WIFE", string.Format(CultureInfo.InvariantCulture,
                                                   "@{0}@", idMap.Get(partnerRight.Id)));
            }

            if (relationship == null)
            {
                return;
            }


            // Marriage.
            if (relationship.SpouseModifier == SpouseModifier.Current)
            {
                WriteLine(1, "MARR", "");

                if (relationship.MarriageDate != null)
                {
                    string Date = ExportDate(relationship.MarriageDate);
                    // Date if it exist.

                    if (relationship.MarriageDateDescriptor != null && relationship.MarriageDateDescriptor.Length > 1)
                    {
                        WriteLine(2, "DATE", relationship.MarriageDateDescriptor + Date);
                    }
                    else
                    {
                        WriteLine(2, "DATE", Date);
                    }
                }
                //Place if it exist.
                if (relationship.MarriagePlace != null && relationship.MarriagePlace.Length > 0)
                {
                    WriteLine(2, "PLAC", relationship.MarriagePlace);
                }

                //Source if it exist.
                if (!string.IsNullOrEmpty(relationship.MarriageSource) && !string.IsNullOrEmpty(relationship.MarriageCitation) && ExportableCitation(relationship.MarriageSource) == true)
                {
                    WriteLine(2, "SOUR", "@" + relationship.MarriageSource + "@");
                    WriteLine(3, "PAGE", relationship.MarriageCitation);
                    WriteLine(3, "DATA", "");
                    if (!string.IsNullOrEmpty(relationship.MarriageCitationActualText))
                    {
                        WriteLine(4, "TEXT", relationship.MarriageCitationActualText);
                    }
                    //Many programs ignore web links so add web link to note.
                    if (!string.IsNullOrEmpty(relationship.MarriageCitationNote) && string.IsNullOrEmpty(relationship.MarriageLink))
                    {
                        WriteLine(3, "NOTE", relationship.MarriageCitationNote);
                    }
                    if (!string.IsNullOrEmpty(relationship.MarriageCitationNote) && !string.IsNullOrEmpty(relationship.MarriageLink))
                    {
                        WriteLine(3, "NOTE", relationship.MarriageCitationNote + " " + relationship.MarriageLink);
                    }
                    if (string.IsNullOrEmpty(relationship.MarriageCitationNote) && !string.IsNullOrEmpty(relationship.MarriageLink))
                    {
                        WriteLine(3, "NOTE", relationship.MarriageLink);
                    }

                    if (!string.IsNullOrEmpty(relationship.MarriageLink))
                    {
                        WriteLine(3, "OBJE", "");
                        WriteLine(4, "FORM", "URL");
                        WriteLine(4, "TITL", "URL of citation");
                        WriteLine(4, "FILE", relationship.MarriageLink);
                    }
                }
            }

            // Divorce.
            if (relationship.SpouseModifier == SpouseModifier.Former)
            {
                WriteLine(1, "MARR", "");

                if (relationship.MarriageDate != null)
                {
                    string Date = ExportDate(relationship.MarriageDate);
                    // Date if it exist.

                    if (relationship.MarriageDateDescriptor != null && relationship.MarriageDateDescriptor.Length > 1)
                    {
                        WriteLine(2, "DATE", relationship.MarriageDateDescriptor + Date);
                    }
                    else
                    {
                        WriteLine(2, "DATE", Date);
                    }
                }
                //Place if it exist.
                if (relationship.MarriagePlace != null && relationship.MarriagePlace.Length > 0)
                {
                    WriteLine(2, "PLAC", relationship.MarriagePlace);
                }

                //Source if it exist.
                if (!string.IsNullOrEmpty(relationship.MarriageSource) && !string.IsNullOrEmpty(relationship.MarriageCitation) && ExportableCitation(relationship.MarriageSource) == true)
                {
                    WriteLine(2, "SOUR", "@" + relationship.MarriageSource + "@");
                    WriteLine(3, "PAGE", relationship.MarriageCitation);
                    WriteLine(3, "DATA", "");
                    if (!string.IsNullOrEmpty(relationship.MarriageCitationActualText))
                    {
                        WriteLine(4, "TEXT", relationship.MarriageCitationActualText);
                    }
                    //Many programs ignore web links so add web link to note.
                    if (!string.IsNullOrEmpty(relationship.MarriageCitationNote) && string.IsNullOrEmpty(relationship.MarriageLink))
                    {
                        WriteLine(3, "NOTE", relationship.MarriageCitationNote);
                    }
                    if (!string.IsNullOrEmpty(relationship.MarriageCitationNote) && !string.IsNullOrEmpty(relationship.MarriageLink))
                    {
                        WriteLine(3, "NOTE", relationship.MarriageCitationNote + " " + relationship.MarriageLink);
                    }
                    if (string.IsNullOrEmpty(relationship.MarriageCitationNote) && !string.IsNullOrEmpty(relationship.MarriageLink))
                    {
                        WriteLine(3, "NOTE", relationship.MarriageLink);
                    }

                    if (!string.IsNullOrEmpty(relationship.MarriageLink))
                    {
                        WriteLine(3, "OBJE", "");
                        WriteLine(4, "FORM", "URL");
                        WriteLine(4, "TITL", "URL of citation");
                        WriteLine(4, "FILE", relationship.MarriageLink);
                    }
                }

                WriteLine(1, "DIV", "");

                if (relationship.DivorceDate != null)
                {
                    string Date = ExportDate(relationship.DivorceDate);
                    // Date if it exist.

                    if (relationship.DivorceDateDescriptor != null && relationship.DivorceDateDescriptor.Length > 1)
                    {
                        WriteLine(2, "DATE", relationship.DivorceDateDescriptor + Date);
                    }
                    else
                    {
                        WriteLine(2, "DATE", Date);
                    }
                }

                //Source if it exist.
                if (!string.IsNullOrEmpty(relationship.DivorceSource) && !string.IsNullOrEmpty(relationship.DivorceCitation) && ExportableCitation(relationship.DivorceSource) == true)
                {
                    WriteLine(2, "SOUR", "@" + relationship.DivorceSource + "@");
                    WriteLine(3, "PAGE", relationship.DivorceCitation);
                    WriteLine(3, "DATA", "");
                    if (!string.IsNullOrEmpty(relationship.DivorceCitationActualText))
                    {
                        WriteLine(4, "TEXT", relationship.DivorceCitationActualText);
                    }
                    //Many programs ignore web links so add web link to note.
                    if (!string.IsNullOrEmpty(relationship.DivorceCitationNote) && string.IsNullOrEmpty(relationship.DivorceLink))
                    {
                        WriteLine(4, "NOTE", relationship.DivorceCitationNote);
                    }
                    if (!string.IsNullOrEmpty(relationship.DivorceCitationNote) && !string.IsNullOrEmpty(relationship.DivorceLink))
                    {
                        WriteLine(4, "NOTE", relationship.DivorceCitationNote + " " + relationship.DivorceLink);
                    }
                    if (string.IsNullOrEmpty(relationship.DivorceCitationNote) && !string.IsNullOrEmpty(relationship.DivorceLink))
                    {
                        WriteLine(4, "NOTE", relationship.DivorceLink);
                    }

                    if (!string.IsNullOrEmpty(relationship.DivorceLink))
                    {
                        WriteLine(3, "OBJE", "");
                        WriteLine(4, "FORM", "URL");
                        WriteLine(4, "TITL", "URL of citation");
                        WriteLine(4, "FILE", relationship.DivorceLink);
                    }
                }
            }
        }
Example #4
0
        private void UpdateSourceIDs()
        {
            string [,] sourceIDMap = new string[2, sources.Count];

            int i = 0;

            foreach (Source s in sources)
            {
                sourceIDMap[0, i] = s.Id.Replace("@", string.Empty);
                s.Id = "S" + (i + 1).ToString();
                sourceIDMap[1, i] = s.Id;
                i++;
            }

            foreach (Person p in people)
            {
                //only ever replace an id once
                bool replacedMarriage   = false;
                bool replacedDivorce    = false;
                bool replacedBirth      = false;
                bool replacedDeath      = false;
                bool replacedCremation  = false;
                bool replacedBurial     = false;
                bool replacedOccupation = false;
                bool replacedEducation  = false;
                bool replacedReligion   = false;

                for (int z = 0; z < sources.Count; z++)
                {
                    string s1 = sourceIDMap[0, z];
                    string s2 = sourceIDMap[1, z];

                    if (p.HasSpouse)
                    {
                        foreach (Relationship rel in p.Relationships)
                        {
                            if (rel.RelationshipType == RelationshipType.Spouse)
                            {
                                SpouseRelationship spouseRel = (SpouseRelationship)rel;

                                if (spouseRel.MarriageSource != null && !replacedMarriage)
                                {
                                    spouseRel.MarriageSource = s2;
                                    replacedMarriage         = true;
                                }

                                if (spouseRel.DivorceSource != null && !replacedDivorce)
                                {
                                    spouseRel.DivorceSource = s2;
                                    replacedDivorce         = true;
                                }
                            }
                        }
                    }

                    if (p.BirthSource == s1)
                    {
                        if (s2 != null && !replacedBirth)
                        {
                            p.BirthSource = s2;
                            replacedBirth = true;
                        }
                    }
                    if (p.DeathSource == s1)
                    {
                        if (s2 != null && !replacedDeath)
                        {
                            p.DeathSource = s2;
                            replacedDeath = true;
                        }
                    }
                    if (p.OccupationSource == s1)
                    {
                        if (s2 != null && !replacedOccupation)
                        {
                            p.OccupationSource = s2;
                            replacedOccupation = true;
                        }
                    }
                    if (p.EducationSource == s1)
                    {
                        if (s2 != null && !replacedEducation)
                        {
                            p.EducationSource = s2;
                            replacedEducation = true;
                        }
                    }
                    if (p.ReligionSource == s1)
                    {
                        if (s2 != null && !replacedReligion)
                        {
                            p.ReligionSource = s2;
                            replacedReligion = true;
                        }
                    }

                    if (p.CremationSource == s1)
                    {
                        if (s2 != null && !replacedCremation)
                        {
                            p.CremationSource = s2;
                            replacedCremation = true;
                        }
                    }

                    if (p.BurialSource == s1)
                    {
                        if (s2 != null && !replacedBurial)
                        {
                            p.BurialSource = s2;
                            replacedBurial = true;
                        }
                    }
                }
            }
        }