예제 #1
0
        public int IndexOfChild(GEDCOMRecord childRec)
        {
            int result = -1;

            for (int i = fChildren.Count - 1; i >= 0; i--)
            {
                if (fChildren[i].Value == childRec)
                {
                    result = i;
                    break;
                }
            }

            return(result);
        }
예제 #2
0
        public GEDCOMRecord FindUID(string uid)
        {
            int num = fRecords.Count;

            for (int i = 0; i < num; i++)
            {
                GEDCOMRecord rec = fRecords[i];
                if (rec.UID == uid)
                {
                    return(rec);
                }
            }

            return(null);
        }
예제 #3
0
        public int[] GetRecordStats()
        {
            int[] stats = new int[((int)GEDCOMRecordType.rtLast)];

            int num = RecordsCount;

            for (int i = 0; i < num; i++)
            {
                GEDCOMRecord rec   = this[i];
                int          index = (int)rec.RecordType;
                stats[index] += 1;
            }

            return(stats);
        }
        public override void MoveTo(GEDCOMRecord targetRecord, bool clearDest)
        {
            GEDCOMRecordWithEvents target = targetRecord as GEDCOMRecordWithEvents;

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

            base.MoveTo(targetRecord, clearDest);

            while (fEvents.Count > 0)
            {
                GEDCOMCustomEvent obj = fEvents.Extract(0);
                obj.ResetParent(target);
                target.AddEvent(obj);
            }
        }
예제 #5
0
        /// <summary>
        /// The MoveTo() merges records and their references, but does not change the text in the target.
        /// </summary>
        /// <param name="targetRecord"></param>
        /// <param name="clearDest"></param>
        public override void MoveTo(GEDCOMRecord targetRecord, bool clearDest)
        {
            GEDCOMNoteRecord targetNote = (targetRecord as GEDCOMNoteRecord);

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

            StringList cont = new StringList();

            try
            {
                cont.Text = targetNote.Note.Text;
                base.MoveTo(targetRecord, clearDest);
                targetNote.Note = cont;
            }
            finally
            {
                cont.Dispose();
            }
        }
예제 #6
0
        public override void Assign(GEDCOMTag source)
        {
            GEDCOMRecord sourceRec = source as GEDCOMRecord;

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

            base.Assign(source);

            foreach (GEDCOMNotes sourceNote in sourceRec.fNotes)
            {
                GEDCOMNotes copy = (GEDCOMNotes)GEDCOMNotes.Create(Owner, this, "", "");
                copy.Assign(sourceNote);
                Notes.Add(copy);
            }

            foreach (GEDCOMMultimediaLink sourceMediaLink in sourceRec.fMultimediaLinks)
            {
                GEDCOMMultimediaLink copy = (GEDCOMMultimediaLink)GEDCOMMultimediaLink.Create(Owner, this, "", "");
                copy.Assign(sourceMediaLink);
                MultimediaLinks.Add(copy);
            }

            foreach (GEDCOMSourceCitation sourceSrcCit in sourceRec.fSourceCitations)
            {
                GEDCOMSourceCitation copy = (GEDCOMSourceCitation)GEDCOMSourceCitation.Create(Owner, this, "", "");
                copy.Assign(sourceSrcCit);
                SourceCitations.Add(copy);
            }

            foreach (GEDCOMUserReference sourceUserRef in sourceRec.fUserReferences)
            {
                GEDCOMUserReference copy = (GEDCOMUserReference)GEDCOMUserReference.Create(Owner, this, "", "");
                copy.Assign(sourceUserRef);
                UserReferences.Add(copy);
            }
        }
예제 #7
0
        private StringList GetNotes()
        {
            StringList notes;

            if (!IsPointer)
            {
                notes = GetTagStrings(this);
            }
            else
            {
                GEDCOMRecord notesRecord = Value;
                if (notesRecord is GEDCOMNoteRecord)
                {
                    notes = ((notesRecord as GEDCOMNoteRecord).Note);
                }
                else
                {
                    notes = new StringList();
                }
            }

            return(notes);
        }
