Exemple #1
0
        private static void CheckPersonalName(IBaseContext baseContext, GDMTree tree, GEDCOMFormat format, GDMPersonalName persName)
        {
            CheckTagWithNotes(tree, format, persName);
            CheckTagWithSourceCitations(tree, format, persName);

            baseContext.CollectNameLangs(persName);
        }
Exemple #2
0
        public static void RestrictAssociatedSources(this GDMTree tree, GDMIndividualRecord iRec)
        {
            // Restrict sources connected with individual directly
            foreach (GDMSourceCitation sc in iRec.SourceCitations)
            {
                RestrictSource(sc, true);
            }

            // Restrict sources connected with name
            foreach (GDMPersonalName pns in iRec.PersonalNames)
            {
                foreach (GDMSourceCitation sc in pns.SourceCitations)
                {
                    RestrictSource(sc, true);
                }
            }

            // Restrict sources connected with events
            foreach (GDMCustomEvent ies in iRec.Events)
            {
                foreach (GDMSourceCitation sc in ies.SourceCitations)
                {
                    RestrictSource(sc, true);
                }
            }

            // Restrict sources connected with m_associationStructures
            foreach (GDMAssociation ass in iRec.Associations)
            {
                foreach (GDMSourceCitation sc in ass.SourceCitations)
                {
                    RestrictSource(sc, true);
                }
            }
        }
Exemple #3
0
        public void Test_Standart()
        {
            Assembly assembly = typeof(CoreTests).Assembly;

            using (Stream inStream = assembly.GetManifestResourceStream("GKTests.Resources.TGC55CLF.GED")) {
                using (GDMTree tree = new GDMTree()) {
                    var gedcomProvider = new GEDCOMProvider(tree);
                    gedcomProvider.LoadFromStreamExt(inStream, inStream);

                    Assert.AreEqual(GEDCOMFormat.gf_Unknown, tree.Format);

                    GDMMultimediaRecord mmRec1 = tree.XRefIndex_Find("M1") as GDMMultimediaRecord;
                    Assert.IsNotNull(mmRec1);

                    GDMTag blobTag = mmRec1.FindTag("BLOB", 0);
                    Assert.IsNotNull(blobTag);
                    var strBlob = GEDCOMUtils.GetTagStrings(blobTag).Text;
                    Assert.IsNotNull(strBlob);
                    MemoryStream blobStream = GEDCOMUtils.DecodeBlob(strBlob.Replace("\r\n", ""));
                    Assert.IsNotNull(blobStream);

                    // unsupported apple's `pict` format

                    /*using (FileStream file = new FileStream("d:\\image.pict", FileMode.Create, FileAccess.Write)) {
                     *  blobStream.WriteTo(file);
                     *  blobStream.Close();
                     * }*/

                    using (MemoryStream outStream = new MemoryStream()) {
                        gedcomProvider = new GEDCOMProvider(tree);
                        gedcomProvider.SaveToStreamExt(outStream, GEDCOMCharacterSet.csASCII);
                    }
                }
            }
        }
Exemple #4
0
        private static void CheckRecord(IBaseContext baseContext, GDMTree tree, GDMRecord rec,
                                        GEDCOMFormat format, int fileVer)
        {
            CheckStructWL(tree, format, rec);

            switch (rec.RecordType)
            {
            case GDMRecordType.rtIndividual:
                CheckIndividualRecord(baseContext, tree, format, rec as GDMIndividualRecord);
                break;

            case GDMRecordType.rtFamily:
                CheckFamilyRecord(baseContext, tree, format, rec as GDMFamilyRecord);
                break;

            case GDMRecordType.rtGroup:
                CheckGroupRecord(rec as GDMGroupRecord);
                break;

            case GDMRecordType.rtSource:
                CheckSourceRecord(rec as GDMSourceRecord);
                break;

            case GDMRecordType.rtMultimedia:
                CheckMultimediaRecord(rec as GDMMultimediaRecord, format, fileVer);
                break;
            }
        }
