Example #1
0
        public static bool AddIndividualPortrait(IBaseWindow baseWin, ChangeTracker localUndoman, GDMIndividualRecord iRec)
        {
            bool result = false;

            GDMMultimediaRecord mmRec = baseWin.Context.SelectRecord(GDMRecordType.rtMultimedia, null) as GDMMultimediaRecord;

            if (mmRec == null)
            {
                return(false);
            }

            // remove previous portrait link
            GDMMultimediaLink mmLink = iRec.GetPrimaryMultimediaLink();

            if (mmLink != null)
            {
                mmLink.IsPrimary = false;
            }

            // set new portrait link
            mmLink = iRec.SetPrimaryMultimediaLink(mmRec);

            // select portrait area
            using (var selectDlg = AppHost.ResolveDialog <IPortraitSelectDlg>(baseWin)) {
                selectDlg.MultimediaLink = mmLink;
                result = AppHost.Instance.ShowModalX(selectDlg, false);
            }

            if (result)
            {
                result = localUndoman.DoOrdinaryOperation(OperationType.otIndividualPortraitAttach, iRec, mmLink);
            }

            return(result);
        }
Example #2
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.tmSpouse && 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;
                        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);
        }
Example #3
0
        public static bool ModifyNote(IBaseWindow baseWin, ref GDMNoteRecord noteRec)
        {
            bool result;

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

                bool exists = noteRec != null;
                if (!exists)
                {
                    noteRec = new GDMNoteRecord(tree);
                    noteRec.InitNew();
                }

                try {
                    baseWin.Context.LockRecord(noteRec);

                    if (GlobalOptions.Instance.UseExtendedNotes)
                    {
                        using (var dlg = AppHost.ResolveDialog <INoteEditDlgEx>(baseWin)) {
                            dlg.NoteRecord = noteRec;
                            result         = (AppHost.Instance.ShowModalX(dlg, false));
                        }
                    }
                    else
                    {
                        using (var dlg = AppHost.ResolveDialog <INoteEditDlg>(baseWin)) {
                            dlg.NoteRecord = noteRec;
                            result         = (AppHost.Instance.ShowModalX(dlg, false));
                        }
                    }
                } finally {
                    baseWin.Context.UnlockRecord(noteRec);
                }

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

            return(result);
        }
Example #4
0
        public void ShowOptions(OptionsPage page)
        {
            using (var dlgOptions = AppHost.ResolveDialog <IOptionsDlg>(AppHost.Instance)) {
                dlgOptions.SetPage(page);

                if (AppHost.Instance.ShowModalX(dlgOptions))
                {
                    AppHost.Instance.ApplyOptions();
                }
            }
        }
Example #5
0
        public static ushort RequestLanguage()
        {
            using (var dlg = AppHost.ResolveDialog <ILanguageSelectDlg>()) {
                if (AppHost.Instance.ShowModalX(dlg, false))
                {
                    return((ushort)dlg.SelectedLanguage);
                }
            }

            return(LangMan.LS_DEF_CODE);
        }
Example #6
0
        public static bool ModifyAddress(IBaseWindow baseWin, GDMAddress address)
        {
            bool result;

            try {
                baseWin.Context.BeginUpdate();

                using (var dlg = AppHost.ResolveDialog <IAddressEditDlg>(baseWin)) {
                    dlg.Address = address;
                    result      = (AppHost.Instance.ShowModalX(dlg, false));
                }
            } finally {
                baseWin.Context.EndUpdate();
            }

            return(result);
        }
Example #7
0
        public static bool ModifyMedia(IBaseWindow baseWin, ref GDMMultimediaRecord mediaRec)
        {
            bool result;

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

                using (var dlg = AppHost.ResolveDialog <IMediaEditDlg>(baseWin)) {
                    bool exists = mediaRec != null;
                    if (!exists)
                    {
                        mediaRec = new GDMMultimediaRecord(tree);
                        mediaRec.FileReferences.Add(new GDMFileReferenceWithTitle(mediaRec));
                        mediaRec.InitNew();
                    }

                    try {
                        baseWin.Context.LockRecord(mediaRec);

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

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

            return(result);
        }
Example #8
0
        public static bool ModifyName(IBaseContext context, ref NameEntry nameEntry)
        {
            bool result;

            try {
                context.BeginUpdate();

                using (var dlg = AppHost.ResolveDialog <INameEditDlg>())
                {
                    dlg.IName = nameEntry;
                    result    = AppHost.Instance.ShowModalX(dlg, false);
                }
            } finally {
                context.EndUpdate();
            }

            return(result);
        }
Example #9
0
        public static bool ModifyLocation(IBaseWindow baseWin, ref GDMLocationRecord locRec)
        {
            bool result;

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

                using (var dlg = AppHost.ResolveDialog <ILocationEditDlg>(baseWin)) {
                    bool exists = locRec != null;
                    if (!exists)
                    {
                        locRec = new GDMLocationRecord(tree);
                        locRec.InitNew();
                    }

                    try {
                        baseWin.Context.LockRecord(locRec);

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

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

            return(result);
        }
Example #10
0
        public static bool ModifySourceCitation(IBaseWindow baseWin, ChangeTracker undoman, IGEDCOMStructWithLists _struct, ref GDMSourceCitation cit)
        {
            bool result;

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

                using (var dlg = AppHost.ResolveDialog <ISourceCitEditDlg>(baseWin)) {
                    bool exists = cit != null;
                    if (!exists)
                    {
                        cit = new GDMSourceCitation(_struct as GDMObject);
                    }

                    dlg.SourceCitation = cit;
                    result             = AppHost.Instance.ShowModalX(dlg, false);

                    if (!exists)
                    {
                        if (result)
                        {
                            result = undoman.DoOrdinaryOperation(OperationType.otRecordSourceCitAdd, (GDMObject)_struct, cit);
                        }
                        else
                        {
                            cit.Dispose();
                        }
                    }
                }
            } finally {
                baseWin.Context.EndUpdate();
            }

            return(result);
        }
Example #11
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);
        }