Esempio n. 1
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);
        }
Esempio n. 2
0
 private static string GetCachedFilename(string imageUID)
 {
     return(AppHost.GetCachePath() + imageUID + ".bmp");
 }
Esempio n. 3
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);
        }