Exemple #5
0
        public void Test_CompareTree()
        {
            string extFile = string.Empty;

            Assert.Throws(typeof(ArgumentNullException), () => { TreeTools.CompareTree(null, extFile, null); });
            Assert.Throws(typeof(ArgumentNullException), () => { TreeTools.CompareTree(fBaseWin.Context, extFile, null); });

            GDMTree extTree = null;

            Assert.Throws(typeof(ArgumentNullException), () => { TreeTools.CompareTree(null, extTree, null); });
            Assert.Throws(typeof(ArgumentNullException), () => { TreeTools.CompareTree(fBaseWin.Context, extTree, null); });

            var logStub = new TextBoxStub(null);

            Assembly assembly = typeof(CoreTests).Assembly;

            using (var ctx1 = new BaseContext(null)) {
                IBaseWindow baseWin = new BaseWindowStub(ctx1);

                using (Stream stmGed1 = assembly.GetManifestResourceStream("GKTests.Resources.test1.ged")) {
                    var gedcomProvider = new GEDCOMProvider(ctx1.Tree);
                    gedcomProvider.LoadFromStreamExt(stmGed1, stmGed1);
                }

                using (var ctx2 = new BaseContext(null)) {
                    using (Stream stmGed2 = assembly.GetManifestResourceStream("GKTests.Resources.test2.ged")) {
                        var gedcomProvider = new GEDCOMProvider(ctx2.Tree);
                        gedcomProvider.LoadFromStreamExt(stmGed2, stmGed2);

                        TreeTools.CompareTree(ctx1, ctx2.Tree, logStub);
                    }
                }
            }
        }
Exemple #6
0
        private static void PL_WalkDescLinks(GDMTree tree, Graph graph, GKVarCache <GDMFamilyRecord, PGNode> pgNodes, PGNode prevNode, GDMIndividualRecord ancestor)
        {
            for (int i = 0, count = ancestor.SpouseToFamilyLinks.Count; i < count; i++)
            {
                var family = tree.GetPtrValue(ancestor.SpouseToFamilyLinks[i]);
                var node   = pgNodes[family];

                if (node != null && node.Type != PGNodeType.Default)
                {
                    Vertex vtx = graph.FindVertex(node.FamilyXRef);
                    if (vtx == null)
                    {
                        vtx = graph.AddVertex(node.FamilyXRef, node);
                    }

                    if (prevNode != null)
                    {
                        graph.AddDirectedEdge(prevNode.FamilyXRef, node.FamilyXRef, 1, null);
                    }

                    prevNode = node;
                }

                for (int k = 0, count2 = family.Children.Count; k < count2; k++)
                {
                    GDMIndividualRecord child = tree.GetPtrValue(family.Children[k]);
                    PL_WalkDescLinks(tree, graph, pgNodes, prevNode, child);
                }
            }
        }
        public override void UpdateView()
        {
            GDMTree tree = fBase.Context.Tree;

            fTemp = fFilter.BranchPersons;

            var values = new StringList();
            int num    = tree.RecordsCount;

            for (int i = 0; i < num; i++)
            {
                GDMRecord rec = tree[i];
                if (rec.RecordType == GDMRecordType.rtSource)
                {
                    values.AddObject((rec as GDMSourceRecord).ShortTitle, rec);
                }
            }
            values.Sort();
            fView.SourceCombo.AddItem(LangMan.LS(LSID.LSID_SrcAll), null);
            fView.SourceCombo.AddItem(LangMan.LS(LSID.LSID_SrcNot), null);
            fView.SourceCombo.AddItem(LangMan.LS(LSID.LSID_SrcAny), null);
            fView.SourceCombo.AddStrings(values);

            UpdateControls();
        }
Exemple #8
0
        // TODO: refactor
        private static void CheckRecord_RepairTag(GDMTree tree, GEDCOMFormat format, GDMTagWithLists tag)
        {
            for (int i = tag.MultimediaLinks.Count - 1; i >= 0; i--)
            {
                GDMMultimediaLink mmLink = tag.MultimediaLinks[i];
                if (mmLink.IsPointer && mmLink.Value == null)
                {
                    tag.MultimediaLinks.DeleteAt(i);
                }
            }

            for (int i = tag.Notes.Count - 1; i >= 0; i--)
            {
                GDMNotes note = tag.Notes[i];
                if (note.IsPointer && note.Value == null)
                {
                    tag.Notes.DeleteAt(i);
                }
            }

            for (int i = tag.SourceCitations.Count - 1; i >= 0; i--)
            {
                GDMSourceCitation sourCit = tag.SourceCitations[i];
                if (sourCit.IsPointer && sourCit.Value == null)
                {
                    tag.SourceCitations.DeleteAt(i);
                }
            }
        }