예제 #8
0
        public bool DeleteSourceRecord(GEDCOMSourceRecord srcRec)
        {
            if (srcRec == null)
            {
                return(false);
            }

            int num = fRecords.Count;

            for (int i = 0; i < num; i++)
            {
                GEDCOMRecord rec = this[i];
                for (int j = rec.SourceCitations.Count - 1; j >= 0; j--)
                {
                    if (rec.SourceCitations[j].Value == srcRec)
                    {
                        rec.SourceCitations.DeleteAt(j);
                    }
                }
            }

            DeleteRecord(srcRec);
            return(true);
        }
예제 #9
0
        // Support function. Parse GEDCOM string, returns ADDR object found
        private GEDCOMAddress AddrParse(string text)
        {
            // TODO should go into general utility class
            GEDCOMTree     tee = new GEDCOMTree();
            GEDCOMProvider gp  = new GEDCOMProvider(tee);

            try {
                gp.LoadFromString(text);
            } catch (Exception) {
            }
            Assert.AreEqual(1, tee.RecordsCount);
            GEDCOMRecord rec = tee[0];

            Assert.IsTrue(rec is GEDCOMIndividualRecord);
            GEDCOMIndividualRecord rec2 = (GEDCOMIndividualRecord)rec;
            // end for utility class

            GEDCOMList <GEDCOMCustomEvent> events = rec2.Events;

            Assert.AreEqual(1, events.Count);
            GEDCOMCustomEvent evt = events[0];

            return(evt.Address);
        }
예제 #10
0
        public bool DeleteMediaRecord(GEDCOMMultimediaRecord mRec)
        {
            if (mRec == null)
            {
                return(false);
            }

            int num = fRecords.Count;

            for (int i = 0; i < num; i++)
            {
                GEDCOMRecord rec = this[i];
                for (int j = rec.MultimediaLinks.Count - 1; j >= 0; j--)
                {
                    if (rec.MultimediaLinks[j].Value == mRec)
                    {
                        rec.MultimediaLinks.DeleteAt(j);
                    }
                }
            }

            DeleteRecord(mRec);
            return(true);
        }
예제 #11
0
        public bool DeleteNoteRecord(GEDCOMNoteRecord nRec)
        {
            if (nRec == null)
            {
                return(false);
            }

            int num = fRecords.Count;

            for (int i = 0; i < num; i++)
            {
                GEDCOMRecord rec = this[i];
                for (int j = rec.Notes.Count - 1; j >= 0; j--)
                {
                    if (rec.Notes[j].Value == nRec)
                    {
                        rec.Notes.DeleteAt(j);
                    }
                }
            }

            DeleteRecord(nRec);
            return(true);
        }
예제 #12
0
        /*public void Delete(int index)
         * {
         *  XRefIndex_DeleteRecord(fRecords[index]);
         *  fRecords.DeleteAt(index);
         * }*/

        public void DeleteRecord(GEDCOMRecord record)
        {
            XRefIndex_DeleteRecord(record);
            fRecords.Delete(record);
        }
예제 #13
0
 public int IndexOf(GEDCOMRecord record)
 {
     return(fRecords.IndexOf(record));
 }
예제 #14
0
 public GEDCOMRecord AddRecord(GEDCOMRecord record)
 {
     fRecords.Add(record);
     XRefIndex_AddRecord(record);
     return(record);
 }
예제 #15
0
        private static string GetSignByRecord(GEDCOMRecord record)
        {
            string result = "";

            if (record == null)
            {
                return(result);
            }

            switch (record.RecordType)
            {
            case GEDCOMRecordType.rtIndividual:
                result = "I";
                break;

            case GEDCOMRecordType.rtFamily:
                result = "F";
                break;

            case GEDCOMRecordType.rtNote:
                result = "N";
                break;

            case GEDCOMRecordType.rtMultimedia:
                result = "O";
                break;

            case GEDCOMRecordType.rtSource:
                result = "S";
                break;

            case GEDCOMRecordType.rtRepository:
                result = "R";
                break;

            case GEDCOMRecordType.rtGroup:
                result = "G";
                break;

            case GEDCOMRecordType.rtResearch:
                result = "RS";
                break;

            case GEDCOMRecordType.rtTask:
                result = "TK";
                break;

            case GEDCOMRecordType.rtCommunication:
                result = "CM";
                break;

            case GEDCOMRecordType.rtLocation:
                result = "L";
                break;

            case GEDCOMRecordType.rtSubmission:
                result = "????";
                break;

            case GEDCOMRecordType.rtSubmitter:
                result = "SUB";
                break;
            }

            return(result);
        }
