private void UpdateTreeMap() { fDataMap.Model.Clear(); if (fBase == null) { fDataMap.Invalidate(); return; } GEDCOMTree tree = fBase.Context.Tree; List <GEDCOMIndividualRecord> prepared = new List <GEDCOMIndividualRecord>(); List <GEDCOMRecord> groupRecords = new List <GEDCOMRecord>(); try { int groupNum = 0; int num = tree.RecordsCount; for (int i = 0; i < num; i++) { GEDCOMRecord rec = tree[i]; if (rec.RecordType == GEDCOMRecordType.rtIndividual) { GEDCOMIndividualRecord iRec = rec as GEDCOMIndividualRecord; if (prepared.IndexOf(iRec) < 0) { groupNum++; groupRecords.Clear(); TreeTools.WalkTree(iRec, TreeTools.TreeWalkMode.twmAll, groupRecords); int groupSize = groupRecords.Count; float quality = 0.0f; for (int j = 0; j < groupSize; j++) { iRec = (GEDCOMIndividualRecord)groupRecords[j]; prepared.Add(iRec); quality += iRec.GetCertaintyAssessment(); } quality /= groupSize; string name = groupNum.ToString() + " group (" + groupSize.ToString() + ") " + quality.ToString("0.00"); CreateItem(null, name, groupSize, quality); } } } } finally { groupRecords.Clear(); //prepared.Dispose(); } fDataMap.UpdateView(); }
public CommonStats GetCommonStats() { CommonStats stats = new CommonStats(); int num = fSelectedRecords.Count; for (int i = 0; i < num; i++) { GEDCOMRecord rec = fSelectedRecords[i]; if (rec.RecordType != GEDCOMRecordType.rtIndividual) { continue; } GEDCOMIndividualRecord ind = (GEDCOMIndividualRecord)rec; stats.persons++; switch (ind.Sex) { case GEDCOMSex.svFemale: stats.persons_f++; if (ind.IsLive()) { stats.lives_f++; stats.lives++; } break; case GEDCOMSex.svMale: stats.persons_m++; if (ind.IsLive()) { stats.lives_m++; stats.lives++; } break; } string vAge = GKUtils.GetAgeStr(ind, -1); stats.age.TakeVal(vAge, ind.Sex, true); string vLife = GKUtils.GetLifeExpectancyStr(ind); stats.life.TakeVal(vLife, ind.Sex, true); int chCnt = ind.GetTotalChildsCount(); stats.childs.TakeVal(chCnt, ind.Sex, true); int vFba = GKUtils.GetFirstbornAge(ind, GKUtils.GetFirstborn(ind)); stats.fba.TakeVal(vFba, ind.Sex, true); int mCnt = GKUtils.GetMarriagesCount(ind); stats.marr.TakeVal(mCnt, ind.Sex, true); int vMAge = GKUtils.GetMarriageAge(ind); stats.mage.TakeVal(vMAge, ind.Sex, true); float vCI = ind.GetCertaintyAssessment(); stats.cIndex.TakeVal(vCI, ind.Sex, false); } return(stats); }
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; } } }
public void BuildBy(GEDCOMIndividualRecord iRec) { try { fRec = iRec; if (iRec != null) { if (fModel.PreparedIndividuals.IndexOf(iRec.XRef) < 0) { fModel.PreparedIndividuals.Add(iRec.XRef); } var parts = GKUtils.GetNameParts(iRec); fSurname = parts.Surname; fName = parts.Name; fPatronymic = parts.Patronymic; fNick = GKUtils.GetNickString(iRec); fSex = iRec.Sex; TreeChartOptions options = fModel.Options; var lifeDates = iRec.GetLifeDates(); DateFormat dateFormat = (options.OnlyYears) ? DateFormat.dfYYYY : DateFormat.dfDD_MM_YYYY; IsDead = (lifeDates.DeathEvent != null); fBirthDate = GKUtils.GEDCOMEventToDateStr(lifeDates.BirthEvent, dateFormat, false); fDeathDate = GKUtils.GEDCOMEventToDateStr(lifeDates.DeathEvent, dateFormat, false); if (options.SignsVisible) { EnumSet <SpecialUserRef> signs = EnumSet <SpecialUserRef> .Create(); int num = fRec.UserReferences.Count; for (int i = 0; i < num; i++) { string rs = fRec.UserReferences[i].StringValue; for (var cps = SpecialUserRef.urRI_StGeorgeCross; cps <= SpecialUserRef.urLast; cps++) { string sur = LangMan.LS(GKData.SpecialUserRefs[(int)cps].Title); if (rs == sur) { signs.Include(cps); } } } fSigns = signs; } else { fSigns = EnumSet <SpecialUserRef> .Create(); } if (options.PortraitsVisible) { try { fPortrait = PortraitsCache.Instance.GetImage(fModel.Base.Context, iRec); if (fPortrait == null && options.DefaultPortraits) { string resName = (fSex == GEDCOMSex.svFemale) ? "pi_female_140.png" : "pi_male_140.png"; fPortrait = AppHost.GfxProvider.GetResourceImage(resName, false); } } catch (MediaFileNotFoundException) { if (!fModel.HasMediaFail) { AppHost.StdDialogs.ShowError(LangMan.LS(LSID.LSID_ArcNotFound)); fModel.HasMediaFail = true; } } } CertaintyAssessment = iRec.GetCertaintyAssessment(); } else { fSurname = ""; fName = "< ? >"; fPatronymic = ""; fNick = ""; fBirthDate = ""; fDeathDate = ""; IsDead = false; fSex = GEDCOMSex.svNone; fSigns = EnumSet <SpecialUserRef> .Create(); CertaintyAssessment = 0.0f; } } catch (Exception ex) { Logger.LogWrite("TreeChartPerson.BuildBy(): " + ex.Message); throw; } }