Exemple #9
0
        private static void ConvertIdentifiers(GDMTree tree, IProgressController pc)
        {
            pc.ProgressInit(LangMan.LS(LSID.LSID_IDsCorrect), tree.RecordsCount * 2);
            GDMXRefReplacer repMap = new GDMXRefReplacer();

            try {
                int recsCount = tree.RecordsCount;
                for (int i = 0; i < recsCount; i++)
                {
                    GDMRecord rec = tree[i];
                    if (!CheckRecordXRef(rec))
                    {
                        string newXRef = tree.XRefIndex_NewXRef(rec);
                        repMap.AddXRef(rec, rec.XRef, newXRef);
                        rec.XRef = newXRef;
                    }
                    pc.ProgressStep();
                }

                tree.Header.ReplaceXRefs(repMap);
                for (int i = 0; i < recsCount; i++)
                {
                    GDMRecord rec = tree[i];
                    rec.ReplaceXRefs(repMap);
                    pc.ProgressStep();
                }
            } finally {
                repMap.Dispose();
                pc.ProgressDone();
            }
        }
Exemple #10
0
        private static void TransformMultimediaLink(GDMTree tree, GDMMultimediaLink mmLink)
        {
            string title = mmLink.Title;
            GDMMultimediaRecord mmRec = tree.CreateMultimedia();

            int num = mmLink.FileReferences.Count;

            for (int i = 0; i < num; i++)
            {
                GDMFileReference          srcFileRef = mmLink.FileReferences[i];
                GDMFileReferenceWithTitle tgtFileRef = new GDMFileReferenceWithTitle(mmRec);

                tgtFileRef.LinkFile(srcFileRef.StringValue);

                if (srcFileRef.MultimediaFormat != GDMMultimediaFormat.mfNone)
                {
                    tgtFileRef.MultimediaFormat = srcFileRef.MultimediaFormat;
                }
                if (srcFileRef.MediaType != GDMMediaType.mtUnknown)
                {
                    tgtFileRef.MediaType = srcFileRef.MediaType;
                }
                tgtFileRef.Title = title;

                mmRec.FileReferences.Add(tgtFileRef);
            }

            mmLink.Clear();
            mmLink.Value = mmRec;
        }
Exemple #11
0
        public void Test_CompareTree()
        {
            string extFile = string.Empty;

            Assert.Throws(typeof(ArgumentNullException), () => { TreeTools.CompareTree(null, extFile, null); });
            Assert.Throws(typeof(ArgumentNullException), () => { TreeTools.CompareTree(fBaseWin.Context, extFile, null); });

            GDMTree extTree = null;

            Assert.Throws(typeof(ArgumentNullException), () => { TreeTools.CompareTree(null, extTree, null); });
            Assert.Throws(typeof(ArgumentNullException), () => { TreeTools.CompareTree(fBaseWin.Context, extTree, null); });

            var logBox = Substitute.For <ITextBox>();

            using (var ctx1 = new BaseContext(null)) {
                IBaseWindow baseWin = new BaseWindowStub(ctx1);

                using (Stream stmGed1 = TestUtils.LoadResourceStream("test1.ged")) {
                    var gedcomProvider = new GEDCOMProvider(ctx1.Tree);
                    gedcomProvider.LoadFromStreamExt(stmGed1, stmGed1);
                }

                using (var ctx2 = new BaseContext(null)) {
                    using (Stream stmGed2 = TestUtils.LoadResourceStream("test2.ged")) {
                        var gedcomProvider = new GEDCOMProvider(ctx2.Tree);
                        gedcomProvider.LoadFromStreamExt(stmGed2, stmGed2);

                        TreeTools.CompareTree(ctx1, ctx2.Tree, logBox);
                    }
                }
            }
        }
Exemple #12
0
        private static void CheckFamilyRecord(IBaseContext baseContext, GDMTree tree, GEDCOMFormat format,
                                              GDMFamilyRecord fam)
        {
            for (int i = 0, num = fam.Events.Count; i < num; i++)
            {
                GDMCustomEvent evt = fam.Events[i];

                CheckEvent(tree, format, evt);
            }

            for (int i = fam.Children.Count - 1; i >= 0; i--)
            {
                if (fam.Children[i].Value == null)
                {
                    fam.Children.DeleteAt(i);
                }
            }

            GDMRecord val = fam.Husband.Value;

            if (!string.IsNullOrEmpty(fam.Husband.XRef) && val == null)
            {
                fam.Husband.Value = null;
            }

            val = fam.Wife.Value;
            if (!string.IsNullOrEmpty(fam.Wife.XRef) && val == null)
            {
                fam.Wife.Value = null;
            }
        }
