Exemplo n.º 1
0
        private void SetPersonProperties(ref IndividualClass person)
        {
            if (propertyList != null)
            {
                person.GetPersonalName().SetName(PersonalNameClass.PartialNameType.GivenName, propertyList[0].Value.ToString());
                person.GetPersonalName().SetName(PersonalNameClass.PartialNameType.MiddleName, propertyList[1].Value.ToString());
                person.GetPersonalName().SetName(PersonalNameClass.PartialNameType.Surname, propertyList[2].Value.ToString());
                person.GetPersonalName().SetName(PersonalNameClass.PartialNameType.BirthSurname, propertyList[3].Value.ToString());
                person.GetPersonalName().SetName(PersonalNameClass.PartialNameType.NameString, propertyList[4].Value.ToString());
                person.GetPersonalName().SetName(PersonalNameClass.PartialNameType.PublicName, propertyList[5].Value.ToString());

                switch ((PersonPropertySex)propertyList[SexIndex].Value)
                {
                case PersonPropertySex.Female:
                    person.SetSex(IndividualClass.IndividualSexType.Female);
                    break;

                case PersonPropertySex.Male:
                    person.SetSex(IndividualClass.IndividualSexType.Male);
                    break;

                case PersonPropertySex.Unknown:
                    person.SetSex(IndividualClass.IndividualSexType.Unknown);
                    break;
                }

                IList <IndividualEventClass> eventList = person.GetEventList();

                familyTree.UpdateIndividual(person, PersonUpdateType.ChildFamily | PersonUpdateType.Events | PersonUpdateType.Name | PersonUpdateType.SpouseFamily);
            }
            else
            {
                trace.TraceEvent(TraceEventType.Error, 0, "error no proplist");
            }
        }
Exemplo n.º 2
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();
            }
        }