Exemple #1
0
        public void Test_GEDCOMEventToDateStr()
        {
            GDMIndividualRecord iRec = fContext.Tree.XRefIndex_Find("I1") as GDMIndividualRecord;

            GDMCustomEvent evt = iRec.FindEvent(GEDCOMTagType.BIRT);

            Assert.IsNotNull(evt);

            string st2 = GKUtils.GEDCOMEventToDateStr(null, DateFormat.dfYYYY_MM_DD, false);

            Assert.AreEqual("", st2);

            st2 = GKUtils.GEDCOMEventToDateStr(evt, DateFormat.dfYYYY_MM_DD, false);
            Assert.AreEqual("1990.12.28", st2);

            evt.Cause = "test cause";
            st2       = GKUtils.GetEventCause(evt);
            Assert.AreEqual("test cause", st2);

            string ds = GKUtils.GEDCOMEventToDateStr(evt, DateFormat.dfDD_MM_YYYY, false);

            Assert.AreEqual("28.12.1990", ds);

            ds = GKUtils.GEDCOMEventToDateStr(evt, DateFormat.dfYYYY_MM_DD, false);
            Assert.AreEqual("1990.12.28", ds);

            ds = GKUtils.GEDCOMEventToDateStr(evt, DateFormat.dfYYYY, false);
            Assert.AreEqual("1990", ds);

            ds = GKUtils.GEDCOMEventToDateStr(null, DateFormat.dfYYYY, false);
            Assert.AreEqual("", ds);
        }
Exemple #2
0
        public object gt_get_person_event_ex(object recPtr, string sign)
        {
            GDMIndividualRecord iRec = recPtr as GDMIndividualRecord;

            if (iRec == null)
            {
                return(null);
            }

            GDMCustomEvent evt = iRec.FindEvent(sign);

            return(evt);
        }
Exemple #3
0
        public void Test_FamilyTreeMaker_2008()
        {
            // actually need to find the real signature of version for FTM 2008 (wrong in the file)
            using (var ctx = TestUtils.LoadResourceGEDCOMFile("test_ftm2008.ged")) {
                Assert.AreEqual(GEDCOMFormat.gf_FamilyTreeMaker, ctx.Tree.Format);

                GEDCOMChecker.CheckGEDCOMFormat(ctx.Tree, ctx, new ProgressStub());

                GDMIndividualRecord iRec1 = ctx.Tree.XRefIndex_Find("I1") as GDMIndividualRecord;
                Assert.IsNotNull(iRec1);
                Assert.AreEqual("John Smith", iRec1.GetPrimaryFullName());

                // test of conversion
                var occuEvent = iRec1.FindEvent(GEDCOMTagType.OCCU);
                Assert.IsNotNull(occuEvent);
                Assert.AreEqual("test occupation", occuEvent.StringValue);
            }
        }