Exemple #13
0
        public void Test_NativeFormat()
        {
            GEDCOMProvider.DebugWrite = false;
            using (Stream inStream = TestUtils.LoadResourceStream("test_native.ged")) {
                using (GDMTree tree = new GDMTree()) {
                    byte[] inArray;
                    using (MemoryStream inMem = new MemoryStream()) {
                        inStream.CopyTo(inMem);
                        inStream.Position = 0;
                        inArray           = inMem.ToArray();
                    }

                    var gedcomProvider = new GEDCOMProvider(tree);
                    gedcomProvider.LoadFromStreamExt(inStream, inStream);

                    using (MemoryStream outStream = new MemoryStream()) {
                        gedcomProvider = new GEDCOMProvider(tree);
                        gedcomProvider.SaveToStreamExt(outStream, GEDCOMCharacterSet.csUTF8);

                        outStream.Position = 0;
                        byte[] outArray = outStream.ToArray();

                        string inStr = Encoding.ASCII.GetString(inArray);
                        // convert to GK GEDCOM
                        inStr = inStr.Replace("1 ALIA @I11@", "1 ASSO @I11@\r\n2 RELA possible_duplicate");

                        string outStr = Encoding.ASCII.GetString(outArray);
                        Assert.AreEqual(inStr, outStr);
                    }
                }
            }
        }
Exemple #14
0
        private static void CheckTagWithLists(GDMTree tree, GEDCOMFormat format, GDMTagWithLists tag)
        {
            int num = tag.MultimediaLinks.Count;

            for (int i = 0; i < num; i++)
            {
                GDMMultimediaLink mmLink = tag.MultimediaLinks[i];
                if (!mmLink.IsPointer)
                {
                    TransformMultimediaLink(tree, mmLink);
                }
            }

            num = tag.Notes.Count;
            for (int i = 0; i < num; i++)
            {
                GDMNotes note = tag.Notes[i];
                if (!note.IsPointer)
                {
                    TransformNote(tree, note);
                }
            }

            num = tag.SourceCitations.Count;
            for (int i = 0; i < num; i++)
            {
                GDMSourceCitation sourCit = tag.SourceCitations[i];
                if (!sourCit.IsPointer)
                {
                    TransformSourceCitation(tree, sourCit);
                }
            }
        }
Exemple #15
0
 private GEDCOMChecker(IBaseContext baseContext, IProgressController progress)
 {
     fBaseContext = baseContext;
     fTree        = fBaseContext.Tree;
     fFormat      = GEDCOMProvider.GetGEDCOMFormat(fTree);
     fProgress    = progress;
 }
Exemple #16
0
        public void Test_NativeFormat()
        {
            GEDCOMProvider.DebugWrite = false;
            Assembly assembly = typeof(CoreTests).Assembly;

            using (Stream inStream = assembly.GetManifestResourceStream("GKTests.Resources.test_native.ged")) {
                using (GDMTree tree = new GDMTree()) {
                    byte[] inArray;
                    using (MemoryStream inMem = new MemoryStream()) {
                        inStream.CopyTo(inMem);
                        inStream.Position = 0;
                        inArray           = inMem.ToArray();
                    }

                    var gedcomProvider = new GEDCOMProvider(tree);
                    gedcomProvider.LoadFromStreamExt(inStream, inStream);

                    using (MemoryStream outStream = new MemoryStream()) {
                        gedcomProvider = new GEDCOMProvider(tree);
                        gedcomProvider.SaveToStreamExt(outStream, GEDCOMCharacterSet.csUTF8);

                        outStream.Position = 0;
                        byte[] outArray;
                        outArray = outStream.ToArray();

                        string outStr = Encoding.ASCII.GetString(outArray);
                        Assert.AreEqual(Encoding.ASCII.GetString(inArray), outStr);
                    }
                }
            }
        }
