コード例 #1
0
        private Range <int> GetIndividualDates(GEDCOMIndividualRecord iRec)
        {
            var dates = iRec.GetLifeDates();

            int yBirth = (dates.BirthEvent == null) ? 0 : dates.BirthEvent.GetChronologicalYear();
            int yDeath = (dates.DeathEvent == null) ? 0 : dates.DeathEvent.GetChronologicalYear();

            int provedLife = (iRec.Sex == GEDCOMSex.svMale) ? (int)fStats.life.MaleVal : (int)fStats.life.FemaleVal;

            if ((yBirth != 0) && (yDeath == 0))
            {
                yDeath = yBirth + provedLife; //GKData.PROVED_LIFE_LENGTH;
            }

            if ((yBirth == 0) && (yDeath != 0))
            {
                yBirth = yDeath - provedLife; //GKData.PROVED_LIFE_LENGTH;
            }

            var range = new Range <int>(yBirth, yDeath);

            return(range);
        }
コード例 #2
0
        public void BuildBy(GEDCOMIndividualRecord iRec)
        {
            try
            {
                fRec = iRec;

                if (iRec != null)
                {
                    if (fModel.PreparedIndividuals.IndexOf(iRec.XRef) < 0)
                    {
                        fModel.PreparedIndividuals.Add(iRec.XRef);
                    }

                    var parts = GKUtils.GetNameParts(iRec);
                    fSurname    = parts.Surname;
                    fName       = parts.Name;
                    fPatronymic = parts.Patronymic;
                    fNick       = GKUtils.GetNickString(iRec);
                    fSex        = iRec.Sex;

                    TreeChartOptions options = fModel.Options;

                    var        lifeDates  = iRec.GetLifeDates();
                    DateFormat dateFormat = (options.OnlyYears) ? DateFormat.dfYYYY : DateFormat.dfDD_MM_YYYY;

                    IsDead     = (lifeDates.DeathEvent != null);
                    fBirthDate = GKUtils.GEDCOMEventToDateStr(lifeDates.BirthEvent, dateFormat, false);
                    fDeathDate = GKUtils.GEDCOMEventToDateStr(lifeDates.DeathEvent, dateFormat, false);

                    if (options.SignsVisible)
                    {
                        EnumSet <SpecialUserRef> signs = EnumSet <SpecialUserRef> .Create();

                        int num = fRec.UserReferences.Count;
                        for (int i = 0; i < num; i++)
                        {
                            string rs = fRec.UserReferences[i].StringValue;

                            for (var cps = SpecialUserRef.urRI_StGeorgeCross; cps <= SpecialUserRef.urLast; cps++)
                            {
                                string sur = LangMan.LS(GKData.SpecialUserRefs[(int)cps].Title);
                                if (rs == sur)
                                {
                                    signs.Include(cps);
                                }
                            }
                        }

                        fSigns = signs;
                    }
                    else
                    {
                        fSigns = EnumSet <SpecialUserRef> .Create();
                    }

                    if (options.PortraitsVisible)
                    {
                        try
                        {
                            fPortrait = PortraitsCache.Instance.GetImage(fModel.Base.Context, iRec);

                            if (fPortrait == null && options.DefaultPortraits)
                            {
                                string resName = (fSex == GEDCOMSex.svFemale) ? "pi_female_140.png" : "pi_male_140.png";
                                fPortrait = AppHost.GfxProvider.GetResourceImage(resName, false);
                            }
                        }
                        catch (MediaFileNotFoundException)
                        {
                            if (!fModel.HasMediaFail)
                            {
                                AppHost.StdDialogs.ShowError(LangMan.LS(LSID.LSID_ArcNotFound));
                                fModel.HasMediaFail = true;
                            }
                        }
                    }

                    CertaintyAssessment = iRec.GetCertaintyAssessment();
                }
                else
                {
                    fSurname    = "";
                    fName       = "< ? >";
                    fPatronymic = "";
                    fNick       = "";
                    fBirthDate  = "";
                    fDeathDate  = "";
                    IsDead      = false;
                    fSex        = GEDCOMSex.svNone;
                    fSigns      = EnumSet <SpecialUserRef> .Create();

                    CertaintyAssessment = 0.0f;
                }
            }
            catch (Exception ex)
            {
                Logger.LogWrite("TreeChartPerson.BuildBy(): " + ex.Message);
                throw;
            }
        }