Exemple #4
0
        private void GetEventField(StatsMode mode, List <StatsItem> values, GDMIndividualRecord iRec, string evtName)
        {
            string         v   = "?";
            GDMCustomEvent 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:
                if (evt.HasPlace)
                {
                    v = evt.Place.StringValue;
                }
                break;
            }

            CheckVal(values, v);
        }
        protected override void LoadFromReader(Stream fileStream, StreamReader reader, string streamCharset = null)
        {
            fTree.State = GDMTreeState.osLoading;
            try {
                ProgressEventHandler progressHandler = fTree.OnProgress;

                long fileSize = fileStream.Length;
                int  progress = 0;

                GDMIndividualRecord lastIndividual = null;
                FXTag            lastTagType       = FXTag.Unknown;
                RelationshipType relationshipType  = RelationshipType.None;
                var families   = new List <FamilyRec>();
                var children   = new List <ChildRec>();
                var indiIdents = new Dictionary <string, GDMIndividualRecord>();

                XmlReaderSettings settings = new XmlReaderSettings();
                settings.DtdProcessing = DtdProcessing.Ignore;
                using (XmlReader xr = XmlReader.Create(fileStream, settings)) {
                    while (xr.Read())
                    {
                        if (xr.NodeType == XmlNodeType.Element && !xr.IsEmptyElement)
                        {
                            string nodeType = xr.Name;
                            if (nodeType == "Person")
                            {
                                lastIndividual = fTree.CreateIndividual();
                                var persName = new GDMPersonalName();
                                lastIndividual.AddPersonalName(persName);

                                // add an empty birth event
                                AddEvent(lastIndividual, GEDCOMTagName.BIRT);

                                lastIndividual.UID = xr.GetAttribute("Id");
                                indiIdents.Add(lastIndividual.UID, lastIndividual);
                            }
                            else if (nodeType == "Gender")
                            {
                                lastTagType = FXTag.Gender;
                            }
                            else if (nodeType == "Restriction")
                            {
                                lastTagType = FXTag.Restriction;
                            }
                            else if (nodeType == "FirstName")
                            {
                                lastTagType = FXTag.FirstName;
                            }
                            else if (nodeType == "LastName")
                            {
                                lastTagType = FXTag.LastName;
                            }
                            else if (nodeType == "Suffix")
                            {
                                lastTagType = FXTag.Suffix;
                            }
                            else if (nodeType == "IsLiving")
                            {
                                lastTagType = FXTag.IsLiving;
                            }
                            else if (nodeType == "Note")
                            {
                                lastTagType = FXTag.Note;
                            }
                            else if (nodeType == "BirthDate")
                            {
                                lastTagType = FXTag.BirthDate;
                            }
                            else if (nodeType == "BirthPlace")
                            {
                                lastTagType = FXTag.BirthPlace;
                            }
                            else if (nodeType == "DeathDate")
                            {
                                lastTagType = FXTag.DeathDate;
                            }
                            else if (nodeType == "DeathPlace")
                            {
                                lastTagType = FXTag.DeathPlace;
                            }
                            else if (nodeType == "RelationshipType")
                            {
                                lastTagType = FXTag.Relationship;
                            }
                            else if (nodeType == "PersonId")
                            {
                                switch (relationshipType)
                                {
                                case RelationshipType.Spouse:
                                    lastTagType = FXTag.SpouseLink;
                                    break;

                                case RelationshipType.Child:
                                    lastTagType = FXTag.ChildLink;
                                    break;

                                default:
                                    lastTagType = FXTag.Unknown;
                                    break;
                                }
                                relationshipType = RelationshipType.None;
                            }
                        }
                        else if (xr.NodeType == XmlNodeType.Text)
                        {
                            string nodeValue = xr.Value;
                            if (!string.IsNullOrEmpty(nodeValue))
                            {
                                switch (lastTagType)
                                {
                                case FXTag.Gender:
                                    if (nodeValue == "Male")
                                    {
                                        lastIndividual.Sex = GDMSex.svMale;
                                    }
                                    else if (nodeValue == "Female")
                                    {
                                        lastIndividual.Sex = GDMSex.svFemale;
                                    }
                                    break;

                                case FXTag.Restriction:
                                    // FIXME: parse from nodeValue
                                    lastIndividual.Restriction = GDMRestriction.rnNone;
                                    break;

                                case FXTag.FirstName:
                                    lastIndividual.PersonalNames[0].FirstPart = nodeValue;
                                    break;

                                case FXTag.LastName:
                                    lastIndividual.PersonalNames[0].Surname = nodeValue;
                                    break;

                                case FXTag.Suffix:
                                    lastIndividual.PersonalNames[0].LastPart = nodeValue;
                                    break;

                                case FXTag.IsLiving:
                                    bool isLiving = string.Equals(nodeValue, "true", StringComparison.InvariantCultureIgnoreCase);
                                    if (!isLiving)
                                    {
                                        AddEvent(lastIndividual, GEDCOMTagName.DEAT);
                                    }
                                    break;

                                case FXTag.BirthDate:
                                case FXTag.BirthPlace:
                                    var birthEvent = lastIndividual.FindEvent("BIRT");
                                    if (lastTagType == FXTag.BirthDate)
                                    {
                                        SetEventDate(birthEvent, nodeValue);
                                    }
                                    else
                                    {
                                        birthEvent.Place.StringValue = nodeValue;
                                    }
                                    break;

                                case FXTag.DeathDate:
                                case FXTag.DeathPlace:
                                    var deathEvent = lastIndividual.FindEvent("DEAT");
                                    // IsLiving may be wrong
                                    if (deathEvent == null)
                                    {
                                        deathEvent = AddEvent(lastIndividual, GEDCOMTagName.DEAT);
                                    }
                                    if (lastTagType == FXTag.DeathDate)
                                    {
                                        SetEventDate(deathEvent, nodeValue);
                                    }
                                    else
                                    {
                                        deathEvent.Place.StringValue = nodeValue;
                                    }
                                    break;

                                case FXTag.Note:
                                    AddNote(lastIndividual, nodeValue);
                                    break;

                                case FXTag.Relationship:
                                    if (nodeValue == "Spouse")
                                    {
                                        relationshipType = RelationshipType.Spouse;
                                    }
                                    else if (nodeValue == "Child")
                                    {
                                        relationshipType = RelationshipType.Child;
                                    }
                                    break;

                                case FXTag.SpouseLink:
                                    ProcessSpouse(families, lastIndividual, nodeValue);
                                    break;

                                case FXTag.ChildLink:
                                    ProcessChild(children, lastIndividual, nodeValue);
                                    break;
                                }
                                lastTagType = FXTag.Unknown;
                            }
                        }

                        if (progressHandler != null)
                        {
                            int newProgress = (int)Math.Min(100, (fileStream.Position * 100.0f) / fileSize);
                            if (progress != newProgress)
                            {
                                progress = newProgress;
                                progressHandler(fTree, progress);
                            }
                        }
                    }
                }

                foreach (var fam in families)
                {
                    GDMIndividualRecord husbRec;
                    indiIdents.TryGetValue(fam.HusbandId, out husbRec);

                    GDMIndividualRecord wifeRec;
                    indiIdents.TryGetValue(fam.WifeId, out wifeRec);

                    GDMFamilyRecord famRec = fTree.CreateFamily();
                    famRec.AddSpouse(husbRec);
                    famRec.AddSpouse(wifeRec);
                }

                foreach (var child in children)
                {
                    GDMIndividualRecord fathRec;
                    indiIdents.TryGetValue(child.FatherId, out fathRec);

                    GDMIndividualRecord mothRec;
                    indiIdents.TryGetValue(child.MotherId, out mothRec);

                    GDMIndividualRecord childRec;
                    indiIdents.TryGetValue(child.ChildId, out childRec);

                    GDMFamilyRecord famRec = GetParentsFamily(fathRec, mothRec);
                    famRec.AddChild(childRec);
                }
            } finally {
                fTree.State = GDMTreeState.osReady;
            }
        }