Exemple #17
0
        public void Test_LanguageEditDlgController()
        {
            var view = Substitute.For <ILanguageEditDlg>();

            Assert.AreEqual(GDMLanguageID.Unknown, view.LanguageID);

            var baseWin = Substitute.For <IBaseWindow>();
            var tree    = new GDMTree();

            var controller = new LanguageEditDlgController(view);

            Assert.IsNotNull(controller);

            controller.Init(baseWin);
            Assert.AreEqual(baseWin, controller.Base);

            controller.LanguageID = GDMLanguageID.Akkadian;
            Assert.AreEqual(GDMLanguageID.Akkadian, controller.LanguageID);

            var langValue = GDMLanguageID.AngloSaxon;

            // substitutes of values
            view.LanguageCombo.GetSelectedTag <GDMLanguageID>().Returns(langValue);

            Assert.IsTrue(controller.Accept());
            Assert.AreEqual(langValue, controller.LanguageID);
        }
Exemple #18
0
        private static void CheckRecord(IBaseContext baseContext, GDMTree tree, GDMRecord rec,
                                        GEDCOMFormat format, int fileVer)
        {
            if (format != GEDCOMFormat.gf_Native)
            {
                int num = rec.MultimediaLinks.Count;
                for (int i = 0; i < num; i++)
                {
                    GDMMultimediaLink mmLink = rec.MultimediaLinks[i];
                    if (!mmLink.IsPointer)
                    {
                        TransformMultimediaLink(tree, mmLink);
                    }
                }

                num = rec.Notes.Count;
                for (int i = 0; i < num; i++)
                {
                    GDMNotes note = rec.Notes[i];
                    if (!note.IsPointer)
                    {
                        TransformNote(tree, note);
                    }
                }

                num = rec.SourceCitations.Count;
                for (int i = 0; i < num; i++)
                {
                    GDMSourceCitation sourCit = rec.SourceCitations[i];
                    if (!sourCit.IsPointer)
                    {
                        TransformSourceCitation(tree, sourCit);
                    }
                }
            }

            switch (rec.RecordType)
            {
            case GDMRecordType.rtIndividual:
                CheckIndividualRecord(baseContext, tree, format, rec as GDMIndividualRecord);
                break;

            case GDMRecordType.rtFamily:
                CheckFamilyRecord(baseContext, tree, format, rec as GDMFamilyRecord);
                break;

            case GDMRecordType.rtGroup:
                CheckGroupRecord(rec as GDMGroupRecord);
                break;

            case GDMRecordType.rtSource:
                CheckSourceRecord(rec as GDMSourceRecord);
                break;

            case GDMRecordType.rtMultimedia:
                CheckMultimediaRecord(rec as GDMMultimediaRecord, format, fileVer);
                break;
            }
        }
Exemple #19
0
        private static void TransformNote(GDMTree tree, GDMNotes note)
        {
            GDMNoteRecord noteRec = tree.CreateNote();

            noteRec.Lines.Assign(note.Lines);

            note.Clear();
            note.Value = noteRec;
        }
Exemple #20
0
        public void Test_GetGEDCOMFormat()
        {
            GDMTree tree = new GDMTree();

            // Tests of determine GEDCOM-format
            Assert.AreEqual(GEDCOMFormat.gf_Unknown, GEDCOMProvider.GetGEDCOMFormat(tree));
            tree.Header.Source.StringValue = "GENBOX";
            Assert.AreEqual(GEDCOMFormat.gf_GENBOX, GEDCOMProvider.GetGEDCOMFormat(tree));
        }
Exemple #21
0
 public void Test_FamilyShow()
 {
     using (Stream inStream = TestUtils.LoadResourceStream("test_windsor.familyx")) {
         using (GDMTree tree = new GDMTree()) {
             var fxProvider = new FamilyXProvider(tree);
             fxProvider.LoadFromStreamExt(inStream, inStream);
         }
     }
 }
Exemple #22
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);
        }
