Beispiel #1
0
        public void SetNameSex(string name, GDMSex sex)
        {
            if (string.IsNullOrEmpty(name))
            {
                return;
            }

            NameEntry nm = FindName(name);

            if (nm == null)
            {
                nm = AddName(name);
            }

            if (nm.Sex == GDMSex.svUnknown && (sex == GDMSex.svMale || sex == GDMSex.svFemale))
            {
                nm.Sex = sex;
            }
        }
Beispiel #2
0
        public override void Clear()
        {
            base.Clear();

            FilterGroupMode = FilterGroupMode.All;
            GroupRef        = "";
            if (FilterLifeMode != FilterLifeMode.lmTimeLocked)
            {
                FilterLifeMode = FilterLifeMode.lmAll;
            }
            Name            = "*";
            AliveBeforeDate = "";
            PatriarchOnly   = false;
            Residence       = "*";
            Sex             = GDMSex.svUnknown;
            SourceMode      = FilterGroupMode.All;
            SourceRef       = "";
            EventVal        = "*";
        }
Beispiel #3
0
        private GDMFamilyRecord GetFamilyByNum(GDMIndividualRecord parent, int marrNum)
        {
            // it's source of ERRORS! but without this - bad! (AddSpouse() not linking parent to family)
            GDMSex sex = parent.Sex;

            if (sex == GDMSex.svUnknown || sex == GDMSex.svIntersex)
            {
                parent.Sex = GDMSex.svMale;
            }

            while (parent.SpouseToFamilyLinks.Count < marrNum)
            {
                GDMFamilyRecord fam = fTree.CreateFamily();
                fam.AddSpouse(parent);
            }

            GDMFamilyRecord family = fTree.GetPtrValue(parent.SpouseToFamilyLinks[marrNum - 1]);

            return(family);
        }
Beispiel #4
0
        public override void Assign(GDMTag source)
        {
            GDMIndividualRecord sourceRec = source as GDMIndividualRecord;

            if (sourceRec == null)
            {
                throw new ArgumentException(@"Argument is null or wrong type", "source");
            }

            base.Assign(source);

            fSex = sourceRec.fSex;

            foreach (GDMPersonalName srcName in sourceRec.fPersonalNames)
            {
                GDMPersonalName copyName = new GDMPersonalName(this);
                copyName.Assign(srcName);
                AddPersonalName(copyName);
            }
        }
Beispiel #5
0
        private static void CheckVal(List <StatsItem> valsList, string val, GDMSex sex = GDMSex.svUnknown)
        {
            if (sex == GDMSex.svUnknown)
            {
                if (val == "-1" || val == "" || val == "0")
                {
                    val = "?";
                }
            }

            int vIdx = valsList.FindIndex(delegate(StatsItem lv) { return(lv.Caption == val); });

            StatsItem lvi;

            if (vIdx == -1)
            {
                lvi = new StatsItem(val, sex != GDMSex.svUnknown);
                valsList.Add(lvi);
            }
            else
            {
                lvi = valsList[vIdx];
            }

            switch (sex)
            {
            case GDMSex.svFemale:
                lvi.ValF = lvi.ValF + 1;
                break;

            case GDMSex.svMale:
                lvi.ValM = lvi.ValM + 1;
                break;

            case GDMSex.svUnknown:
            case GDMSex.svIntersex:
                lvi.Value = lvi.Value + 1;
                break;
            }
        }
