Exemple #1
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);
            }
        }