Exemple #23
0
        private static void CheckIndividualRecord(IBaseContext baseContext, GDMTree tree, GEDCOMFormat format,
                                                  GDMIndividualRecord iRec)
        {
            for (int i = 0, num = iRec.Events.Count; i < num; i++)
            {
                GDMCustomEvent evt = iRec.Events[i];

                CheckEvent(tree, format, evt);

                baseContext.CollectEventValues(evt);
            }

            for (int i = 0, num = iRec.UserReferences.Count; i < num; i++)
            {
                CheckUserRef(iRec, iRec.UserReferences[i]);
            }

            for (int i = 0, num = iRec.PersonalNames.Count; i < num; i++)
            {
                CheckPersonalName(baseContext, tree, format, iRec.PersonalNames[i]);
            }

            for (int i = iRec.ChildToFamilyLinks.Count - 1; i >= 0; i--)
            {
                var cfl = iRec.ChildToFamilyLinks[i];
                if (cfl.Family == null)
                {
                    iRec.ChildToFamilyLinks.DeleteAt(i);
                }
                else
                {
                    CheckPointerWithNotes(tree, format, cfl);
                }
            }

            for (int i = iRec.SpouseToFamilyLinks.Count - 1; i >= 0; i--)
            {
                var sfl = iRec.SpouseToFamilyLinks[i];
                if (sfl.Family == null)
                {
                    iRec.SpouseToFamilyLinks.DeleteAt(i);
                }
                else
                {
                    CheckPointerWithNotes(tree, format, sfl);
                }
            }

            for (int i = 0, num = iRec.Associations.Count; i < num; i++)
            {
                var asso = iRec.Associations[i];
                CheckPointerWithNotes(tree, format, asso);
                CheckTagWithSourceCitations(tree, format, asso);
            }

            baseContext.ImportNames(iRec);
        }
Exemple #24
0
 public BaseWindowStub(bool fill = true)
 {
     fContext = TestUtils.CreateContext(/*this*/);
     if (fill)
     {
         TestUtils.FillContext(fContext);
     }
     fTree = fContext.Tree;
 }
Exemple #25
0
        protected Exporter(IBaseWindow baseWin)
        {
            if (baseWin == null)
            {
                throw new ArgumentNullException("baseWin");
            }

            fBase = baseWin;
            fTree = baseWin.Context.Tree;
        }
        private void UpdateTreeMap()
        {
            fDataMap.Model.Items.Clear();
            if (fBase == null)
            {
                fDataMap.Invalidate();
                return;
            }

            string hint = fPlugin.LangMan.LS(CLS.LSID_Hint);

            GDMTree tree = fBase.Context.Tree;
            List <GDMIndividualRecord> prepared     = new List <GDMIndividualRecord>();
            List <GDMRecord>           groupRecords = new List <GDMRecord>();

            try {
                int groupNum = 0;
                int num      = tree.RecordsCount;
                for (int i = 0; i < num; i++)
                {
                    GDMRecord rec = tree[i];

                    if (rec.RecordType == GDMRecordType.rtIndividual)
                    {
                        GDMIndividualRecord iRec = rec as GDMIndividualRecord;
                        if (prepared.IndexOf(iRec) < 0)
                        {
                            groupNum++;
                            groupRecords.Clear();

                            TreeTools.WalkTree(tree, iRec, TreeTools.TreeWalkMode.twmAll, groupRecords);

                            int   groupSize = groupRecords.Count;
                            float quality   = 0.0f;
                            for (int j = 0; j < groupSize; j++)
                            {
                                iRec = (GDMIndividualRecord)groupRecords[j];
                                prepared.Add(iRec);

                                quality += iRec.GetCertaintyAssessment();
                            }
                            quality /= groupSize;

                            string name = string.Format(hint, groupNum, groupSize, quality.ToString("0.00"));

                            CreateItem(null, name, groupSize, quality);
                        }
                    }
                }
            } finally {
                groupRecords.Clear();
            }

            fDataMap.UpdateView();
        }
Exemple #27
0
        public void Test_FamilyShow()
        {
            Assembly assembly = typeof(CoreTests).Assembly;

            using (Stream inStream = assembly.GetManifestResourceStream("GKTests.Resources.test_windsor.familyx")) {
                using (GDMTree tree = new GDMTree()) {
                    var fxProvider = new FamilyXProvider(tree);
                    fxProvider.LoadFromStreamExt(inStream, inStream);
                }
            }
        }
Exemple #28
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);
        }
Exemple #29
0
 // Marks the given source citation as (un)restricted
 public static void RestrictSource(GDMTree tree, GDMSourceCitation sc, bool visible)
 {
     if (tree != null && sc != null)
     {
         var sourceRec = tree.GetPtrValue <GDMSourceRecord>(sc);
         if (sourceRec != null)
         {
             GMHelper.SetVisibility(sourceRec, visible);
         }
     }
 }
Exemple #30
0
        public static bool DetectCycle(GDMTree tree, GDMIndividualRecord iRec)
        {
            string res = TreeTools.DetectCycle(tree, iRec);

            if (!string.IsNullOrEmpty(res))
            {
                AppHost.StdDialogs.ShowError(string.Format(LangMan.LS(LSID.LSID_DetectedDataLoop), res));
                return(true);
            }
            return(false);
        }