public void Test_GEDCOMEventToDateStr() { GEDCOMIndividualRecord iRec = fContext.Tree.XRefIndex_Find("I1") as GEDCOMIndividualRecord; GEDCOMCustomEvent evt = iRec.FindEvent("BIRT"); Assert.IsNotNull(evt); string st2 = GKUtils.GEDCOMEventToDateStr(null, DateFormat.dfYYYY_MM_DD, false); Assert.AreEqual("", st2); st2 = GKUtils.GEDCOMEventToDateStr(evt, DateFormat.dfYYYY_MM_DD, false); Assert.AreEqual("1990.12.28", st2); evt.Cause = "test cause"; st2 = GKUtils.GetEventCause(evt); Assert.AreEqual("test cause", st2); string ds = GKUtils.GEDCOMEventToDateStr(evt, DateFormat.dfDD_MM_YYYY, false); Assert.AreEqual("28.12.1990", ds); ds = GKUtils.GEDCOMEventToDateStr(evt, DateFormat.dfYYYY_MM_DD, false); Assert.AreEqual("1990.12.28", ds); ds = GKUtils.GEDCOMEventToDateStr(evt, DateFormat.dfYYYY, false); Assert.AreEqual("1990", ds); ds = GKUtils.GEDCOMEventToDateStr(null, DateFormat.dfYYYY, false); Assert.AreEqual("", ds); }
public object gt_get_person_event_ex(object recPtr, string sign) { GEDCOMIndividualRecord iRec = recPtr as GEDCOMIndividualRecord; if (iRec == null) { return(null); } GEDCOMCustomEvent evt = iRec.FindEvent(sign); return(evt); }
private void GetEventField(StatsMode mode, List <StatsItem> values, GEDCOMIndividualRecord iRec, string evtName) { string v = "?"; GEDCOMCustomEvent evt = iRec.FindEvent(evtName); if (evt == null) { return; } int dtY = evt.GetChronologicalYear(); if (dtY == 0 && (mode != StatsMode.smBirthPlaces && mode != StatsMode.smDeathPlaces)) { return; } switch (mode) { case StatsMode.smBirthYears: case StatsMode.smDeathYears: v = Convert.ToString(dtY); break; case StatsMode.smBirthTenYears: case StatsMode.smDeathTenYears: v = Convert.ToString(dtY / 10 * 10); break; case StatsMode.smBirthPlaces: case StatsMode.smDeathPlaces: v = evt.Place.StringValue; break; } CheckVal(values, v); }
public static void FillContext(IBaseContext context) { // a null result if the record is not defined GEDCOMCustomEvent evt = context.CreateEventEx(null, "BIRT", "xxxxx", "xxxxx"); Assert.IsNull(evt); // first individual GEDCOMIndividualRecord iRec = context.CreatePersonEx("Ivan", "Ivanovich", "Ivanov", GEDCOMSex.svMale, true); Assert.IsNotNull(iRec); evt = iRec.FindEvent("BIRT"); Assert.IsNotNull(evt); evt.Date.ParseString("28 DEC 1990"); evt.Place.StringValue = "Ivanovo"; GEDCOMCustomEvent evtd = context.CreateEventEx(iRec, "DEAT", "28 DEC 2010", "Ivanovo"); Assert.IsNotNull(evtd); // second individual, wife GEDCOMIndividualRecord iRec2 = context.CreatePersonEx("Maria", "Petrovna", "Ivanova", GEDCOMSex.svFemale, true); evt = iRec2.FindEvent("BIRT"); Assert.IsNotNull(evt); evt.Date.ParseString("17 MAR 1990"); evt.Place.StringValue = "Ivanovo"; iRec.AddAssociation("spouse", iRec2); // third individual, child GEDCOMIndividualRecord iRec3 = context.CreatePersonEx("Anna", "Ivanovna", "Ivanova", GEDCOMSex.svFemale, true); evt = iRec3.FindEvent("BIRT"); Assert.IsNotNull(evt); evt.Date.ParseString("11 FEB 2010"); evt.Place.StringValue = "Ivanovo"; // their family GEDCOMFamilyRecord famRec = context.Tree.CreateFamily(); Assert.IsNotNull(famRec); famRec.AddSpouse(iRec); famRec.AddSpouse(iRec2); famRec.AddChild(iRec3); context.CreateEventEx(famRec, "MARR", "01 JAN 2000", "unknown"); // individual outside the family GEDCOMIndividualRecord iRec4 = context.CreatePersonEx("Alex", "", "Petrov", GEDCOMSex.svMale, true); evt = iRec4.FindEvent("BIRT"); Assert.IsNotNull(evt); evt.Date.ParseString("15 JUN 1989"); evt.Place.StringValue = "Far Forest"; evt = context.CreateEventEx(iRec4, "RESI", "12 FEB", "Far Forest"); Assert.IsNotNull(evt); // fifth GEDCOMIndividualRecord iRec5 = context.CreatePersonEx("Anna", "", "Jones", GEDCOMSex.svFemale, false); Assert.IsNotNull(iRec5); // group for tests GEDCOMGroupRecord groupRec = context.Tree.CreateGroup(); groupRec.GroupName = "GroupTest"; Assert.IsNotNull(groupRec, "group1 != null"); groupRec.AddMember(iRec); // location for tests GEDCOMLocationRecord locRec = context.Tree.CreateLocation(); locRec.LocationName = "Test Location"; locRec.Map.Lati = 5.11111; locRec.Map.Long = 7.99999; Assert.IsNotNull(locRec, "locRec != null"); // repository for tests GEDCOMRepositoryRecord repoRec = context.Tree.CreateRepository(); repoRec.RepositoryName = "Test repository"; Assert.IsNotNull(repoRec, "repoRec != null"); // research for tests GEDCOMResearchRecord resRec = context.Tree.CreateResearch(); resRec.ResearchName = "Test research"; Assert.IsNotNull(resRec, "resRec != null"); // source for tests GEDCOMSourceRecord srcRec = context.Tree.CreateSource(); srcRec.FiledByEntry = "Test source"; Assert.IsNotNull(srcRec, "srcRec != null"); iRec.AddSource(srcRec, "p1", 0); // note for tests GEDCOMNoteRecord noteRec = context.Tree.CreateNote(); noteRec.SetNoteText("Test note"); Assert.IsNotNull(noteRec, "noteRec != null"); iRec.AddNote(noteRec); // task for tests GEDCOMTaskRecord tskRec = context.Tree.CreateTask(); tskRec.Goal = "Test task"; Assert.IsNotNull(tskRec, "tskRec != null"); // media for tests GEDCOMMultimediaRecord mediaRec = context.Tree.CreateMultimedia(); mediaRec.AddTag("FILE", "", null); GEDCOMFileReferenceWithTitle fileRef = mediaRec.FileReferences[0]; fileRef.Title = "Test multimedia"; fileRef.LinkFile("sample.png"); Assert.IsNotNull(mediaRec, "mediaRec != null"); iRec.AddMultimedia(mediaRec); // communication for tests GEDCOMCommunicationRecord commRec = context.Tree.CreateCommunication(); commRec.CommName = "Test communication"; Assert.IsNotNull(commRec, "commRec != null"); }
private void WriteExcessFmt(PedigreePerson person) { fWriter.addParagraph(LangMan.LS(LSID.LSID_Sex) + ": " + GKUtils.SexStr(person.IRec.Sex), fTextFont); string st = GKUtils.GetLifeExpectancyStr(person.IRec); if (st != "?" && st != "") { fWriter.addParagraph(LangMan.LS(LSID.LSID_LifeExpectancy) + ": " + st, fTextFont); } GEDCOMIndividualRecord father, mother; GEDCOMFamilyRecord fam = person.IRec.GetParentsFamily(); if (fam == null) { father = null; mother = null; } else { father = fam.GetHusband(); mother = fam.GetWife(); } if (father != null) { fWriter.addParagraphLink(LangMan.LS(LSID.LSID_Father) + ": " + GKUtils.GetNameString(father, true, false) + " ", fTextFont, idLink(father), fLinkFont); } if (mother != null) { fWriter.addParagraphLink(LangMan.LS(LSID.LSID_Mother) + ": " + GKUtils.GetNameString(mother, true, false) + " ", fTextFont, idLink(mother), fLinkFont); } ExtList <PedigreeEvent> evList = new ExtList <PedigreeEvent>(true); try { int i; if (person.IRec.Events.Count > 0) { fWriter.addParagraph(LangMan.LS(LSID.LSID_Events) + ":", fTextFont); int num = person.IRec.Events.Count; for (i = 0; i < num; i++) { GEDCOMCustomEvent evt = person.IRec.Events[i]; if (!(evt is GEDCOMIndividualAttribute) || fOptions.PedigreeOptions.IncludeAttributes) { evList.Add(new PedigreeEvent(person.IRec, evt)); } } WriteEventList(person, evList); } int num2 = person.IRec.SpouseToFamilyLinks.Count; for (i = 0; i < num2; i++) { GEDCOMFamilyRecord family = person.IRec.SpouseToFamilyLinks[i].Family; if (!fBase.Context.IsRecordAccess(family.Restriction)) { continue; } GEDCOMPointer sp; string unk; if (person.IRec.Sex == GEDCOMSex.svMale) { sp = family.Wife; st = LangMan.LS(LSID.LSID_Wife) + ": "; unk = LangMan.LS(LSID.LSID_UnkFemale); } else { sp = family.Husband; st = LangMan.LS(LSID.LSID_Husband) + ": "; unk = LangMan.LS(LSID.LSID_UnkMale); } GEDCOMIndividualRecord irec = sp.Value as GEDCOMIndividualRecord; string sps; if (irec != null) { sps = st + GKUtils.GetNameString(irec, true, false) + GKUtils.GetPedigreeLifeStr(irec, fOptions.PedigreeOptions.Format) /* + this.idLink(this.FindPerson(irec))*/; } else { sps = st + unk; } fWriter.addParagraph(sps, fTextFont); evList.Clear(); int childrenCount = family.Children.Count; for (int j = 0; j < childrenCount; j++) { irec = (GEDCOMIndividualRecord)family.Children[j].Value; evList.Add(new PedigreeEvent(irec, irec.FindEvent("BIRT"))); } WriteEventList(person, evList); } } finally { evList.Dispose(); } if (fOptions.PedigreeOptions.IncludeNotes && person.IRec.Notes.Count != 0) { fWriter.addParagraph(LangMan.LS(LSID.LSID_RPNotes) + ":", fTextFont); fWriter.beginList(); int notesCount = person.IRec.Notes.Count; for (int i = 0; i < notesCount; i++) { GEDCOMNotes note = person.IRec.Notes[i]; fWriter.addListItem(" " + GKUtils.MergeStrings(note.Notes), fTextFont); } fWriter.endList(); } }
private void GetSimplePersonStat(StatsMode mode, List <StatsItem> values, GEDCOMIndividualRecord iRec) { string iName = GKUtils.GetNameString(iRec, true, false); switch (mode) { case StatsMode.smAncestors: values.Add(new StatsItem(iName, GKUtils.GetAncestorsCount(iRec) - 1)); break; case StatsMode.smDescendants: values.Add(new StatsItem(iName, GKUtils.GetDescendantsCount(iRec) - 1)); break; case StatsMode.smDescGenerations: values.Add(new StatsItem(iName, GKUtils.GetDescGenerations(iRec))); break; case StatsMode.smChildsCount: values.Add(new StatsItem(iName, iRec.GetTotalChildsCount())); break; case StatsMode.smFirstbornAge: values.Add(new StatsItem(iName, GKUtils.GetFirstbornAge(iRec, GKUtils.GetFirstborn(iRec)))); break; case StatsMode.smMarriages: values.Add(new StatsItem(iName, GKUtils.GetMarriagesCount(iRec))); break; case StatsMode.smMarriageAge: values.Add(new StatsItem(iName, GKUtils.GetMarriageAge(iRec))); break; case StatsMode.smSurnames: case StatsMode.smNames: case StatsMode.smPatronymics: GetIndiName(mode, values, iRec); break; case StatsMode.smAge: CheckVal(values, GKUtils.GetAgeStr(iRec, -1)); break; case StatsMode.smLifeExpectancy: CheckVal(values, GKUtils.GetLifeExpectancyStr(iRec)); break; case StatsMode.smBirthYears: case StatsMode.smBirthTenYears: case StatsMode.smBirthPlaces: GetEventField(mode, values, iRec, "BIRT"); break; case StatsMode.smDeathYears: case StatsMode.smDeathTenYears: case StatsMode.smDeathPlaces: GetEventField(mode, values, iRec, "DEAT"); break; case StatsMode.smChildsDistribution: CheckVal(values, iRec.GetTotalChildsCount().ToString()); break; case StatsMode.smResidences: CheckVal(values, GKUtils.GetResidencePlace(iRec, false)); break; case StatsMode.smOccupation: CheckVal(values, GKUtils.GetAttributeValue(iRec, "OCCU")); break; case StatsMode.smReligious: CheckVal(values, GKUtils.GetAttributeValue(iRec, "RELI")); break; case StatsMode.smNational: CheckVal(values, GKUtils.GetAttributeValue(iRec, "NATI")); break; case StatsMode.smEducation: CheckVal(values, GKUtils.GetAttributeValue(iRec, "EDUC")); break; case StatsMode.smCaste: CheckVal(values, GKUtils.GetAttributeValue(iRec, "CAST")); break; case StatsMode.smHobby: CheckVal(values, GKUtils.GetAttributeValue(iRec, "_HOBBY")); break; case StatsMode.smAward: CheckVal(values, GKUtils.GetAttributeValue(iRec, "_AWARD")); break; case StatsMode.smMili: CheckVal(values, GKUtils.GetAttributeValue(iRec, "_MILI")); break; case StatsMode.smMiliInd: CheckVal(values, GKUtils.GetAttributeValue(iRec, "_MILI_IND")); break; case StatsMode.smMiliDis: CheckVal(values, GKUtils.GetAttributeValue(iRec, "_MILI_DIS")); break; case StatsMode.smMiliRank: CheckVal(values, GKUtils.GetAttributeValue(iRec, "_MILI_RANK")); break; case StatsMode.smCertaintyIndex: CheckVal(values, string.Format("{0:0.00}", iRec.GetCertaintyAssessment())); break; case StatsMode.smBirthByMonth: GEDCOMCustomEvent ev = iRec.FindEvent("BIRT"); if (ev != null) { var dtx = ev.Date.Value as GEDCOMDate; if (dtx != null) { int month = dtx.GetMonthNumber(); if (month > 0) { CheckVal(values, month.ToString()); } } } break; case StatsMode.smDemography: { int lifeExp = GKUtils.GetLifeExpectancy(iRec); if (lifeExp > -1) { string v = Convert.ToString(lifeExp / 5 * 5); CheckVal(values, v, iRec.Sex); } break; } } }
protected override void InternalGenerate() { IColor clrBlack = AppHost.GfxProvider.CreateColor(0x000000); IColor clrBlue = AppHost.GfxProvider.CreateColor(0x0000FF); fTitleFont = fWriter.CreateFont("", 14f, true, false, clrBlack); fChapFont = fWriter.CreateFont("", 12f, true, false, clrBlack); fTextFont = fWriter.CreateFont("", 10f, false, false, clrBlack); //fWriter.AddParagraph(fTitle, fTitleFont, TextAlignment.taLeft); fWriter.AddParagraph(GKUtils.GetNameString(fPerson, true, false), fTitleFont, TextAlignment.taLeft); fWriter.NewLine(); var evList = new List <PersonalEvent>(); GEDCOMIndividualRecord father = null, mother = null; if (fPerson.ChildToFamilyLinks.Count > 0) { GEDCOMFamilyRecord family = fPerson.ChildToFamilyLinks[0].Family; if (fBase.Context.IsRecordAccess(family.Restriction)) { father = family.GetHusband(); mother = family.GetWife(); } } ExtractEvents(EventType.Personal, evList, fPerson); int num2 = fPerson.SpouseToFamilyLinks.Count; for (int j = 0; j < num2; j++) { GEDCOMFamilyRecord family = fPerson.SpouseToFamilyLinks[j].Family; if (!fBase.Context.IsRecordAccess(family.Restriction)) { continue; } ExtractEvents(EventType.Spouse, evList, family); int num3 = family.Children.Count; for (int i = 0; i < num3; i++) { GEDCOMIndividualRecord child = family.Children[i].Value as GEDCOMIndividualRecord; GEDCOMCustomEvent evt = child.FindEvent("BIRT"); if (evt != null && evt.GetChronologicalYear() != 0) { evList.Add(new PersonalEvent(EventType.Child, child, evt)); } } } SortHelper.QuickSort(evList, EventsCompare); fWriter.BeginList(); int num4 = evList.Count; for (int i = 0; i < num4; i++) { PersonalEvent evObj = evList[i]; if (!evObj.Date.HasKnownYear()) { continue; } GEDCOMCustomEvent evt = evObj.Event; string st = GKUtils.GetEventName(evt); string dt = GKUtils.GEDCOMEventToDateStr(evt, DateFormat.dfDD_MM_YYYY, false); if (ShowAges) { int year = evt.GetChronologicalYear(); int age = (evObj.Rec == fPerson) ? GKUtils.GetAge(fPerson, year) : -1; if (age >= 0) { dt += string.Format(" ({0})", age); } } string li = dt + ": " + st + "."; if (evt.Place.StringValue != "") { li = li + " " + LangMan.LS(LSID.LSID_Place) + ": " + evt.Place.StringValue; } fWriter.AddListItem(" " + li, fTextFont); if (evObj.Rec is GEDCOMIndividualRecord) { GEDCOMIndividualRecord iRec = evObj.Rec as GEDCOMIndividualRecord; if (evt.Name == "BIRT") { if (evObj.Type == EventType.Personal) { if (father != null) { fWriter.AddListItem(" " + " " + LangMan.LS(LSID.LSID_Father) + ": " + GKUtils.GetNameString(father, true, false) + " ", fTextFont); } if (mother != null) { fWriter.AddListItem(" " + " " + LangMan.LS(LSID.LSID_Mother) + ": " + GKUtils.GetNameString(mother, true, false) + " ", fTextFont); } } else if (evObj.Type == EventType.Child) { if (iRec.Sex == GEDCOMSex.svMale) { st = LangMan.LS(LSID.LSID_RK_Son) + ": "; } else { st = LangMan.LS(LSID.LSID_RK_Daughter) + ": "; } st = ConvertHelper.UniformName(st) + GKUtils.GetNameString(iRec, true, false); fWriter.AddListItem(" " + " " + st, fTextFont); } } } else if (evObj.Rec is GEDCOMFamilyRecord) { GEDCOMFamilyRecord famRec = evObj.Rec as GEDCOMFamilyRecord; GEDCOMIndividualRecord sp; string unk; if (fPerson.Sex == GEDCOMSex.svMale) { sp = famRec.GetWife(); st = LangMan.LS(LSID.LSID_Wife) + ": "; unk = LangMan.LS(LSID.LSID_UnkFemale); } else { sp = famRec.GetHusband(); st = LangMan.LS(LSID.LSID_Husband) + ": "; unk = LangMan.LS(LSID.LSID_UnkMale); } string sps; if (sp != null) { sps = st + GKUtils.GetNameString(sp, true, false) /* + GKUtils.GetPedigreeLifeStr(sp, fOptions.PedigreeOptions.Format)*/; } else { sps = st + unk; } fWriter.AddListItem(" " + " " + sps, fTextFont); } } fWriter.EndList(); }