예제 #1
0
            public string GetXRef(string fileXref, bool defined = false)
            {
                if (xrefMap.ContainsKey(fileXref))
                {
                    xrefMap[fileXref].CheckAndSetDefined(defined);
                    return(xrefMap[fileXref].newXref);
                }
                string newXref = familyTree.CreateNewXref(type);

                xrefMap.Add(fileXref, new XrefMapClass(newXref, defined));
                xrefMap[fileXref].CheckAndSetDefined(defined);
                return(newXref);
            }
예제 #2
0
            private string GetXRef(ref IDictionary <string, XrefMapperClass> mapper, XrefType type, string fileXref, bool defined)
            {
                if (mapper.ContainsKey(fileXref))
                {
                    mapper[fileXref].CheckAndSetDefined(defined);
                    return(mapper[fileXref].newXref);
                }
                //resultStr = "I" + Guid.NewGuid().ToString();
                string newXref = familyTree.CreateNewXref(type);

                mapper.Add(fileXref, new XrefMapperClass(newXref, defined));
                mapper[fileXref].CheckAndSetDefined(defined);
                return(newXref);
            }
예제 #3
0
        public void AddPersonEvent(object sender, EventArgs e)
        {
            if (m_addPersonForm != null)
            {
                selectedIndividual = new IndividualClass();

                m_addPersonForm.GetPerson(ref selectedIndividual);

                //m_addPersonForm.Close();

                m_addPersonForm.Visible = false;

                selectedIndividual.SetXrefName(familyTree.CreateNewXref(XrefType.Individual));
                familyTree.AddIndividual(selectedIndividual);
                if (SelectedPersonChanged != null)
                {
                    SelectedPersonChanged(this, new PersonChangeEvent(selectedIndividual));
                }
            }
        }
예제 #4
0
        public void AddRelative(RelativeType relation, IndividualClass person = null)
        {
            trace.TraceInformation("TreeViewPanel2::AddRelative " + relation);
            if (familyTree != null)
            {
                if (selectedIndividual != null)
                {
                    IndividualClass newPerson;
                    if (person != null)
                    {
                        newPerson = person;
                    }
                    else
                    {
                        newPerson = new IndividualClass();
                    }
                    newPerson.SetXrefName(familyTree.CreateNewXref(XrefType.Individual));

                    if (relation == RelativeType.Parent)
                    {
                        FamilyXrefClass         parentFamilyXref = null;
                        FamilyClass             parentFamily     = null;
                        IList <FamilyXrefClass> parents          = selectedIndividual.GetFamilyChildList();
                        if (parents != null)
                        {
                            if (parents.Count > 0)
                            {
                                // ToDo: Full support for multiple families..
                                parentFamilyXref = parents[0];
                                parentFamily     = familyTree.GetFamily(parentFamilyXref.GetXrefName());
                            }
                        }
                        if (parentFamilyXref == null)
                        {
                            parentFamilyXref = new FamilyXrefClass(familyTree.CreateNewXref(XrefType.Family));
                            //parentFamily.SetXrefName();
                            parentFamily = new FamilyClass();
                            parentFamily.SetXrefName(parentFamilyXref.GetXrefName());
                            parentFamily.AddRelation(new IndividualXrefClass(selectedIndividual.GetXrefName()), FamilyClass.RelationType.Child);
                            selectedIndividual.AddRelation(parentFamilyXref, IndividualClass.RelationType.Child);
                            familyTree.UpdateIndividual(selectedIndividual, PersonUpdateType.ChildFamily);
                        }
                        parentFamily.AddRelation(new IndividualXrefClass(newPerson.GetXrefName()), FamilyClass.RelationType.Parent);
                        newPerson.AddRelation(parentFamilyXref, IndividualClass.RelationType.Spouse);
                        familyTree.AddFamily(parentFamily);

                        familyTree.AddIndividual(newPerson);
                    }
                    else if (relation == RelativeType.Child)
                    {
                        FamilyXrefClass         childFamilyXref = null;
                        FamilyClass             childFamily     = null;
                        IList <FamilyXrefClass> children        = selectedIndividual.GetFamilySpouseList();
                        if (children != null)
                        {
                            if (children.Count > 0)
                            {
                                // ToDo: Full support for multiple families..
                                childFamilyXref = children[0];
                                childFamily     = familyTree.GetFamily(childFamilyXref.GetXrefName());
                            }
                        }
                        if (childFamilyXref == null)
                        {
                            childFamilyXref = new FamilyXrefClass(familyTree.CreateNewXref(XrefType.Family));
                            //parentFamily.SetXrefName();
                            childFamily = new FamilyClass();
                            childFamily.SetXrefName(childFamilyXref.GetXrefName());
                            childFamily.AddRelation(new IndividualXrefClass(selectedIndividual.GetXrefName()), FamilyClass.RelationType.Parent);
                            selectedIndividual.AddRelation(childFamilyXref, IndividualClass.RelationType.Spouse);
                            familyTree.UpdateIndividual(selectedIndividual, PersonUpdateType.SpouseFamily);
                        }
                        childFamily.AddRelation(new IndividualXrefClass(newPerson.GetXrefName()), FamilyClass.RelationType.Child);
                        newPerson.AddRelation(childFamilyXref, IndividualClass.RelationType.Child);
                        familyTree.AddFamily(childFamily);

                        familyTree.AddIndividual(newPerson);
                    }
                    else // if (relation == RelativeType.Unrelated)
                    {
                        familyTree.AddIndividual(newPerson);
                    }
                    //familyTree.AddIndividual(newPerson);
                }
                ShowActiveFamily();
            }
        }