Beispiel #6
0
        public string GetPatronymicByName(string name, GDMSex sex)
        {
            string result = "";

            NameEntry nm = FindName(name);

            if (nm != null)
            {
                switch (sex)
                {
                case GDMSex.svMale:
                    result = nm.M_Patronymic;
                    break;

                case GDMSex.svFemale:
                    result = nm.F_Patronymic;
                    break;
                }
            }

            return(result);
        }
        public override void Clear()
        {
            base.Clear();

            fSex = GDMSex.svUnknown;

            for (int i = fChildToFamilyLinks.Count - 1; i >= 0; i--)
            {
                var family = fTree.GetPtrValue <GDMFamilyRecord>(fChildToFamilyLinks[i]);
                family.DeleteChild(this);
            }
            fChildToFamilyLinks.Clear();

            for (int i = fSpouseToFamilyLinks.Count - 1; i >= 0; i--)
            {
                var family = fTree.GetPtrValue <GDMFamilyRecord>(fSpouseToFamilyLinks[i]);
                family.RemoveSpouse(this);
            }
            fSpouseToFamilyLinks.Clear();

            if (fGroups != null)
            {
                for (int i = fGroups.Count - 1; i >= 0; i--)
                {
                    var group = fTree.GetPtrValue <GDMGroupRecord>(fGroups[i]);
                    group.RemoveMember(this);
                }
                fGroups.Clear();
            }

            if (fAssociations != null)
            {
                fAssociations.Clear();
            }

            fPersonalNames.Clear();
        }
Beispiel #8
0
        public void Test_RussianCulture()
        {
            GDMIndividualRecord iRec = fContext.Tree.XRefIndex_Find("I3") as GDMIndividualRecord;

            Assert.IsNotNull(iRec);

            ICulture rusCulture = new RussianCulture();

            Assert.IsNotNull(rusCulture);
            Assert.IsTrue(rusCulture.HasPatronymic());
            Assert.IsTrue(rusCulture.HasSurname());

            string[] surnames = rusCulture.GetSurnames(iRec);
            Assert.AreEqual(1, surnames.Length);
            Assert.AreEqual("Ivanova", surnames[0]);
            Assert.Throws(typeof(ArgumentNullException), () => { rusCulture.GetSurnames(null); });


            Assert.AreEqual("Иванов", rusCulture.NormalizeSurname("Иванова", true));
            Assert.AreEqual("Бельский", rusCulture.NormalizeSurname("Бельская", true));
            Assert.AreEqual("Грозный", rusCulture.NormalizeSurname("Грозная", true));
            Assert.AreEqual("Иванов", rusCulture.NormalizeSurname("Иванов", false));
            Assert.AreEqual("Бельский", rusCulture.NormalizeSurname("Бельский", false));
            Assert.AreEqual("Грозный", rusCulture.NormalizeSurname("Грозный", false));

            Assert.AreEqual("?", rusCulture.NormalizeSurname(null, false));
            Assert.AreEqual("?", rusCulture.NormalizeSurname("", false));
            Assert.AreEqual("?", rusCulture.NormalizeSurname("(Иванова)", false));

            Assert.AreEqual("Иванова", rusCulture.GetMarriedSurname("Иванов"));
            Assert.AreEqual("Бельская", rusCulture.GetMarriedSurname("Бельский"));
            Assert.AreEqual("Грозная", rusCulture.GetMarriedSurname("Грозный"));

            Assert.AreEqual("?", rusCulture.GetMarriedSurname(""));
            Assert.AreEqual("?", rusCulture.GetMarriedSurname(null));

            string[] snms = rusCulture.GetSurnames("Бельская (Иванова)", true);
            Assert.AreEqual(2, snms.Length);
            Assert.AreEqual("Бельский", snms[0]);
            Assert.AreEqual("Иванов", snms[1]);

            snms = rusCulture.GetSurnames("Бельская", true);
            Assert.AreEqual(1, snms.Length);
            Assert.AreEqual("Бельский", snms[0]);

            snms = rusCulture.GetSurnames("Бельский", false);
            Assert.AreEqual(1, snms.Length);
            Assert.AreEqual("Бельский", snms[0]);


            GDMSex sx = rusCulture.GetSex("Мария", "Петровна", false);

            Assert.AreEqual(GDMSex.svFemale, sx);

            sx = rusCulture.GetSex("Иван", "Петрович", false);
            Assert.AreEqual(GDMSex.svMale, sx);

            Assert.AreEqual(GDMSex.svUnknown, rusCulture.GetSex("", "", false));

            Assert.AreEqual("Иванова Ивана Ивановича", rusCulture.GetPossessiveName("Иванов Иван Иванович"));

            GDMIndividualRecord iRec2    = fContext.Tree.CreateIndividual();
            GDMPersonalName     persName = new GDMPersonalName();

            persName.SetNameParts("Иван Иванович", "Иванов", "");
            iRec2.PersonalNames.Add(persName);

            Assert.AreEqual("Иванова Ивана Ивановича", rusCulture.GetPossessiveName(iRec2));
        }
