private void ExtractEvents(EventType type, List <PersonalEvent> list, IGEDCOMRecordWithEvents record)
        {
            int num = record.Events.Count;

            for (int i = 0; i < num; i++)
            {
                GEDCOMCustomEvent evt = record.Events[i];
                if (evt.GetChronologicalYear() != 0)
                {
                    list.Add(new PersonalEvent(type, (GEDCOMRecord)record, evt));
                }
            }
        }
        private static void PrepareEventYear(StringList index, GEDCOMCustomEvent evt, GEDCOMIndividualRecord iRec)
        {
            if (evt == null)
            {
                return;
            }

            int dtY = evt.GetChronologicalYear();

            if (dtY != 0)
            {
                PrepareSpecIndex(index, dtY.ToString(), iRec);
            }
        }
Exemple #3
0
        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);
        }
        private void CollectData()
        {
            int num = fBase.Context.Tree.RecordsCount;

            for (int i = 0; i < num; i++)
            {
                GEDCOMRecord rec = fBase.Context.Tree[i];
                if (rec.RecordType != GEDCOMRecordType.rtIndividual)
                {
                    continue;
                }

                GEDCOMIndividualRecord iRec = (GEDCOMIndividualRecord)rec;

                int num2 = iRec.Events.Count;
                for (int k = 0; k < num2; k++)
                {
                    GEDCOMCustomEvent ev = iRec.Events[k];

                    if (ev.Name == "BIRT" || ev.Name == "DEAT")
                    {
                        int year = ev.GetChronologicalYear();
                        if (year != 0)
                        {
                            if (fYearMin > year)
                            {
                                fYearMin = year;
                            }
                            if (fYearMax < year)
                            {
                                fYearMax = year;
                            }
                        }
                    }
                }
            }
        }
        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();
        }