Exemple #6
0
        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>();

            GDMIndividualRecord father = null, mother = null;

            if (fPerson.ChildToFamilyLinks.Count > 0)
            {
                GDMFamilyRecord family = fPerson.ChildToFamilyLinks[0].Family;
                if (fBase.Context.IsRecordAccess(family.Restriction))
                {
                    father = family.Husband.Individual;
                    mother = family.Wife.Individual;
                }
            }

            ExtractEvents(EventType.Personal, evList, fPerson);

            int num2 = fPerson.SpouseToFamilyLinks.Count;

            for (int j = 0; j < num2; j++)
            {
                GDMFamilyRecord 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++)
                {
                    GDMIndividualRecord child = family.Children[i].Individual;
                    GDMCustomEvent      evt   = child.FindEvent(GEDCOMTagType.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;
                }

                GDMCustomEvent evt = evObj.Event;
                string         st  = GKUtils.GetEventName(evt);
                string         dt  = GKUtils.GEDCOMEventToDateStr(evt, GlobalOptions.Instance.DefDateFormat, 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 GDMIndividualRecord)
                {
                    GDMIndividualRecord iRec = evObj.Rec as GDMIndividualRecord;

                    if (evt.GetTagType() == GEDCOMTagType.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 == GDMSex.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 GDMFamilyRecord)
                {
                    GDMFamilyRecord famRec = evObj.Rec as GDMFamilyRecord;

                    GDMIndividualRecord sp;
                    string unk;
                    if (fPerson.Sex == GDMSex.svMale)
                    {
                        sp  = famRec.Wife.Individual;
                        st  = LangMan.LS(LSID.LSID_Wife) + ": ";
                        unk = LangMan.LS(LSID.LSID_UnkFemale);
                    }
                    else
                    {
                        sp  = famRec.Husband.Individual;
                        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();
        }
Exemple #7
0
        public static void FillContext(IBaseContext context)
        {
            // a null result if the record is not defined
            GDMCustomEvent evt = context.CreateEventEx(null, GEDCOMTagName.BIRT, "xxxxx", "xxxxx");

            Assert.IsNull(evt);

            // first individual (I1)
            GDMIndividualRecord iRec = context.CreatePersonEx("Ivan", "Ivanovich", "Ivanov", GDMSex.svMale, true);

            Assert.IsNotNull(iRec);

            evt = iRec.FindEvent(GEDCOMTagType.BIRT);
            Assert.IsNotNull(evt);
            evt.Date.ParseString("28 DEC 1990");
            evt.Place.StringValue = "Ivanovo";

            GDMCustomEvent evtd = context.CreateEventEx(iRec, GEDCOMTagName.DEAT, "28 DEC 2010", "Ivanovo");

            Assert.IsNotNull(evtd);

            // second individual, wife (I2)
            GDMIndividualRecord iRec2 = context.CreatePersonEx("Maria", "Petrovna", "Ivanova", GDMSex.svFemale, true);

            evt = iRec2.FindEvent(GEDCOMTagType.BIRT);
            Assert.IsNotNull(evt);
            evt.Date.ParseString("17 MAR 1991");
            evt.Place.StringValue = "Ivanovo";

            iRec.AddAssociation("spouse", iRec2);

            // third individual, child (I3)
            GDMIndividualRecord iRec3 = context.CreatePersonEx("Anna", "Ivanovna", "Ivanova", GDMSex.svFemale, true);

            evt = iRec3.FindEvent(GEDCOMTagType.BIRT);
            Assert.IsNotNull(evt);
            evt.Date.ParseString("11 FEB 2010");
            evt.Place.StringValue = "Ivanovo";

            // their family
            GDMFamilyRecord famRec = context.Tree.CreateFamily();

            Assert.IsNotNull(famRec);
            famRec.AddSpouse(iRec);
            famRec.AddSpouse(iRec2);
            famRec.AddChild(iRec3);

            context.CreateEventEx(famRec, GEDCOMTagName.MARR, "01 JAN 2000", "unknown");

            // individual outside the family (I4)
            GDMIndividualRecord iRec4 = context.CreatePersonEx("Alex", "", "Petrov", GDMSex.svMale, true);

            evt = iRec4.FindEvent(GEDCOMTagType.BIRT);
            Assert.IsNotNull(evt);
            evt.Date.ParseString("15 JUN 1989");
            evt.Place.StringValue = "Far Forest";

            evt = context.CreateEventEx(iRec4, GEDCOMTagName.RESI, "12 FEB", "Far Forest");
            Assert.IsNotNull(evt);

            // fifth (I5)
            GDMIndividualRecord iRec5 = context.CreatePersonEx("Anna", "", "Jones", GDMSex.svFemale, false);

            Assert.IsNotNull(iRec5);

            // sixth (I6)
            GDMIndividualRecord iRec6 = context.CreatePersonEx("Mary", "", "Jones", GDMSex.svFemale, false);

            Assert.IsNotNull(iRec6);
            evt = context.CreateEventEx(iRec6, GEDCOMTagName.BIRT, "12 FEB 1650", "Far Forest");

            GDMFamilyRecord famRec2 = context.Tree.CreateFamily();

            Assert.IsNotNull(famRec2);
            famRec2.AddSpouse(iRec3);
            //famRec2.AddSpouse(iRec4);
            famRec2.AddChild(iRec5);
            famRec2.AddChild(iRec6);

            // group for tests
            GDMGroupRecord groupRec = context.Tree.CreateGroup();

            groupRec.GroupName = "GroupTest";
            Assert.IsNotNull(groupRec, "group1 != null");
            groupRec.AddMember(iRec);

            // location for tests
            GDMLocationRecord locRec = context.Tree.CreateLocation();

            locRec.LocationName = "Test Location";
            locRec.Map.Lati     = 5.11111;
            locRec.Map.Long     = 7.99999;
            Assert.IsNotNull(locRec, "locRec != null");

            // repository for tests
            GDMRepositoryRecord repoRec = context.Tree.CreateRepository();

            repoRec.RepositoryName = "Test repository";
            Assert.IsNotNull(repoRec, "repoRec != null");

            // research for tests
            GDMResearchRecord resRec = context.Tree.CreateResearch();

            resRec.ResearchName = "Test research";
            Assert.IsNotNull(resRec, "resRec != null");

            // source for tests
            GDMSourceRecord srcRec = context.Tree.CreateSource();

            srcRec.ShortTitle = "Test source";
            Assert.IsNotNull(srcRec, "srcRec != null");
            iRec.AddSource(srcRec, "p1", 0);

            // note for tests
            GDMNoteRecord noteRec = context.Tree.CreateNote();

            noteRec.SetNoteText("Test note");
            Assert.IsNotNull(noteRec, "noteRec != null");
            iRec.AddNote(noteRec);

            // task for tests
            GDMTaskRecord tskRec = context.Tree.CreateTask();

            tskRec.Goal = "Test task";
            Assert.IsNotNull(tskRec, "tskRec != null");

            // media for tests
            GDMMultimediaRecord mediaRec = context.Tree.CreateMultimedia();

            mediaRec.FileReferences.Add(new GDMFileReferenceWithTitle());
            GDMFileReferenceWithTitle fileRef = mediaRec.FileReferences[0];

            fileRef.Title = "Test multimedia";
            fileRef.LinkFile("sample.png");
            Assert.IsNotNull(mediaRec, "mediaRec != null");
            iRec.AddMultimedia(mediaRec);

            // communication for tests
            GDMCommunicationRecord commRec = context.Tree.CreateCommunication();

            commRec.CommName = "Test communication";
            Assert.IsNotNull(commRec, "commRec != null");
        }
Exemple #8
0
        private void WriteExcessFmt(PedigreePerson person)
        {
            fWriter.AddParagraph(LangMan.LS(LSID.LSID_Sex) + ": " + GKUtils.SexStr(person.IRec.Sex), fTextFont);

            string st = GKUtils.GetLifeExpectancyStr(person.IRec);

            if (st != "?" && st != "")
            {
                fWriter.AddParagraph(LangMan.LS(LSID.LSID_LifeExpectancy) + ": " + st, fTextFont);
            }

            GDMIndividualRecord father, mother;

            fTree.GetParents(person.IRec, out father, out mother);

            if (father != null)
            {
                fWriter.AddParagraphLink(LangMan.LS(LSID.LSID_Father) + ": " + GKUtils.GetNameString(father, true, false) + " ", fTextFont, idLink(father), fLinkFont);
            }

            if (mother != null)
            {
                fWriter.AddParagraphLink(LangMan.LS(LSID.LSID_Mother) + ": " + GKUtils.GetNameString(mother, true, false) + " ", fTextFont, idLink(mother), fLinkFont);
            }

            var evList = new ExtList <PedigreeEvent>(true);

            try {
                int i;
                if (person.IRec.Events.Count > 0)
                {
                    fWriter.AddParagraph(LangMan.LS(LSID.LSID_Events) + ":", fTextFont);

                    int num = person.IRec.Events.Count;
                    for (i = 0; i < num; i++)
                    {
                        GDMCustomEvent evt = person.IRec.Events[i];
                        if (!(evt is GDMIndividualAttribute) || fOptions.PedigreeOptions.IncludeAttributes)
                        {
                            evList.Add(new PedigreeEvent(person.IRec, evt));
                        }
                    }
                    WriteEventList(person, evList);
                }

                int num2 = person.IRec.SpouseToFamilyLinks.Count;
                for (i = 0; i < num2; i++)
                {
                    GDMFamilyRecord family = fTree.GetPtrValue(person.IRec.SpouseToFamilyLinks[i]);
                    if (!fBase.Context.IsRecordAccess(family.Restriction))
                    {
                        continue;
                    }

                    GDMIndividualRecord spRec;
                    string unk;
                    if (person.IRec.Sex == GDMSex.svMale)
                    {
                        spRec = fTree.GetPtrValue(family.Wife);
                        st    = LangMan.LS(LSID.LSID_Wife) + ": ";
                        unk   = LangMan.LS(LSID.LSID_UnkFemale);
                    }
                    else
                    {
                        spRec = fTree.GetPtrValue(family.Husband);
                        st    = LangMan.LS(LSID.LSID_Husband) + ": ";
                        unk   = LangMan.LS(LSID.LSID_UnkMale);
                    }

                    string sps;
                    if (spRec != null)
                    {
                        sps = st + GKUtils.GetNameString(spRec, true, false) + GKUtils.GetPedigreeLifeStr(spRec, fOptions.PedigreeOptions.Format) /* + this.idLink(this.FindPerson(irec))*/;
                    }
                    else
                    {
                        sps = st + unk;
                    }

                    fWriter.AddParagraph(sps, fTextFont);

                    evList.Clear();
                    int childrenCount = family.Children.Count;
                    for (int j = 0; j < childrenCount; j++)
                    {
                        GDMIndividualRecord child = fTree.GetPtrValue(family.Children[j]);
                        evList.Add(new PedigreeEvent(child, child.FindEvent(GEDCOMTagType.BIRT)));
                    }
                    WriteEventList(person, evList);
                }
            } finally {
                evList.Dispose();
            }

            if (fOptions.PedigreeOptions.IncludeNotes && person.IRec.Notes.Count != 0)
            {
                fWriter.AddParagraph(LangMan.LS(LSID.LSID_RPNotes) + ":", fTextFont);

                fWriter.BeginList();

                int notesCount = person.IRec.Notes.Count;
                for (int i = 0; i < notesCount; i++)
                {
                    GDMLines noteLines = fTree.GetNoteLines(person.IRec.Notes[i]);
                    fWriter.AddListItem(" " + GKUtils.MergeStrings(noteLines), fTextFont);
                }

                fWriter.EndList();
            }
        }
Exemple #9
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(fTree, iRec) - 1));
                break;

            case StatsMode.smDescendants:
                values.Add(new StatsItem(iName, GKUtils.GetDescendantsCount(fTree, iRec) - 1));
                break;

            case StatsMode.smDescGenerations:
                values.Add(new StatsItem(iName, GKUtils.GetDescGenerations(fTree, iRec)));
                break;

            case StatsMode.smChildsCount:
                values.Add(new StatsItem(iName, fTree.GetTotalChildrenCount(iRec)));
                break;

            case StatsMode.smFirstbornAge:
                values.Add(new StatsItem(iName, GKUtils.GetFirstbornAge(iRec, GKUtils.GetFirstborn(fTree, iRec))));
                break;

            case StatsMode.smMarriages:
                values.Add(new StatsItem(iName, GKUtils.GetMarriagesCount(iRec)));
                break;

            case StatsMode.smMarriageAge:
                values.Add(new StatsItem(iName, GKUtils.GetMarriageAge(fTree, 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, fTree.GetTotalChildrenCount(iRec).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;
            }
            }
        }