Beispiel #9
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;
            }
        }
Beispiel #10
0
 public static void SetCreateIndividualHandler(NUnitFormTest formTest, GDMSex needIndividualSex)
 {
     fNeedIndividualSex = needIndividualSex;
     RecordSelectDlgTests.SetCreateItemHandler(formTest, IndividualAdd_Mini_Handler);
 }
Beispiel #11
0
        private void BaseWin_Tests(IBaseWindow baseWin, string stage)
        {
            // Stage 5: calls to the different Editors
            for (GDMRecordType rt = GDMRecordType.rtIndividual; rt <= GDMRecordType.rtLocation; rt++)
            {
                Assert.IsNotNull(((BaseWinSDI)baseWin).GetHyperViewByType(rt), stage + ".1");

                baseWin.ShowRecordsTab(rt);

                ModalFormHandler = Dialog_Cancel_Handler;
                ClickToolStripButton("tbRecordAdd", fMainWin);

                ModalFormHandler = EditorDlg_btnAccept_Handler;
                ClickToolStripButton("tbRecordAdd", fMainWin);

                ModalFormHandler = Dialog_Cancel_Handler;
                ClickToolStripButton("tbRecordEdit", fMainWin);

                ModalFormHandler = EditorDlg_btnAccept_Handler;
                ClickToolStripButton("tbRecordEdit", fMainWin);

                IListManager listMan = baseWin.GetRecordsListManByType(rt);
                listMan.AddCondition((byte)PersonColumnType.ctPatriarch, ConditionKind.ck_Contains, "test"); // any first column

                ModalFormHandler = CommonFilterDlgTests.CommonFilterDlg_btnAccept_Handler;
                ClickToolStripButton("tbFilter", fMainWin);
                ModalFormHandler = CommonFilterDlgTests.CommonFilterDlg_btnReset_Handler;
                ClickToolStripButton("tbFilter", fMainWin);
            }

            Assert.IsTrue(baseWin.Context.IsUnknown(), stage + ".2");

            baseWin.ShowRecordsTab(GDMRecordType.rtIndividual);
            baseWin.SelectRecordByXRef("I1");

            GDMRecord record = ((BaseWinSDI)baseWin).GetSelectedRecordEx();

            Assert.IsNotNull(record, stage + ".4");

            StringList recordContent = baseWin.GetRecordContent(record);

            Assert.IsNotNull(recordContent, stage + ".4.1");

            Assert.IsTrue(baseWin.Context.IsAvailableRecord(record), stage + ".5");
            Assert.IsTrue(baseWin.RecordIsFiltered(record), stage + ".6");

            Assert.Throws(typeof(ArgumentNullException), () => { baseWin.ShowMedia(null, false); });
            Assert.Throws(typeof(ArgumentNullException), () => { baseWin.Context.SelectSpouseFor(null); });
            baseWin.NotifyRecord(null, RecordAction.raAdd);

            IList <ISearchResult> search = baseWin.FindAll("Maria");

            Assert.AreEqual(1, search.Count);

            Assert.AreEqual(null, baseWin.Context.GetChildFamily(null, false, null));
            Assert.AreEqual(null, baseWin.Context.AddChildForParent(null, GDMSex.svUnknown));
            Assert.Throws(typeof(ArgumentNullException), () => { baseWin.Context.AddFamilyForSpouse(null); });

            Assert.Throws(typeof(ArgumentNullException), () => { baseWin.Context.CollectTips(null); });
            baseWin.Context.CollectTips(new StringList());

            Assert.Throws(typeof(ArgumentNullException), () => { baseWin.Context.CheckPersonSex(null); });

            baseWin.NotifyRecord(null, RecordAction.raEdit);

            baseWin.ApplyFilter();

            // default lang for tests is English
            string patr = baseWin.Context.DefinePatronymic("Ivan", GDMSex.svMale, false);

            Assert.AreEqual("", patr);

            ModalFormHandler = SexCheckDlgTests.SexCheckDlgTests_AcceptM_Handler;
            GDMSex sex = baseWin.Context.DefineSex("Ivan", "Ivanovich");

            Assert.AreEqual(GDMSex.svMale, sex);
        }
