예제 #1
0
        public static string GetLifeDatesStr(this GDMIndividualRecord record)
        {
            var lifeDates = record.GetLifeDates();
            //TODO
            //TreeChartOptions options = GlobalOptions.Instance.ChartOptions;
            //DateFormat dateFormat = (options.OnlyYears) ? DateFormat.dfYYYY : DateFormat.dfDD_MM_YYYY;
            DateFormat dateFormat = DateFormat.dfYYYY;

            string birthDate = GKUtils.GEDCOMEventToDateStr(lifeDates.BirthEvent, dateFormat, false);
            string deathDate = GKUtils.GEDCOMEventToDateStr(lifeDates.DeathEvent, dateFormat, false);

            return(birthDate + " - " + deathDate);
        }
예제 #2
0
        private Range <int> GetIndividualDates(GDMIndividualRecord 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 == GDMSex.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);
        }
예제 #3
0
        public void BuildBy(GDMIndividualRecord iRec)
        {
            try {
                fRec = iRec;

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

                    var parts = GKUtils.GetNameParts(fModel.Base.Context.Tree, 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.OnlyYears)
                    {
                        if (options.ShowPlaces)
                        {
                            fBirthPlace = GKUtils.GetPlaceStr(lifeDates.BirthEvent, false);
                            if (!string.IsNullOrEmpty(fBirthPlace) && !options.SeparateDatesAndPlacesLines)
                            {
                                if (!string.IsNullOrEmpty(fBirthDate))
                                {
                                    fBirthDate += ", ";
                                }
                                fBirthDate += fBirthPlace;
                            }

                            fDeathPlace = GKUtils.GetPlaceStr(lifeDates.DeathEvent, false);
                            if (!string.IsNullOrEmpty(fDeathPlace) && !options.SeparateDatesAndPlacesLines)
                            {
                                if (!string.IsNullOrEmpty(fDeathDate))
                                {
                                    fDeathDate += ", ";
                                }
                                fDeathDate += fDeathPlace;
                            }
                        }

                        if (!string.IsNullOrEmpty(fBirthDate))
                        {
                            fBirthDate = ImportUtils.STD_BIRTH_SIGN + " " + fBirthDate;
                        }
                        if (!string.IsNullOrEmpty(fDeathDate))
                        {
                            fDeathDate = ImportUtils.STD_DEATH_SIGN + " " + fDeathDate;
                        }
                    }

                    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 == GDMSex.svFemale) ? "pi_female_140.png" : "pi_male_140.png";
                                fPortrait = AppHost.GfxProvider.LoadResourceImage(resName, false);
                            }
                        } catch (MediaFileNotFoundException) {
                            if (!fModel.HasMediaFail)
                            {
                                AppHost.StdDialogs.ShowError(LangMan.LS(LSID.LSID_MediaFileNotLoaded));
                                fModel.HasMediaFail = true;
                            }
                        }
                    }

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

                    CertaintyAssessment = 0.0f;
                }
            } catch (Exception ex) {
                Logger.WriteError("TreeChartPerson.BuildBy()", ex);
                throw;
            }
        }