Beispiel #1
0
        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);
        }
Beispiel #2
0
        private void PrepareDescendants(TVPerson person)
        {
            if (person == null)
            {
                return;
            }

            try
            {
                int gens = (person.DescGenerations <= 0) ? 1 : person.DescGenerations;
                person.GenSlice = person.BaseRadius / gens; // ?

                GEDCOMIndividualRecord iRec = person.IRec;

                foreach (GEDCOMSpouseToFamilyLink spLink in iRec.SpouseToFamilyLinks)
                {
                    GEDCOMFamilyRecord famRec = spLink.Family;

                    bool alreadyPrepared = false;

                    // processing the spouse of the current person
                    GEDCOMIndividualRecord spouse = famRec.GetSpouseBy(iRec);
                    if (spouse != null)
                    {
                        TVPerson sps = PreparePerson(null, spouse, TVPersonType.Spouse);
                        if (sps == null)
                        {
                            // this can occur only when processing of the patriarchs later than those already processed,
                            // i.e. if the at first was already processed the patriarch, born in 1710, was processed his childrens
                            // and one of theirs spouses being a patriarch of new branches!
                            Logger.LogWrite("TreeVizControl.PrepareDescendants(): an unexpected collision");
                            alreadyPrepared = true;
                        }
                        else
                        {
                            ProcessPersonStem(sps, person, TVPersonType.Spouse);

                            person.Spouses.Add(sps);
                        }
                    }

                    if (!alreadyPrepared)
                    {
                        // processing children of the current family
                        foreach (GEDCOMPointer childPtr in famRec.Children)
                        {
                            GEDCOMIndividualRecord child = (GEDCOMIndividualRecord)childPtr.Value;

                            // exclude childless branches
                            if (EXCLUDE_CHILDLESS && (fBase.Context.IsChildless(child) || child.GetTotalChildsCount() < 1))
                            {
                                continue;
                            }

                            TVPerson chp = PreparePerson(person, child, TVPersonType.Child);
                            if (chp == null)
                            {
                                // this is someone spouse and already prepared, intersection of branches
                                Logger.LogWrite("TreeVizControl.PrepareDescendants(): intersection");
                            }
                            else
                            {
                                chp.BaseRadius      = (float)((person.BaseRadius / 2) * 0.95);
                                chp.DescGenerations = person.DescGenerations - 1;

                                ProcessPersonStem(chp, person, TVPersonType.Child);

                                person.Childs.Add(chp);

                                PrepareDescendants(chp);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogWrite("TreeVizControl.PrepareDescendants(): " + ex.Message);
            }
        }
Beispiel #3
0
        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;
            }
            }
        }