예제 #5
0
        private void ReadFile(ref FamilyTreeStoreBaseClass inFamilyTree, FamilyTreeStoreAnarkiv anarkivStore)
        {
            //IndividualClass person = anarkivStore.GetIndividual();

            IEnumerator <IndividualClass> people = anarkivStore.SearchPerson();

            AnarkivMappers mappers = new AnarkivMappers(inFamilyTree);
            IDictionary <string, XrefMapperClass> individualMapper = mappers.GetMapper(XrefType.Individual);
            IDictionary <string, XrefMapperClass> familyMapper     = mappers.GetMapper(XrefType.Family);

            int counter = 0;

            while (people.MoveNext())
            {
                IndividualClass person = people.Current;

                trace.TraceInformation("Person[" + counter++ + "]:" + person.GetPersonalName().ToString());

                IndividualXrefClass xref = new IndividualXrefClass(inFamilyTree.CreateNewXref(XrefType.Individual));

                individualMapper.Add(person.GetXrefName(), new XrefMapperClass(xref.GetXrefName(), true));
                person.SetXrefName(xref.GetXrefName());

                if (person.GetFamilyChildList() != null)
                {
                    IList <FamilyXrefClass> newChildFamilies = new List <FamilyXrefClass>();
                    foreach (FamilyXrefClass childFamily in person.GetFamilyChildList())
                    {
                        FamilyXrefClass newFamily = new FamilyXrefClass(mappers.GetLocalXRef(XrefType.Family, childFamily.GetXrefName()));
                        newChildFamilies.Add(newFamily);
                    }
                    person.SetFamilyChildList(newChildFamilies);
                }

                if (person.GetFamilySpouseList() != null)
                {
                    IList <FamilyXrefClass> newSpouseFamilies = new List <FamilyXrefClass>();
                    foreach (FamilyXrefClass spouseFamily in person.GetFamilySpouseList())
                    {
                        FamilyXrefClass newFamily = new FamilyXrefClass(mappers.GetLocalXRef(XrefType.Family, spouseFamily.GetXrefName()));
                        newSpouseFamilies.Add(newFamily);
                    }
                    person.SetFamilySpouseList(newSpouseFamilies);
                }


                inFamilyTree.AddIndividual(person);
            }

            IEnumerator <FamilyClass> familyEnumerator = anarkivStore.SearchFamily();

            counter = 0;
            while (familyEnumerator.MoveNext())
            {
                FamilyClass family    = familyEnumerator.Current;
                FamilyClass newFamily = new FamilyClass();

                trace.TraceInformation("Family[" + counter++ + "]:" + family.GetXrefName());
                newFamily.SetXrefName(mappers.GetLocalXRef(XrefType.Family, family.GetXrefName(), true));

                trace.TraceInformation("Family xref " + family.GetXrefName() + " ==> " + newFamily.GetXrefName());

                if (family.GetParentList() != null)
                {
                    //IList<IndividualXrefClass> newParentList = new List<IndividualXrefClass>();
                    foreach (IndividualXrefClass parent in family.GetParentList())
                    {
                        IndividualXrefClass newParent = new IndividualXrefClass(mappers.GetLocalXRef(XrefType.Individual, parent.GetXrefName()));
                        //newParentList.Add(newParent);
                        newFamily.AddRelation(newParent, FamilyClass.RelationType.Parent);
                        trace.TraceInformation(" add parent  " + parent.GetXrefName() + " => " + newParent.GetXrefName());
                    }
                }
                if (family.GetChildList() != null)
                {
                    //IList<IndividualXrefClass> newChildList = new List<IndividualXrefClass>();
                    foreach (IndividualXrefClass child in family.GetChildList())
                    {
                        IndividualXrefClass newChild = new IndividualXrefClass(mappers.GetLocalXRef(XrefType.Individual, child.GetXrefName()));
                        //newChildList.Add(newChild);
                        newFamily.AddRelation(newChild, FamilyClass.RelationType.Child);
                        trace.TraceInformation(" add child  " + child.GetXrefName() + " => " + newChild.GetXrefName());
                    }
                }
                //family.

                inFamilyTree.AddFamily(newFamily);
            }
        }