예제 #16
0
 public XRefEntry(GEDCOMRecord rec, string oldXRef, string newXRef)
 {
     Rec     = rec;
     OldXRef = oldXRef;
     NewXRef = newXRef;
 }
예제 #17
0
 public void AddXRef(GEDCOMRecord rec, string oldXRef, string newXRef)
 {
     fList.Add(new XRefEntry(rec, oldXRef, newXRef));
 }
예제 #18
0
        public override void MoveTo(GEDCOMRecord targetRecord, bool clearDest)
        {
            GEDCOMIndividualRecord toRec = targetRecord as GEDCOMIndividualRecord;

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

            if (!clearDest)
            {
                DeleteTag("SEX");
                DeleteTag("_UID");
            }

            base.MoveTo(targetRecord, clearDest);

            while (fPersonalNames.Count > 0)
            {
                GEDCOMPersonalName obj = fPersonalNames.Extract(0);
                obj.ResetParent(toRec);
                toRec.AddPersonalName(obj);
            }

            if (toRec.ChildToFamilyLinks.Count == 0 && ChildToFamilyLinks.Count != 0 && fChildToFamilyLinks != null)
            {
                GEDCOMChildToFamilyLink ctfLink = fChildToFamilyLinks.Extract(0);
                GEDCOMFamilyRecord      family  = ctfLink.Family;

                int num = family.Children.Count;
                for (int i = 0; i < num; i++)
                {
                    GEDCOMPointer childPtr = family.Children[i];

                    if (childPtr.StringValue == "@" + XRef + "@")
                    {
                        childPtr.StringValue = "@" + targetRecord.XRef + "@";
                    }
                }

                ctfLink.ResetParent(toRec);
                toRec.ChildToFamilyLinks.Add(ctfLink);
            }

            while (fSpouseToFamilyLinks.Count > 0)
            {
                GEDCOMSpouseToFamilyLink stfLink = fSpouseToFamilyLinks.Extract(0);
                GEDCOMFamilyRecord       family  = stfLink.Family;

                string targetXRef = "@" + targetRecord.XRef + "@";

                if (family.Husband.StringValue == "@" + XRef + "@")
                {
                    family.Husband.StringValue = targetXRef;
                }
                else if (family.Wife.StringValue == "@" + XRef + "@")
                {
                    family.Wife.StringValue = targetXRef;
                }

                stfLink.ResetParent(toRec);
                toRec.SpouseToFamilyLinks.Add(stfLink);
            }

            while (fIndividualOrdinances.Count > 0)
            {
                GEDCOMIndividualOrdinance ord = fIndividualOrdinances.Extract(0);
                ord.ResetParent(toRec);
                toRec.IndividualOrdinances.Add(ord);
            }

            while (fSubmittors.Count > 0)
            {
                GEDCOMPointer obj = fSubmittors.Extract(0);
                obj.ResetParent(toRec);
                toRec.Submittors.Add(obj);
            }

            while (fAssociations.Count > 0)
            {
                GEDCOMAssociation obj = fAssociations.Extract(0);
                obj.ResetParent(toRec);
                toRec.Associations.Add(obj);
            }

            while (fAliasses.Count > 0)
            {
                GEDCOMAlias obj = fAliasses.Extract(0);
                obj.ResetParent(toRec);
                toRec.Aliases.Add(obj);
            }

            while (fAncestorsInterest.Count > 0)
            {
                GEDCOMPointer obj = fAncestorsInterest.Extract(0);
                obj.ResetParent(toRec);
                toRec.AncestorsInterest.Add(obj);
            }

            while (fDescendantsInterest.Count > 0)
            {
                GEDCOMPointer obj = fDescendantsInterest.Extract(0);
                obj.ResetParent(toRec);
                toRec.DescendantsInterest.Add(obj);
            }

            while (fGroups.Count > 0)
            {
                GEDCOMPointer obj = fGroups.Extract(0);
                obj.ResetParent(toRec);
                toRec.Groups.Add(obj);
            }
        }