// Constructor public CIEvent( CPGDate date, string sType, string sDescription, string sOverview, string sNote, bool sImportant, bool bCapitalise ) { m_epPreference = EPreference.Unknown; m_date = date; if( bCapitalise ) { CCreator.Capitalise( ref sDescription ); } if( sDescription.Length > 0 ) { if( sDescription[ sDescription.Length - 1 ] == '.' ) { m_sDescription = sDescription.Substring( 0, sDescription.Length - 1 ); } else { m_sDescription = sDescription; } } m_sOverview = sOverview; m_bImportant = sImportant; m_sNote = sNote; if( sNote == "" ) { m_sNote = null; } m_sType = sType; }
// Copy constructor public CEventDetail( CEventDetail ed ) : base(ed.Gedcom) { m_sEventOrFactClassification = ed.m_sEventOrFactClassification; if( ed.m_dateValue != null ) { m_dateValue = new CPGDate( ed.m_dateValue ); } else { m_dateValue = null; } if( ed.m_placeStructure != null ) { m_placeStructure = new CPlaceStructure( ed.m_placeStructure ); } else { m_placeStructure = null; } if( ed.m_addressStructure != null ) { m_addressStructure = new CAddressStructure( ed.m_addressStructure ); } else { m_addressStructure = null; } m_sResponsibleAgency = ed.m_sResponsibleAgency; m_sReligiousAffiliation = ed.m_sReligiousAffiliation; m_sCauseOfEvent = ed.m_sCauseOfEvent; m_sRestrictionNotice = ed.m_sRestrictionNotice; m_alNoteStructures = new ArrayList(); foreach( CNoteStructure ns in ed.m_alNoteStructures ) { m_alNoteStructures.Add( ns.CopyConstructor() ); } m_alSourceCitations = new ArrayList(); foreach( CSourceCitation sc in ed.m_alSourceCitations ) { m_alSourceCitations.Add( sc.CopyConstructor() ); } m_alMultimediaLinks = new ArrayList(); foreach( CMultimediaLink ml in ed.m_alMultimediaLinks ) { m_alMultimediaLinks.Add( ml.CopyConstructor() ); } m_sAgeAtEvent = ed.m_sAgeAtEvent; m_sHusbandAgeAtEvent = ed.m_sHusbandAgeAtEvent; m_sWifeAgeAtEvent = ed.m_sWifeAgeAtEvent; m_xrefFam = ed.m_xrefFam; m_bAdoptedByHusband = ed.m_bAdoptedByHusband; m_bAdoptedByWife = ed.m_bAdoptedByWife; m_xrefAdoptedChild = ed.m_xrefAdoptedChild; m_sAlternativePlace = ed.m_sAlternativePlace; }
// Goes through all families this person was a irSibling in and finds their frParents and siblings. private void AddParentsAndSiblings() { // Set a limit for date comparisons DateTime dtNow = DateTime.Now; // Go through all families this person was a irSibling in foreach (CChildToFamilyLink cfl in m_ir.m_alChildToFamilyLinks) { CFamilyRecord fr = m_gedcom.GetFamilyRecord(cfl.m_xrefFam); if (fr != null) { CIndividualRecord husband = m_gedcom.GetIndividualRecord(fr.m_xrefHusband); CIndividualRecord wife = m_gedcom.GetIndividualRecord(fr.m_xrefWife); if (husband != null || wife != null) { CHusbandAndWife parents = new CHusbandAndWife(); parents.m_irHusband = husband; parents.m_irWife = wife; m_alParents.Add(parents); } // Get all the children in order, to find previous and next irSibling CPGDate testBirthday = (m_qdateInferredBirthday != null) ? m_qdateInferredBirthday.m_date : null; if (testBirthday == null) { testBirthday = new CPGDate(dtNow); } int previousDifference = -100 * 365; // 100 years should be enough int nextDifference = 100 * 365; int previousXrefDifference = -100 * 365; // Arbitrary big value int nextXrefDifference = 100 * 365; // Arbitrary big value int xrefNumber = CGedcom.MakeXrefNumber(m_ir.m_xref); foreach (CChild ch in fr.m_alChildren) { if (ch.m_ir.m_xref == m_ir.m_xref) continue; CIndividualRecord child = ch.m_ir; if (child != null) { if (child.Visibility() == CIndividualRecord.EVisibility.Invisible) continue; CEventDetail childBirthday = child.GetEvent("BIRT"); if (childBirthday == null) { childBirthday = child.GetEvent("CHR"); } if (childBirthday == null) { childBirthday = child.GetEvent("BAPM"); } CPGDate childBirthdate = null; if (childBirthday != null) childBirthdate = childBirthday.m_dateValue; if (childBirthdate == null) { childBirthdate = new CPGDate(dtNow); } int difference = CPGDate.Difference(testBirthday, childBirthdate); if (difference < 0) { if (difference > previousDifference) { previousDifference = difference; m_sPreviousChildLink = MakeLink(child,"previous child"); } } else if (difference > 0) { if (difference < nextDifference) { nextDifference = difference; m_sNextChildLink = MakeLink(child,"next child"); } } else { // Twins or no birthday. Sort according to xref number int childXrefNumber = CGedcom.MakeXrefNumber(ch.m_ir.m_xref); int xrefDifference = xrefNumber - childXrefNumber; if (xrefDifference < 0) { if (xrefDifference > previousXrefDifference) { previousXrefDifference = xrefDifference; m_sPreviousChildLink = MakeLink(child,"previous child"); } } else { if (xrefDifference < nextXrefDifference) { nextXrefDifference = xrefDifference; m_sNextChildLink = MakeLink(child,"next child"); } } } // end 3 way if } // end if(irSibling != null ) } // end foreach irSibling } // end if( fr != null ) } // end foreach fr }
// Extracts the data from the MARR event for the fr record. private string AddMarriageEvent( CFamilyRecord fr, string sourceRefs, out CPGDate marriageDate, out string marriageNote, out string marriagePlace ) { // Find out when they were married marriageDate = null; marriagePlace = ""; sourceRefs = ""; marriageNote = ""; foreach (CFamilyEventStructure fes in fr.m_alFamilyEventStructures) { if (fes.Type == "MARR") { if (fes.m_eventDetail != null) { marriageDate = fes.m_eventDetail.m_dateValue; if (fes.m_eventDetail.m_placeStructure != null) { if (fes.m_eventDetail.m_placeStructure.m_sPlaceName != "") marriagePlace = String.Concat(" ", MainForm.s_config.m_sPlaceWord, " ", EscapeHTML(fes.m_eventDetail.m_placeStructure.m_sPlaceName, false)); } sourceRefs = AddSources(ref m_alReferenceList, fes.m_eventDetail.m_alSourceCitations); if (fes.m_eventDetail.m_alNoteStructures != null) { foreach (CNoteStructure ns in fes.m_eventDetail.m_alNoteStructures) { if (ns.Text != null && ns.Text.Length > 0) { if (marriageNote != "") { marriageNote += "\n"; } if (MainForm.s_config.m_bObfuscateEmails) { marriageNote += ObfuscateEmail(ns.Text); } else { marriageNote += ns.Text; } } } } break; } } } return sourceRefs; }
// Picks the individual's occupation closest to the given date, within the given limits. private static string BestOccupation(ArrayList occupations, CPGDate givenDate, CPGDate lowerLimit, CPGDate upperLimit) { int minDifference; if (lowerLimit == null || upperLimit == null) { minDifference = Int32.MaxValue; } else { minDifference = Math.Abs(CPGDate.Difference(lowerLimit, upperLimit)); } COccupationCounter bestOc = null; foreach (COccupationCounter oc in occupations) { if (oc.m_date == null) { // Dateless occupation assumed to be the generic answer return oc.m_sName; } else { int sdifference = CPGDate.Difference(givenDate, oc.m_date); int difference = Math.Abs(sdifference); if (Math.Sign(sdifference) == -1) { // favours occupations before date rather than after it. difference *= 3; difference /= 2; } if (Math.Abs(difference) < minDifference) { minDifference = difference; bestOc = oc; } } } if (bestOc == null) return ""; return bestOc.m_sName; }
// The main method that causes the page to be created. public bool Create( CStats stats ) { LogFile.TheLogFile.WriteLine(LogFile.DT_HTML, LogFile.EDebugLevel.Note, "CCreatorRecordIndividual.Create()"); if (m_ir == null) { return false; } if (m_ir.Visibility() == CIndividualRecord.EVisibility.Invisible) { return false; } // Collect together multimedia links if (MainForm.s_config.m_bAllowMultimedia && (m_ir.m_alUniqueFileRefs != null) && !m_bConcealed) { m_ir.m_alUniqueFileRefs.Sort(new CMultimediaFileReference.OrderComparer()); AddMultimedia( null, m_ir.m_alUniqueFileRefs, String.Concat(m_ir.m_xref, "mm"), String.Concat(m_ir.m_xref, "mo"), MainForm.s_config.m_uMaxImageWidth, MainForm.s_config.m_uMaxImageHeight, stats ); } AddEvents(); RemoveLoneOccupation(); if (m_qdateInferredBirthday != null && m_qdateInferredBirthday.m_eqQualification == CPGQualifiedDate.EQualification.Birth) { m_dateActualBirthday = m_qdateInferredBirthday.m_date; } if (m_qdateInferredDeathday != null && m_qdateInferredDeathday.m_eqQualification == CPGQualifiedDate.EQualification.Death) { m_dateActualDeathday = m_qdateInferredDeathday.m_date; } ConstructName(); CPGDate age30; if (m_qdateInferredBirthday != null && CPGDate.IsValid(m_qdateInferredBirthday.m_date)) { age30 = new CPGDate(m_qdateInferredBirthday.m_date); } else { age30 = new CPGDate(DateTime.Now); } age30.m_year.m_nYear += MainForm.s_config.m_nAgeForOccupation; // We should have birthday and deathday by now, so find longest occupation if (!m_bConcealed) { m_sOccupation = BestOccupation(m_alOccupations, age30, (m_qdateInferredBirthday != null) ? m_qdateInferredBirthday.m_date : null, (m_qdateInferredDeathday != null) ? m_qdateInferredDeathday.m_date : null);// Picks occupation with longest time span } // Go through all families this person was a irSubject to if (!m_bConcealed) { foreach (CSpouseToFamilyLink sfl in m_ir.m_alSpouseToFamilyLinks) { CFamilyRecord fr = m_gedcom.GetFamilyRecord(sfl.m_xrefFam); if (fr != null) { // Find the irSubject's name CIndividualRecord spouse = null; string spouseLink = ""; if (fr.m_xrefHusband != m_ir.m_xref) { spouse = m_gedcom.GetIndividualRecord(fr.m_xrefHusband); } else { spouse = m_gedcom.GetIndividualRecord(fr.m_xrefWife); } if (spouse != null && spouse.Visibility() != CIndividualRecord.EVisibility.Invisible) { spouseLink = MakeLink(spouse); } // Add fr events as events connected to this individual foreach (CFamilyEventStructure fes in fr.m_alFamilyEventStructures) { ProcessEvent(fes, spouseLink ); } AddChildrensEvents(fr); AddMarriage( spouse, spouseLink, fr ); } } AddParentsAndSiblings(); } // end if !concealed string birthyear = ""; string deathyear = ""; if (!m_bConcealed) { if (m_qdateInferredBirthday != null && m_qdateInferredBirthday.m_date != null) { birthyear = m_qdateInferredBirthday.m_date.Year; } if (m_qdateInferredDeathday != null && m_qdateInferredDeathday.m_date != null) { deathyear = m_qdateInferredDeathday.m_date.Year; } } string title = m_sName; //"Fred Bloggs 1871-1921" string lifeDates = ""; if (!m_bConcealed) { if (birthyear != "" || deathyear != "") { lifeDates = String.Concat(birthyear, "-", deathyear); title = String.Concat(m_sName, " ", lifeDates); } } AddIndividualIndexEntry( lifeDates ); OutputHTML( title ); return true; }
// Constructor public CCreatorRecordIndividual( CGedcom gedcom, IProgressCallback progress, string sW3cfile, CIndividualRecord ir, CCreatorIndexIndividuals indiIndexCreator, CPaintbox paintbox ) : base(gedcom, progress, sW3cfile) { m_ir = ir; m_indiIndexCreator = indiIndexCreator; m_paintbox = paintbox; m_htFirstFoundEvent = new Hashtable(); m_sBirthdaySourceRefs = ""; m_sDeathdaySourceRefs = ""; m_sNameTitle = ""; m_bUnknownName = false; m_sName = m_ir.Name; m_sNameSuffix = m_ir.NameSuffix; m_sFirstName = ""; m_sSurname = ""; m_sOccupation = ""; m_bConcealed = m_ir.Visibility() == CIndividualRecord.EVisibility.Restricted; m_alEventList = new ArrayList(); m_alAttributeList = new ArrayList(); m_alReferenceList = new ArrayList(); m_alOccupations = new ArrayList(); m_sPreviousChildLink = ""; m_sNextChildLink = ""; m_alOtherNames = new ArrayList(); m_qdateInferredBirthday = null; m_dateActualBirthday = null; m_qdateInferredDeathday = null; m_dateActualDeathday = null; m_alParents = new ArrayList(); }