Пример #1
0
        public override void Clear()
        {
            base.Clear();

            for (int i = fChildToFamilyLinks.Count - 1; i >= 0; i--)
            {
                GEDCOMFamilyRecord family = fChildToFamilyLinks[i].Family;
                family.DeleteChild(this);
            }
            fChildToFamilyLinks.Clear();

            for (int i = fSpouseToFamilyLinks.Count - 1; i >= 0; i--)
            {
                GEDCOMFamilyRecord family = fSpouseToFamilyLinks[i].Family;
                family.RemoveSpouse(this);
            }
            fSpouseToFamilyLinks.Clear();

            for (int i = fGroups.Count - 1; i >= 0; i--)
            {
                GEDCOMGroupRecord group = (GEDCOMGroupRecord)fGroups[i].Value;
                group.RemoveMember(this);
            }
            fGroups.Clear();

            fPersonalNames.Clear();
            fIndividualOrdinances.Clear();
            fSubmittors.Clear();
            fAssociations.Clear();
            fAliasses.Clear();
            fAncestorsInterest.Clear();
            fDescendantsInterest.Clear();
        }
Пример #2
0
        public GEDCOMFamilyRecord CreateFamily()
        {
            GEDCOMFamilyRecord result = new GEDCOMFamilyRecord(this, this, "", "");

            result.InitNew();
            result.ChangeDate.ChangeDateTime = DateTime.Now;

            AddRecord(result);
            return(result);
        }
Пример #3
0
        public bool DeleteFamilyRecord(GEDCOMFamilyRecord famRec)
        {
            if (famRec == null)
            {
                return(false);
            }

            famRec.Clear();
            DeleteRecord(famRec);
            return(true);
        }
Пример #4
0
        /// <summary>
        /// Attention: returns or creates only the first parents family!
        /// </summary>
        /// <param name="canCreate">can create if does not exist</param>
        /// <returns></returns>
        public GEDCOMFamilyRecord GetParentsFamily(bool canCreate = false)
        {
            GEDCOMFamilyRecord result = (fChildToFamilyLinks.Count < 1) ? null : fChildToFamilyLinks[0].Value as GEDCOMFamilyRecord;

            if (result == null && canCreate)
            {
                result = Owner.CreateFamily();
                result.AddChild(this);
            }

            return(result);
        }
Пример #5
0
        /// <summary>
        /// Attention: returns or creates only the first marriage!
        /// </summary>
        /// <param name="canCreate">can create if does not exist</param>
        /// <returns></returns>
        public GEDCOMFamilyRecord GetMarriageFamily(bool canCreate = false)
        {
            GEDCOMFamilyRecord result = (fSpouseToFamilyLinks.Count < 1) ? null : fSpouseToFamilyLinks[0].Family;

            if (result == null && canCreate)
            {
                result = Owner.CreateFamily();
                result.AddSpouse(this);
            }

            return(result);
        }
Пример #6
0
        public void DeleteChildToFamilyLink(GEDCOMFamilyRecord familyRec)
        {
            int num = fChildToFamilyLinks.Count;

            for (int i = 0; i < num; i++)
            {
                if (fChildToFamilyLinks[i].Family == familyRec)
                {
                    fChildToFamilyLinks.DeleteAt(i);
                    break;
                }
            }
        }
Пример #7
0
        public int GetTotalChildsCount()
        {
            int result = 0;

            int num = SpouseToFamilyLinks.Count;

            for (int i = 0; i < num; i++)
            {
                GEDCOMFamilyRecord family = SpouseToFamilyLinks[i].Family;
                result += family.Children.Count;
            }

            return(result);
        }
Пример #8
0
        public int IndexOfSpouse(GEDCOMFamilyRecord familyRec)
        {
            if (familyRec != null)
            {
                int num = fSpouseToFamilyLinks.Count;
                for (int i = 0; i < num; i++)
                {
                    if (fSpouseToFamilyLinks[i].Family == familyRec)
                    {
                        return(i);
                    }
                }
            }

            return(-1);
        }
Пример #9
0
        public override float IsMatch(GEDCOMTag tag, MatchParams matchParams)
        {
            GEDCOMFamilyRecord fam = tag as GEDCOMFamilyRecord;

            if (fam == null)
            {
                return(0.0f);
            }

            float match = 0.0f;

            string title1 = GetFamilyString();
            string title2 = fam.GetFamilyString();

            if (string.Compare(title1, title2, true) == 0)
            {
                match = 100.0f;
            }

            return(match);
        }
Пример #10
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);
            }
        }