コード例 #1
0
        public CommonStats GetCommonStats()
        {
            CommonStats stats = new CommonStats();

            int num = fSelectedRecords.Count;

            for (int i = 0; i < num; i++)
            {
                GDMRecord rec = fSelectedRecords[i];
                if (rec.RecordType != GDMRecordType.rtIndividual)
                {
                    continue;
                }

                GDMIndividualRecord ind = (GDMIndividualRecord)rec;
                stats.persons++;

                switch (ind.Sex)
                {
                case GDMSex.svFemale:
                    stats.persons_f++;
                    if (ind.IsLive())
                    {
                        stats.lives_f++;
                        stats.lives++;
                    }
                    break;

                case GDMSex.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);
        }
コード例 #2
0
ファイル: TreeVizControl.cs プロジェクト: subratb/GEDKeeper
        private void PrepareDescendants(TVPerson person)
        {
            if (person == null)
            {
                return;
            }

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

                GDMIndividualRecord iRec = person.IRec;

                foreach (GDMSpouseToFamilyLink spLink in iRec.SpouseToFamilyLinks)
                {
                    GDMFamilyRecord famRec = spLink.Family;

                    bool alreadyPrepared = false;

                    // processing the spouse of the current person
                    GDMIndividualRecord 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 (GDMIndividualLink childPtr in famRec.Children)
                        {
                            GDMIndividualRecord child = childPtr.Individual;

                            // 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);
            }
        }
コード例 #3
0
        private void GetSimplePersonStat(StatsMode mode, List <StatsItem> values, GDMIndividualRecord 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, GEDCOMTagName.BIRT);
                break;

            case StatsMode.smDeathYears:
            case StatsMode.smDeathTenYears:
            case StatsMode.smDeathPlaces:
                GetEventField(mode, values, iRec, GEDCOMTagName.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, GEDCOMTagName.OCCU));
                break;

            case StatsMode.smReligious:
                CheckVal(values, GKUtils.GetAttributeValue(iRec, GEDCOMTagName.RELI));
                break;

            case StatsMode.smNational:
                CheckVal(values, GKUtils.GetAttributeValue(iRec, GEDCOMTagName.NATI));
                break;

            case StatsMode.smEducation:
                CheckVal(values, GKUtils.GetAttributeValue(iRec, GEDCOMTagName.EDUC));
                break;

            case StatsMode.smCaste:
                CheckVal(values, GKUtils.GetAttributeValue(iRec, GEDCOMTagName.CAST));
                break;

            case StatsMode.smHobby:
                CheckVal(values, GKUtils.GetAttributeValue(iRec, GEDCOMTagName._HOBBY));
                break;

            case StatsMode.smAward:
                CheckVal(values, GKUtils.GetAttributeValue(iRec, GEDCOMTagName._AWARD));
                break;

            case StatsMode.smMili:
                CheckVal(values, GKUtils.GetAttributeValue(iRec, GEDCOMTagName._MILI));
                break;

            case StatsMode.smMiliInd:
                CheckVal(values, GKUtils.GetAttributeValue(iRec, GEDCOMTagName._MILI_IND));
                break;

            case StatsMode.smMiliDis:
                CheckVal(values, GKUtils.GetAttributeValue(iRec, GEDCOMTagName._MILI_DIS));
                break;

            case StatsMode.smMiliRank:
                CheckVal(values, GKUtils.GetAttributeValue(iRec, GEDCOMTagName._MILI_RANK));
                break;

            case StatsMode.smCertaintyIndex:
                CheckVal(values, string.Format("{0:0.00}", iRec.GetCertaintyAssessment()));
                break;

            case StatsMode.smBirthByMonth:
                GDMCustomEvent ev = iRec.FindEvent(GEDCOMTagType.BIRT);
                if (ev != null)
                {
                    var dtx = ev.Date.Value as GDMDate;
                    if (dtx != null && dtx.Month > 0)
                    {
                        CheckVal(values, dtx.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;
            }
            }
        }