Beispiel #1
0
        private void CheckChildLink(GDMFamilyRecord fam, int index)
        {
            GDMIndividualLink childLink = fam.Children[index];
            var childRec = fTree.GetPtrValue <GDMIndividualRecord>(childLink);

            if (childRec == null)
            {
                fam.Children.DeleteAt(index);
                return;
            }

            if (fFormat == GEDCOMFormat.gf_AGES)
            {
                var frelTag = FindSubTagValue(childLink, "_FREL");
                var mrelTag = FindSubTagValue(childLink, "_MREL");
                if (frelTag == "ADOPTED" && mrelTag == "ADOPTED")
                {
                    GDMChildToFamilyLink ctfLink = childRec.FindChildToFamilyLink(fam);
                    ctfLink.PedigreeLinkageType = GDMPedigreeLinkageType.plAdopted;

                    childLink.DeleteTag("_FREL");
                    childLink.DeleteTag("_MREL");
                }
            }
        }
        public override void Setup()
        {
            TestUtils.InitGEDCOMProviderTest();
            WFAppHost.ConfigureBootstrap(false);

            fBase       = new BaseWindowStub();
            fIndividual = new GDMIndividualRecord(null);
            fChildLink  = new GDMChildToFamilyLink();

            fDialog        = new ParentsEditDlg(fBase);
            fDialog.Person = fIndividual;
            fDialog.Link   = fChildLink;
            fDialog.Show();
        }
Beispiel #3
0
 public static GDMFamilyRecord GetPtrValue(this GDMTree tree, GDMChildToFamilyLink ptr)
 {
     return(tree.GetPtrValue <GDMFamilyRecord>(ptr));
 }
Beispiel #4
0
        public override void Modify(object sender, ModifyEventArgs eArgs)
        {
            var iRec = fDataOwner as GDMIndividualRecord;

            if (fBaseWin == null || fSheetList == null || iRec == null)
            {
                return;
            }

            GDMChildToFamilyLink cfLink = eArgs.ItemData as GDMChildToFamilyLink;

            bool result = false;

            switch (eArgs.Action)
            {
            case RecordAction.raAdd:
                GDMFamilyRecord family = fBaseWin.Context.SelectFamily(iRec);
                if (family != null && family.IndexOfChild(iRec) < 0)
                {
                    result = fUndoman.DoOrdinaryOperation(OperationType.otIndividualParentsAttach, iRec, family);
                }
                break;

            case RecordAction.raEdit:
                if (cfLink != null)
                {
                    using (var dlg = AppHost.ResolveDialog <IParentsEditDlg>(fBaseWin)) {
                        dlg.Person = iRec;
                        dlg.Link   = cfLink;
                        result     = AppHost.Instance.ShowModalX(dlg, false);
                    }
                }
                break;

            case RecordAction.raDelete:
                if (AppHost.StdDialogs.ShowQuestionYN(LangMan.LS(LSID.LSID_DetachParentsQuery)))
                {
                    var famRec = fBaseContext.Tree.GetPtrValue(cfLink);
                    result = fUndoman.DoOrdinaryOperation(OperationType.otIndividualParentsDetach, iRec, famRec);
                }
                break;

            case RecordAction.raMoveUp:
            case RecordAction.raMoveDown:
                int idx = iRec.ChildToFamilyLinks.IndexOf(cfLink);
                switch (eArgs.Action)
                {
                case RecordAction.raMoveUp:
                    iRec.ChildToFamilyLinks.Exchange(idx - 1, idx);
                    break;

                case RecordAction.raMoveDown:
                    iRec.ChildToFamilyLinks.Exchange(idx, idx + 1);
                    break;
                }
                result = true;
                break;
            }

            if (result)
            {
                fBaseWin.Context.Modified = true;
                eArgs.IsChanged           = true;
            }
        }