Beispiel #12
0
 public void SetTarget(TargetMode mode, GDMIndividualRecord target, GDMSex needSex)
 {
     fController.SetTarget(mode, target, needSex);
 }
Beispiel #13
0
        public string gt_define_sex(string name, string patr)
        {
            GDMSex sx = fBase.Context.DefineSex(name, patr);

            return(GKData.SexData[(int)sx].Sign);
        }
Beispiel #14
0
        public static bool ModifyIndividual(IBaseWindow baseWin, ref GDMIndividualRecord indivRec,
                                            GDMIndividualRecord target, TargetMode targetMode, GDMSex needSex)
        {
            bool result;

            try {
                baseWin.Context.BeginUpdate();
                GDMTree tree = baseWin.Context.Tree;

                using (var dlg = AppHost.ResolveDialog <IPersonEditDlg>(baseWin)) {
                    bool exists = (indivRec != null);
                    if (!exists)
                    {
                        indivRec = new GDMIndividualRecord(tree);
                        indivRec.InitNew();

                        indivRec.AddPersonalName(new GDMPersonalName(indivRec));
                        baseWin.Context.CreateEventEx(indivRec, GEDCOMTagName.BIRT, "", "");
                    }

                    try {
                        baseWin.Context.LockRecord(indivRec);

                        dlg.Person = indivRec;

                        if (targetMode != TargetMode.tmNone)
                        {
                            if (needSex == GDMSex.svMale || needSex == GDMSex.svFemale)
                            {
                                dlg.SetNeedSex(needSex);
                            }
                            dlg.TargetMode = targetMode;
                            dlg.Target     = target;
                        }

                        result = (AppHost.Instance.ShowModalX(dlg, false));
                    } finally {
                        baseWin.Context.UnlockRecord(indivRec);
                    }

                    if (!exists)
                    {
                        if (result)
                        {
                            PostProcessPerson(baseWin, indivRec);

                            tree.AddRecord(indivRec);
                        }
                        else
                        {
                            indivRec.Clear();
                            indivRec.Dispose();
                            indivRec = null;
                        }
                    }
                }
            } finally {
                baseWin.Context.EndUpdate();
            }

            return(result);
        }
Beispiel #15
0
        public static bool ModifyFamily(IBaseWindow baseWin, ref GDMFamilyRecord familyRec, TargetMode targetType, GDMIndividualRecord target)
        {
            bool result;

            try {
                baseWin.Context.BeginUpdate();
                GDMTree tree = baseWin.Context.Tree;

                if (targetType == TargetMode.tmFamilySpouse && target != null)
                {
                    GDMSex sex = target.Sex;
                    if (sex < GDMSex.svMale || sex > GDMSex.svFemale)
                    {
                        AppHost.StdDialogs.ShowError(LangMan.LS(LSID.LSID_IsNotDefinedSex));
                        return(false);
                    }
                }

                using (var dlg = AppHost.ResolveDialog <IFamilyEditDlg>(baseWin)) {
                    bool exists = (familyRec != null);
                    if (!exists)
                    {
                        familyRec = new GDMFamilyRecord(tree);
                        familyRec.InitNew();
                    }

                    try {
                        baseWin.Context.LockRecord(familyRec);

                        dlg.Family = familyRec;

                        if (targetType != TargetMode.tmNone && target != null)
                        {
                            dlg.SetTarget(targetType, target);
                        }

                        result = (AppHost.Instance.ShowModalX(dlg, false));
                    } finally {
                        baseWin.Context.UnlockRecord(familyRec);
                    }

                    if (!exists)
                    {
                        if (result)
                        {
                            tree.AddRecord(familyRec);
                        }
                        else
                        {
                            familyRec.Clear();
                            familyRec.Dispose();
                            familyRec = null;
                        }
                    }
                }
            } finally {
                baseWin.Context.EndUpdate();
            }

            return(result);
        }