示例#1
0
        /*protected override void OnLayout(LayoutEventArgs e)
         * {
         * trace.TraceInformation("OnLayout()");
         * StartRefreshTimer();
         * base.OnLayout(e);
         * }*/

        private void CheckFamilyButton(string xref, int gen, bool force)
        {
            if (familyControlList.ContainsKey(xref))
            {
                FamilyButton familyButton = familyControlList[xref];

                familyButton.CheckPosition(force);

                if (familyButton.family != null)
                {
                    FamilyClass family = familyButton.family;

                    IList <IndividualXrefClass> parentList = family.GetParentList();

                    if (parentList != null)
                    {
                        foreach (IndividualXrefClass parentXref in parentList)
                        {
                            CheckPersonButton(parentXref.GetXrefName(), gen + 1, force);
                        }
                    }
                }
                else
                {
                    trace.TraceData(TraceEventType.Warning, 0, "Not yet cached family:" + gen + " " + xref);
                }
            }
            else
            {
                trace.TraceData(TraceEventType.Warning, 0, "Not buttoned family:" + gen + " " + xref);
            }
        }
示例#2
0
 void CheckI2fReferences(ref FamilyClass family)
 {
     if (parentsI2fReference.ContainsKey(family.GetXrefName()))
     {
         IList <string> parents = parentsI2fReference[family.GetXrefName()];
         if (parents.Count > family.GetParentList().Count)
         {
             trace.TraceData(TraceEventType.Warning, 0, family.GetXrefName() + " missing parents in family " + parents.Count + " > " + family.GetParentList().Count);
             foreach (string parent in parents)
             {
                 family.AddRelation(new IndividualXrefClass(parent), FamilyClass.RelationType.Parent);
             }
         }
     }
     if (childrenI2fReference.ContainsKey(family.GetXrefName()))
     {
         IList <string> children = childrenI2fReference[family.GetXrefName()];
         if (children.Count > family.GetChildList().Count)
         {
             trace.TraceData(TraceEventType.Warning, 0, family.GetXrefName() + " missing children in family " + children.Count + " > " + family.GetParentList().Count);
             foreach (string child in children)
             {
                 family.AddRelation(new IndividualXrefClass(child), FamilyClass.RelationType.Child);
             }
         }
     }
 }
示例#3
0
        private void UpdateFamily(FamilyClass family, TreeViewLayout layout, ref FamilyButton familyButton, IndividualButton parentButton = null)
        {
            trace.TraceInformation("UpdateFamily(" + family.GetXrefName() + "):" + familyButton.bLayout.generation);
            if (familyButton.family == null)
            {
                familyButton.family = family;
                familyButton.Refresh();
            }
            if (!familyButton.Visible)
            {
                if (!familyButton.SetLayout(layout, parentButton))
                {
                    trace.TraceInformation("UpdateFamily(" + family.GetXrefName() + ")-aborted");
                    return;
                }
                //familyButton.Refresh();
            }

            if (layout.VisibleButton(familyButton.bLayout))
            {
                if (layout.SearchChildren())
                {
                    UpdateIndividualList(family.GetChildList(), familyButton);
                }
                if (layout.SearchParents())
                {
                    UpdateIndividualList(family.GetParentList(), familyButton);
                }
                trace.TraceInformation("UpdateFamily(" + family.GetXrefName() + ")-done");
            }
            else
            {
                trace.TraceInformation("UpdateFamily(" + family.GetXrefName() + "," + familyButton.bLayout.generation + ") not visible generation => stop!");
            }
        }
示例#4
0
 public void UpdateFamilySync(string xref, FamilyClass family)
 {
     if (xref != family.GetXrefName())
     {
         trace.TraceData(TraceEventType.Error, 0, "Requested family doesn't match response!" + xref + "!=" + family.GetXrefName());
     }
     if (familyThreadList.ContainsKey(xref))
     {
         familyThreadList.Remove(xref);
     }
     else
     {
         trace.TraceData(TraceEventType.Error, 0, "Family thread not added!" + xref);
     }
     if (familyControlList.ContainsKey(xref))
     {
         FamilyButton familyButton = familyControlList[xref];
         if (family != null)
         {
             UpdateFamily(family, layout, ref familyButton, null);
         }
     }
     else
     {
         trace.TraceData(TraceEventType.Error, 0, "Family button not added!" + xref);
     }
 }
示例#5
0
 public void AddFamily(FamilyClass tempFamily)
 {
     if (familyList.ContainsKey(tempFamily.GetXrefName()))
     {
         familyList.Remove(tempFamily.GetXrefName());
     }
     familyList.Add(tempFamily.GetXrefName(), tempFamily);
 }
示例#6
0
 public void HandleNewFamily_Function(string xref, FamilyClass family)
 {
     if (InvokeRequired)
     {
         Invoke(new Action(() => UpdateFamilySync(xref, family)));
     }
     else
     {
         UpdateFamilySync(xref, family);
     }
 }
        } // end  of class


        //----------------------------------------------------------
        private void button1_Click(object sender, EventArgs e)
        {
            try {
                double a      = Convert.ToDouble(textBox1.Text);
                double b      = Convert.ToDouble(textBox2.Text);
                double result = FamilyClass.GrandParentMethod(a, b);
                listBox1.Items.Add(result.ToString("0.00"));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "do insert values into text boxes");
            }
        }
示例#8
0
        public FamilyButton(string xref, FamilyClass family = null)
        {
            Visible     = false;
            this.family = family;
            this.xref   = xref;
            bLayout     = new ButtonLayout();

            FlatStyle = FlatStyle.Flat;
            Anchor    = AnchorStyles.Left | AnchorStyles.Top;
            Click    += new System.EventHandler(Clicked);
            details   = new ToolTip();
            UpdateData();

            ClearLayout();
        }
示例#9
0
        public bool CheckFamily(string xrefName)
        {
            if (families.ContainsKey(xrefName))
            {
                FamilyClass family = families[xrefName];

                DateTime latestUpdate = family.GetLatestUpdate();

                if ((DateTime.Now - latestUpdate) < maxCacheTime)
                {
                    return(true);
                }
                families.Remove(xrefName);
                RemoveI2fReferences(xrefName);
            }
            return(false);
        }
示例#10
0
 public void AddFamily(FamilyClass family)
 {
     if (family.GetXrefName().Length == 0)
     {
         trace.TraceEvent(TraceEventType.Error, 0, "error: no xref!");
     }
     else
     {
         if (!families.ContainsKey(family.GetXrefName()))
         {
             CacheFamily(family);
         }
         else
         {
             trace.TraceData(TraceEventType.Information, 0, "family " + family.GetXrefName() + " already in cache!");
         }
     }
 }
示例#11
0
            public void DoWork(object sender, DoWorkEventArgs e)
            {
                string tXref = (string)e.Argument;

                if (familyTree != null)
                {
                    FamilyClass family = familyTree.GetFamily(tXref);

                    if (family != null)
                    {
                        trace.TraceInformation("FindFamilyThread(" + familyXref + ")-done ok");
                        familyCallback(tXref, family);
                        this.Dispose();
                        return;
                    }
                }
                trace.TraceInformation("FindFamilyThread(" + familyXref + ")-failed");
                familyCallback(tXref, null);
                this.Dispose();
            }
示例#12
0
        void CacheFamily(FamilyClass family)
        {
            trace.TraceInformation("CacheFamily " + family.GetXrefName() + " " + Thread.CurrentThread.GetApartmentState() + " " + Thread.CurrentThread.ManagedThreadId);

            lock (families)
            {
                if (!families.ContainsKey(family.GetXrefName()))
                {
                    trace.TraceInformation("cached family-2 " + family.GetXrefName() + " " + families.Count + " " + Thread.CurrentThread.ManagedThreadId);

                    latestUpdate = DateTime.Now;
                    families.Add(family.GetXrefName(), family);
                    UpdateF2iReferences(family);
                }
                else
                {
                    trace.TraceInformation("skipped family " + family.GetXrefName() + " " + Thread.CurrentThread.GetApartmentState() + " " + Thread.CurrentThread.ManagedThreadId);
                }
            }
        }
示例#13
0
        void UpdateF2iReferences(FamilyClass family)
        {
            int checkNo = 0;
            int addedNo = 0;
            IList <IndividualXrefClass> children = family.GetChildList();
            IList <IndividualXrefClass> parents  = family.GetParentList();

            lock (childrenF2iReference)
            {
                foreach (IndividualXrefClass individual in children)
                {
                    if (!childrenF2iReference.ContainsKey(individual.GetXrefName()))
                    {
                        childrenF2iReference.Add(individual.GetXrefName(), new List <string>());
                    }
                    if (!childrenF2iReference[individual.GetXrefName()].Contains(family.GetXrefName()))
                    {
                        childrenF2iReference[individual.GetXrefName()].Add(family.GetXrefName());
                        addedNo++;
                    }
                    checkNo++;
                }
            }
            lock (parentsF2iReference)
            {
                foreach (IndividualXrefClass individual in parents)
                {
                    if (!parentsF2iReference.ContainsKey(individual.GetXrefName()))
                    {
                        parentsF2iReference.Add(individual.GetXrefName(), new List <string>());
                    }
                    if (!parentsF2iReference[individual.GetXrefName()].Contains(family.GetXrefName()))
                    {
                        parentsF2iReference[individual.GetXrefName()].Add(family.GetXrefName());
                        addedNo++;
                    }
                    checkNo++;
                }
            }
        }
示例#14
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();
            }
        }
        void DecodeEvent(ref IndividualClass person, ParsePersonState evType, string eventString)
        {
            switch (evType)
            {
            case ParsePersonState.Birth:
            {
                person.AddEvent(DecodeEventType(eventString, IndividualEventClass.EventType.Birth, false));
            }
            break;

            case ParsePersonState.Baptism:
            {
                person.AddEvent(DecodeEventType(eventString, IndividualEventClass.EventType.Baptism, false));
            }
            break;

            case ParsePersonState.Death:
            {
                person.AddEvent(DecodeEventType(eventString, IndividualEventClass.EventType.Death, false));
            }
            break;

            case ParsePersonState.Burial:
            {
                person.AddEvent(DecodeEventType(eventString, IndividualEventClass.EventType.Burial, false));
            }
            break;

            case ParsePersonState.Occupation:
            {
                person.AddEvent(DecodeEventType(eventString, IndividualEventClass.EventType.Occupation, true));
            }
            break;

            /*case ParsePersonState.Fosterchild:
             * {
             *  IndividualEventClass occupation = new IndividualEventClass(IndividualEventClass.EventType.Adoption);
             *  occupation.AddNote(eventString);
             *  trace.TraceInformation("fosterchild " + eventString + " => " + occupation);
             *  person.AddEvent(occupation);
             * }
             * break;*/

            case ParsePersonState.Move:
            {
                person.AddEvent(DecodeEventType(eventString, IndividualEventClass.EventType.Immigration, true));
            }
            break;

            case ParsePersonState.Source:
            {
                SourceDescriptionClass source = new SourceDescriptionClass(eventString);

                trace.TraceInformation("source " + eventString + " => " + source);
                person.AddSource(source);
            }
            break;

            case ParsePersonState.Lived:
            {
                person.AddEvent(DecodeEventType(eventString, IndividualEventClass.EventType.Residence, true));
            }
            break;

            case ParsePersonState.Changed:
            {
                person.AddEvent(DecodeEventType(eventString, IndividualEventClass.EventType.RecordUpdate, true));
            }
            break;

            case ParsePersonState.ChildFamily:
            {
                string familyId = "";

                foreach (char ch in eventString)
                {
                    if ((ch >= '0') && (ch <= '9') || (ch == ':'))
                    {
                        familyId += ch;
                    }
                }
                string familyXref = xrefMapLists.GetMapper(XrefType.Family).GetXRef(familyId, false);
                person.AddRelation(new FamilyXrefClass(familyXref), IndividualClass.RelationType.Child);
                trace.TraceInformation("child in " + familyId + "=" + familyXref);
                FamilyClass family = familyTree.GetFamily(familyXref);

                if (family == null)
                {
                    family = new FamilyClass();
                    family.SetXrefName(familyXref);
                }
                family.AddRelation(new IndividualXrefClass(person.GetXrefName()), FamilyClass.RelationType.Child);
                familyTree.AddFamily(family);
            }
            break;

            case ParsePersonState.SpouseFamily:
            {
                string familyId = "";

                foreach (char ch in eventString)
                {
                    if ((ch >= '0') && (ch <= '9') || (ch == ':'))
                    {
                        familyId += ch;
                    }
                }
                string familyXref = xrefMapLists.GetMapper(XrefType.Family).GetXRef(familyId, false);
                person.AddRelation(new FamilyXrefClass(familyXref), IndividualClass.RelationType.Spouse);
                trace.TraceInformation("spouse in " + familyId + "=" + familyXref);
                FamilyClass family = familyTree.GetFamily(familyXref);

                if (family == null)
                {
                    family = new FamilyClass();
                    family.SetXrefName(familyXref);
                }
                family.AddRelation(new IndividualXrefClass(person.GetXrefName()), FamilyClass.RelationType.Parent);
                familyTree.AddFamily(family);
            }
            break;
            }
        }
示例#16
0
 public AddFamilyEvent(FamilyClass family)
 {
     this.family = family;
 }
示例#17
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);
            }
        }
示例#18
0
        private void AddPerson(IndividualClass person, Point position, int generation)
        {
            Point            size       = new Point(controlWidth, controlHeight);
            IndividualButton individual = new IndividualButton(this, person, size, boxFont);

            individual.Top  = position.Y;
            individual.Left = position.X;


            this.controlList.Add(individual);
            this.Controls.Add(individual);

            /*if (individual.Width > controlWidth)
             * {
             * individual.Width = controlWidth;
             * }*/

            if (generation < maxGenerations)
            {
                IList <FamilyXrefClass> parentFamilies = individual.individual.GetFamilyChildList();

                if (parentFamilies != null)
                {
                    foreach (FamilyXrefClass familyXref in parentFamilies)
                    {
                        FamilyClass family = familyTree.GetFamily(familyXref.GetXrefName());

                        if (family != null)
                        {
                            IList <IndividualXrefClass> parentXrefList = family.GetParentList();

                            if (parentXrefList != null)
                            {
                                Point nextPosition  = position;
                                int   margin        = controlMargin;
                                int   controlOffset = (controlHeight + margin) * (int)Math.Pow((double)2, (double)(maxGenerations - generation - 1));

                                //if(generation == 0)
                                {
                                    //margin += controlHeight / 2;
                                }

                                if (controlOffset > controlHeight)
                                {
                                    nextPosition.X += controlWidth + margin;
                                }

                                /*else
                                 * {
                                 * nextPosition.X += controlWidthSmall + margin;
                                 * }*/
                                nextPosition.Y -= controlOffset / 2;

                                foreach (IndividualXrefClass parentXref in parentXrefList)
                                {
                                    IndividualClass parent = familyTree.GetIndividual(parentXref.GetXrefName());

                                    if (parent != null)
                                    {
                                        AddPerson(parent, nextPosition, generation + 1);
                                    }
                                    nextPosition.Y += controlOffset;
                                }
                            }
                        }
                    }
                }
            }
        }
示例#19
0
        private void ShowActiveFamily()
        {
            trace.TraceInformation("TreeViewPanel4::ShowActiveFamily (start) " + this.CanFocus);

            while (controlList.Count > 0)
            {
                Control ctrl = controlList[0];

                this.Controls.Remove(ctrl);
                ctrl.Dispose();

                controlList.RemoveAt(0);

                //ctrl.
            }
            selectedFamily = null;

            if (selectedIndividual != null)
            {
                //int pos = 0;
                System.Drawing.Point position = new Point(0, 0);

                int ctrlHeight = 0;

                {
                    IList <FamilyXrefClass> children = selectedIndividual.GetFamilyChildList();
                    //trace.TraceInformation("GetFamilyChildList");

                    if (children != null)
                    {
                        //trace.TraceInformation("Children.count = " + children.Count);
                        foreach (FamilyXrefClass childXref in children)
                        {
                            FamilyClass childFamily = new FamilyClass();
                            childFamily = familyTree.GetFamily(childXref.GetXrefName());
                            if (childFamily != null)
                            {
                                trace.TraceInformation(" parentFamily:" + childFamily.GetXrefName());

                                if (childFamily != null)
                                {
                                    if (childFamily.GetParentList() != null)
                                    {
                                        foreach (IndividualXrefClass parentXref in childFamily.GetParentList())
                                        {
                                            IndividualClass parent = new IndividualClass();

                                            parent = familyTree.GetIndividual(parentXref.GetXrefName());

                                            if (parent != null)
                                            {
                                                IndividualButton ctrl2 = new IndividualButton();
                                                //int position.Y = 0;

                                                if (ctrlHeight == 0)
                                                {
                                                    Label label = new Label();

                                                    label.Top  = position.Y;
                                                    label.Left = position.X;
                                                    label.Text = "Parents:";

                                                    this.Controls.Add(label);
                                                    controlList.Add(label);

                                                    position.Y += label.Height;
                                                }

                                                ctrl2.AutoSize = true;
                                                ctrl2.Left     = position.X;
                                                ctrl2.Top      = position.Y;
                                                //ctrl.Height = 100;
                                                //ctrl.Width = 400;
                                                ctrl2.Text = parent.GetName() + "\n" + parent.GetDate(IndividualEventClass.EventType.Birth).ToString() + " - " + parent.GetDate(IndividualEventClass.EventType.Death).ToString();
                                                trace.TraceInformation(" parent: AddControl:" + parent.GetName() + " X:" + position.X + " Y:" + position.Y + " Top:" + ctrl2.Top + " height:" + ctrl2.Height);
                                                ctrl2.FlatStyle  = FlatStyle.Flat;
                                                ctrl2.individual = parent;
                                                ctrl2.SetParent(this);

                                                ctrl2.Click += new System.EventHandler(ctrl2.Clicked);

                                                //ctrl2.Anchor = AnchorStyles.Left | AnchorStyles.Top;

                                                //ctrl.Height = 40;
                                                //ctrl.Width = 40;
                                                //ctrl.Show();

                                                controlList.Add(ctrl2);

                                                this.Controls.Add(ctrl2);

                                                position.X += ctrl2.Width;

                                                ctrlHeight = ctrl2.Height;
                                            }
                                            else
                                            {
                                                trace.TraceEvent(TraceEventType.Error, 0, "Error not a vaild person xref:" + parentXref.GetXrefName());
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                trace.TraceEvent(TraceEventType.Error, 0, "Error not a vaild person xref:" + childXref.GetXrefName());
                            }
                        }
                    }
                }

                if (ctrlHeight != 0)
                {
                    position.X  = 0;
                    position.Y += ctrlHeight;
                    position.Y += 20;

                    ctrlHeight = 0;
                }

                {
                    {
                        Label label = new Label();

                        label.Top  = position.Y;
                        label.Left = position.X;
                        label.Text = "Selected:";

                        this.Controls.Add(label);
                        controlList.Add(label);

                        position.Y += label.Height;
                    }
                    IndividualButton ctrl = new IndividualButton();

                    ctrl.AutoSize = true;
                    ctrl.Left     = position.X;
                    ctrl.Top      = position.Y;
                    //ctrl.Height = 100;
                    //ctrl.Width = 400;
                    ctrl.Text = selectedIndividual.GetName() + "\n" + selectedIndividual.GetDate(IndividualEventClass.EventType.Birth).ToString() + " - " + selectedIndividual.GetDate(IndividualEventClass.EventType.Death).ToString();

                    ctrl.Anchor    = AnchorStyles.Left | AnchorStyles.Top;
                    ctrl.FlatStyle = FlatStyle.Flat;
                    ctrl.Click    += new System.EventHandler(ctrl.Clicked);
                    ctrl.BackColor = Color.Beige;

                    ctrl.individual = selectedIndividual;
                    ctrl.SetParent(this);

                    trace.TraceInformation(" selected: AddControl:" + selectedIndividual.GetName() + " X:" + position.X + " Y:" + position.Y + " Top:" + ctrl.Top + " Height:" + ctrl.Height);
                    controlList.Add(ctrl);

                    this.Controls.Add(ctrl);

                    position.X += ctrl.Width;

                    ctrlHeight = ctrl.Height;
                }

                /*if (ctrlHeight != 0)
                 * {
                 * position.Y += 20;
                 * ctrlHeight = 0;
                 * }*/

                {
                    IList <FamilyXrefClass> spouseList = selectedIndividual.GetFamilySpouseList();

                    //trace.TraceInformation("GetFamilySpouseList()");
                    if (spouseList != null)
                    {
                        //trace.TraceInformation("spouses.count = " + spouseList.Count);
                        foreach (FamilyXrefClass spouseFamilyXref in spouseList)
                        {
                            FamilyClass spouseFamily = new FamilyClass();
                            spouseFamily = familyTree.GetFamily(spouseFamilyXref.GetXrefName());

                            //trace.TraceInformation("spouses.count s2=" + spouseFamilyXref.GetXrefName());
                            if (spouseFamily != null)
                            {
                                trace.TraceInformation(" spouseFamily:" + spouseFamily.GetXrefName());
                                //trace.TraceInformation("spouses.count s3 = " + spouseFamily);
                                if (selectedFamily == null)
                                {
                                    selectedFamily = spouseFamily;
                                }
                                //trace.TraceInformation("spouses.count s4 = ");
                                if (spouseFamily.GetParentList() != null)
                                {
                                    foreach (IndividualXrefClass spouseXref in spouseFamily.GetParentList())
                                    {
                                        //trace.TraceInformation("spouses.count s5 = ");
                                        if (spouseXref.GetXrefName() != selectedIndividual.GetXrefName())
                                        {
                                            IndividualClass spouse = new IndividualClass();

                                            spouse = familyTree.GetIndividual(spouseXref.GetXrefName());

                                            if (spouse != null)
                                            {
                                                IndividualButton ctrl2 = new IndividualButton();
                                                //int position.Y = 0;

                                                ctrl2.AutoSize = true;
                                                ctrl2.Left     = position.X;
                                                ctrl2.Top      = position.Y;

                                                ctrl2.Text = spouse.GetName() + "\r" + spouse.GetDate(IndividualEventClass.EventType.Birth).ToString() + " - " + spouse.GetDate(IndividualEventClass.EventType.Death).ToString();

                                                ctrl2.SetParent(this);


                                                ctrl2.FlatStyle  = FlatStyle.Flat;
                                                ctrl2.individual = spouse;
                                                ctrl2.Click     += new System.EventHandler(ctrl2.Clicked);

                                                controlList.Add(ctrl2);

                                                this.Controls.Add(ctrl2);
                                                //ctrl2.PerformLayout();
                                                position.X += ctrl2.Width;
                                                ctrlHeight  = ctrl2.Height;
                                                trace.TraceInformation(" spouse: AddControl:" + spouse.GetName() + " X:" + position.X + " Y:" + position.Y + " Top:" + ctrl2.Top + " Height:" + ctrl2.Height);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                if (ctrlHeight != 0)
                {
                    position.X  = 0;
                    position.Y += ctrlHeight;
                    position.Y += 20;
                    ctrlHeight  = 0;
                }
                if (selectedFamily != null)
                {
                    IList <IndividualXrefClass> childXrefList = selectedFamily.GetChildList();

                    trace.TraceInformation(" childFamily:" + selectedFamily.GetXrefName());
                    if (childXrefList != null)
                    {
                        foreach (IndividualXrefClass childXref in childXrefList)
                        {
                            IndividualClass child = new IndividualClass();

                            child = familyTree.GetIndividual(childXref.GetXrefName());

                            if (child != null)
                            {
                                if (ctrlHeight == 0)
                                {
                                    Label label = new Label();

                                    label.Top  = position.Y;
                                    label.Left = position.X;
                                    label.Text = "Children:";

                                    this.Controls.Add(label);
                                    controlList.Add(label);

                                    position.Y += label.Height;
                                }
                                IndividualButton ctrl2 = new IndividualButton();
                                //int position.Y = 0;

                                ctrl2.AutoSize  = true;
                                ctrl2.Left      = position.X;
                                ctrl2.Top       = position.Y;
                                ctrl2.FlatStyle = FlatStyle.Flat;
                                ctrl2.Click    += new System.EventHandler(ctrl2.Clicked);
                                //ctrl.Height = 100;
                                //ctrl.Width = 400;
                                ctrl2.Text       = child.GetName() + "\n" + child.GetDate(IndividualEventClass.EventType.Birth).ToString() + " - " + child.GetDate(IndividualEventClass.EventType.Death).ToString();
                                ctrl2.individual = child;
                                ctrl2.SetParent(this);

                                //ctrl2.Anchor = AnchorStyles.Left | AnchorStyles.Top;

                                //ctrl.Height = 40;
                                //ctrl.Width = 40;
                                //ctrl.Show();

                                controlList.Add(ctrl2);

                                this.Controls.Add(ctrl2);

                                trace.TraceInformation(" child: AddControl:" + child.GetName() + " X:" + position.X + " Y:" + position.Y + " Top:" + ctrl2.Top + " Height:" + ctrl2.Height);

                                position.Y += ctrl2.Height;
                                ctrlHeight += ctrl2.Height;
                            }
                        }
                    }
                }
            }
            this.Top  = 0;
            this.Left = 0;

            this.Width  = 600;
            this.Height = 600;


            //this.Show();

            trace.TraceInformation("TreeViewPanel4::ShowActiveFamily (end) ");
        }
 public void AddFamily(FamilyClass tempFamily)
 {
 }
示例#21
0
        private void ShowActiveFamily()
        {
            trace.TraceInformation("TreeViewPanel2::ShowActiveFamily (start) " + this.CanFocus);

            while (controlList.Count > 0)
            {
                Control ctrl = controlList[0];

                this.Controls.Remove(ctrl);
                ctrl.Dispose();

                controlList.RemoveAt(0);
            }

            if (selectedIndividual != null)
            {
                Point position = new Point(0, 0);

                int ctrlHeight = 0;
                IDictionary <string, Point> familyPosition = new Dictionary <string, Point>();

                {
                    IList <FamilyXrefClass> children = selectedIndividual.GetFamilyChildList();

                    if (children != null)
                    {
                        trace.TraceInformation(" selected->parentFamilies.count = " + children.Count);
                        foreach (FamilyXrefClass childXref in children)
                        {
                            FamilyClass childFamily = new FamilyClass();
                            childFamily = familyTree.GetFamily(childXref.GetXrefName());

                            if (childFamily != null)
                            {
                                trace.TraceInformation(" selected->parentFamily:" + childFamily.GetXrefName());
                                if (childFamily.GetParentList() != null)
                                {
                                    foreach (IndividualXrefClass parentXref in childFamily.GetParentList())
                                    {
                                        IndividualClass parent = new IndividualClass();

                                        parent = familyTree.GetIndividual(parentXref.GetXrefName());

                                        if (parent != null)
                                        {
                                            IndividualButton ctrl2 = new IndividualButton(parent);

                                            if (ctrlHeight == 0)
                                            {
                                                Label label = new Label();

                                                label.Top  = position.Y;
                                                label.Left = position.X;
                                                label.Text = "Parents:";

                                                this.Controls.Add(label);
                                                controlList.Add(label);

                                                position.Y += label.Height;
                                            }

                                            //ctrl2.AutoSize = true;
                                            ctrl2.Left = position.X;
                                            ctrl2.Top  = position.Y;
                                            //ctrl2.Text = parent.GetName() + "\n" + parent.GetDate(IndividualEventClass.EventType.Birth).ToString() + " - " + parent.GetDate(IndividualEventClass.EventType.Death).ToString();
                                            trace.TraceInformation(" parent: AddControl:" + parent.GetName() + " X:" + position.X + " Y:" + position.Y + " Top:" + ctrl2.Top + " height:" + ctrl2.Height);
                                            //ctrl2.FlatStyle = FlatStyle.Flat;
                                            //ctrl2.individual = parent;
                                            ctrl2.SetParent(this);

                                            //ctrl2.Click += new System.EventHandler(ctrl2.Clicked);
                                            //ctrl2.MouseEnter += MouseEntered;
                                            //ctrl2.MouseLeave += MouseLeft;

                                            controlList.Add(ctrl2);

                                            this.Controls.Add(ctrl2);

                                            position.X += ctrl2.Width + 10;

                                            ctrlHeight = ctrl2.Height;
                                        }
                                        else
                                        {
                                            trace.TraceInformation("Error not a vaild person xref:" + parentXref.GetXrefName());
                                        }
                                    }
                                }
                            }
                            else
                            {
                                trace.TraceInformation("Error not a vaild person xref:" + childXref.GetXrefName());
                            }
                        }
                    }
                    else
                    {
                        trace.TraceInformation("selected->Children null ");
                    }
                }

                if (ctrlHeight != 0)
                {
                    position.X  = 0;
                    position.Y += ctrlHeight;
                    //position.Y += 20;

                    ctrlHeight = 0;
                }

                {
                    {
                        Label label = new Label();

                        label.Top  = position.Y;
                        label.Left = position.X;
                        label.Text = "Selected:";

                        this.Controls.Add(label);
                        controlList.Add(label);

                        position.Y += label.Height;
                    }
                    IndividualButton ctrl = new IndividualButton(selectedIndividual, true);

                    //ctrl.AutoSize = true;
                    ctrl.Left = position.X;
                    ctrl.Top  = position.Y;

                    //ctrl.Text = selectedIndividual.GetName() + "\n" + selectedIndividual.GetDate(IndividualEventClass.EventType.Birth).ToString() + " - " + selectedIndividual.GetDate(IndividualEventClass.EventType.Death).ToString();

                    //ctrl.Anchor = AnchorStyles.Left | AnchorStyles.Top;
                    //ctrl.FlatStyle = FlatStyle.Flat;
                    //ctrl.Click += new System.EventHandler(ctrl.Clicked);
                    //ctrl.MouseEnter += new System.EventHandler(MouseEntered);
                    //ctrl.MouseLeave += new System.EventHandler(MouseLeft);
                    //ctrl.BackColor = Color.Beige;

                    //ctrl.individual = selectedIndividual;
                    ctrl.SetParent(this);

                    trace.TraceInformation(" selected: AddControl:" + selectedIndividual.GetName() + " X:" + position.X + " Y:" + position.Y + " Top:" + ctrl.Top + " Height:" + ctrl.Height);
                    controlList.Add(ctrl);

                    this.Controls.Add(ctrl);

                    position.X += ctrl.Width + 10;

                    ctrlHeight = ctrl.Height;
                }

                {
                    IList <FamilyXrefClass> spouseList = selectedIndividual.GetFamilySpouseList();

                    if (spouseList != null)
                    {
                        trace.TraceInformation(" selected->spouseFamily->count:" + spouseList.Count);
                        foreach (FamilyXrefClass spouseFamilyXref in spouseList)
                        {
                            FamilyClass spouseFamily = new FamilyClass();
                            spouseFamily = familyTree.GetFamily(spouseFamilyXref.GetXrefName());

                            if (spouseFamily != null)
                            {
                                trace.TraceInformation(" selected->spouseFamily:" + spouseFamily.GetXrefName());
                                if (!familyPosition.ContainsKey(spouseFamily.GetXrefName()))
                                {
                                    Point famPos = new Point(position.X - 20, position.Y + ctrlHeight);
                                    familyPosition.Add(spouseFamilyXref.GetXrefName(), famPos);
                                    trace.TraceInformation(" selected->spouseFamily Add:" + famPos.X + "," + famPos.Y);
                                }
                                IList <IndividualXrefClass> spouseParentList = spouseFamily.GetParentList();

                                if (spouseParentList != null)
                                {
                                    foreach (IndividualXrefClass spouseXref in spouseParentList)
                                    {
                                        if (spouseXref.GetXrefName() != selectedIndividual.GetXrefName())
                                        {
                                            IndividualClass spouse = new IndividualClass();

                                            spouse = familyTree.GetIndividual(spouseXref.GetXrefName());

                                            if (spouse != null)
                                            {
                                                IndividualButton ctrl2 = new IndividualButton(spouse);
                                                //int position.Y = 0;

                                                //ctrl2.AutoSize = true;
                                                ctrl2.Left = position.X;
                                                ctrl2.Top  = position.Y;

                                                //ctrl2.Text = spouse.GetName() + "\r" + spouse.GetDate(IndividualEventClass.EventType.Birth).ToString() + " - " + spouse.GetDate(IndividualEventClass.EventType.Death).ToString();

                                                ctrl2.SetParent(this);

                                                //ctrl2.FlatStyle = FlatStyle.Flat;
                                                //ctrl2.individual = spouse;
                                                //ctrl2.Click += new System.EventHandler(ctrl2.Clicked);
                                                //ctrl2.MouseEnter += MouseEntered;
                                                //ctrl2.MouseLeave += MouseLeft;

                                                controlList.Add(ctrl2);

                                                this.Controls.Add(ctrl2);

                                                position.X += ctrl2.Width + 10;
                                                ctrlHeight  = ctrl2.Height;
                                                trace.TraceInformation(" spouse: AddControl:" + spouse.GetName() + " X:" + position.X + " Y:" + position.Y + " Top:" + ctrl2.Top + " Height:" + ctrl2.Height);
                                            }
                                            else
                                            {
                                                trace.TraceEvent(TraceEventType.Error, 0, "Error not a vaild person xref:" + spouseXref.GetXrefName());
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                trace.TraceEvent(TraceEventType.Error, 0, "Error not a vaild family xref:" + spouseFamilyXref.GetXrefName());
                            }
                        }
                        if (spouseList != null)
                        {
                            foreach (FamilyXrefClass family in spouseList)
                            {
                                FamilyClass familyObject = familyTree.GetFamily(family.GetXrefName());

                                if (familyObject != null)
                                {
                                    IList <IndividualXrefClass> childXrefList = familyTree.GetFamily(family.GetXrefName()).GetChildList();

                                    if (childXrefList != null)
                                    {
                                        trace.TraceInformation(" selectedFamily->childFamily:" + family.GetXrefName() + " children.count:" + childXrefList.Count);
                                        {
                                            Label label = new Label();

                                            Point childPosition = familyPosition[family.GetXrefName()];

                                            label.Top      = childPosition.Y;
                                            label.Left     = childPosition.X;
                                            label.Text     = "Children:" + childXrefList.Count;
                                            label.AutoSize = true;

                                            this.Controls.Add(label);
                                            controlList.Add(label);

                                            childPosition.Y += label.Height;
                                            familyPosition[family.GetXrefName()] = childPosition;
                                        }
                                        foreach (IndividualXrefClass childXref in childXrefList)
                                        {
                                            IndividualClass child = new IndividualClass();

                                            child = familyTree.GetIndividual(childXref.GetXrefName());

                                            if (child != null)
                                            {
                                                IndividualButton ctrl2 = new IndividualButton(child);

                                                ctrl2.AutoSize = true;
                                                Point childPosition = familyPosition[family.GetXrefName()];
                                                ctrl2.Left      = childPosition.X;
                                                ctrl2.Top       = childPosition.Y;
                                                ctrl2.FlatStyle = FlatStyle.Flat;
                                                ctrl2.Click    += new System.EventHandler(ctrl2.Clicked);
                                                //ctrl2.MouseEnter += MouseEntered;
                                                //ctrl2.MouseLeave += MouseLeft;

                                                //ctrl2.Text = child.GetName() + "\n" + child.GetDate(IndividualEventClass.EventType.Birth).ToString() + " - " + child.GetDate(IndividualEventClass.EventType.Death).ToString();
                                                ctrl2.individual = child;
                                                ctrl2.SetParent(this);

                                                controlList.Add(ctrl2);

                                                this.Controls.Add(ctrl2);

                                                trace.TraceInformation(" child: AddControl:" + child.GetName() + " X:" + position.X + " Y:" + position.Y + " Top:" + ctrl2.Top + " Height:" + ctrl2.Height);

                                                childPosition.Y += ctrl2.Height;
                                                familyPosition[family.GetXrefName()] = childPosition;
                                                ctrlHeight += ctrl2.Height;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        trace.TraceInformation(" selectedFamily->childFamily:" + family.GetXrefName() + " children null");
                                    }
                                }
                                else
                                {
                                    trace.TraceInformation(" selectedFamily:" + family.GetXrefName() + " null");
                                }
                            }
                        }
                    }
                    else
                    {
                        trace.TraceInformation(" selected->spouseFamily null");
                    }
                }
            }
            this.Top  = 0;
            this.Left = 0;

            this.Width  = 600;
            this.Height = 600;


            //this.Show();
            trace.TraceInformation("TreeViewPanel2::ShowActiveFamily (end) ");
        }
        public FamilyClass GetFamily(String familyXrefName)
        {
            if (familyXrefName == null)
            {
                trace.TraceInformation("GetFamily(null) = ");
                return(null);
            }
            if (cache.families.ContainsKey(familyXrefName))
            {
                if (printDecode)
                {
                    trace.TraceInformation("GetFamily(" + familyXrefName + ") cached");
                }
                return(cache.families[familyXrefName]);
            }
            if (printDecode)
            {
                trace.TraceInformation("GetFamily(" + familyXrefName + ") start " + DateTime.Now);
            }
            //IndividualClass individual = null;

            string sLine = null;

            try
            {
                string sURL = "https://www.geni.com/api/union-" + familyXrefName;

                WebRequest wrGETURL;
                wrGETURL = WebRequest.Create(sURL);
                if (authenticationToken != null)
                {
                    wrGETURL.Headers.Add("Authorization", String.Format("Bearer {0}", Uri.EscapeDataString(authenticationToken)));
                }
                if (printDecode)
                {
                    trace.TraceInformation("GetFamily() url " + sURL);
                }

                Stream objStream = wrGETURL.GetResponse().GetResponseStream();

                StreamReader objReader = new StreamReader(objStream);

                sLine = objReader.ReadToEnd();
            }
            catch
            {
                return(null);
            }
            if (sLine != null)
            {
                if (printDecode)
                {
                    trace.TraceInformation("**********************************************************-start");
                    trace.TraceInformation("{0}:{1}", sLine.Length, sLine);
                    trace.TraceInformation("**********************************************************-end");
                }
                if ((sLine.StartsWith("<!DOCTYPE") || sLine.StartsWith("<HTML") || sLine.StartsWith("<html")))
                {
                    trace.TraceInformation("Bad format. Don't parse.");
                    trace.TraceInformation("**********************************************************-start");
                    trace.TraceInformation("{0}:{1}", sLine.Length, sLine);
                    trace.TraceInformation("**********************************************************-end");
                    return(null);
                }

                familyResponse = serializer.Deserialize <HttpFamilyResponse>(sLine);

                if (familyResponse.id != null)
                {
                    FamilyClass family = new FamilyClass();
                    // Ignore "union-"
                    family.SetXrefName(familyResponse.id.Substring(6));

                    if (familyResponse.marriage_date != null)
                    {
                        family.AddEvent(new IndividualEventClass(IndividualEventClass.EventType.FamMarriage, new FamilyDateTimeClass(familyResponse.marriage_date.gedcom)));
                    }
                    if (familyResponse.husband != null)
                    {
                        int startPos = familyResponse.husband.id.IndexOf("individual-") + 11;

                        family.AddRelation(new IndividualXrefClass(familyResponse.husband.id.Substring(startPos)), FamilyClass.RelationType.Parent);
                    }
                    if (familyResponse.wife != null)
                    {
                        int startPos = familyResponse.wife.id.IndexOf("individual-") + 11;

                        family.AddRelation(new IndividualXrefClass(familyResponse.wife.id.Substring(startPos)), FamilyClass.RelationType.Parent);
                    }
                    if (familyResponse.children != null)
                    {
                        foreach (HttpChild child in familyResponse.children)
                        {
                            int startPos = child.child.id.IndexOf("individual-") + 11;
                            // ignore "profile-" = 8 characters
                            family.AddRelation(new IndividualXrefClass(child.child.id.Substring(startPos)), FamilyClass.RelationType.Child);
                        }
                    }
                    if (family.GetXrefName() != "")
                    {
                        if (printDecode)
                        {
                            //family.Print();
                            trace.TraceInformation("GetFamily(" + familyXrefName + ") done " + DateTime.Now);
                        }

                        cache.families.Add(family.GetXrefName(), family);

                        return(family);
                    }
                }
                else
                {
                    trace.TraceInformation("Error no data in familyresult:" + sLine);
                }
            }
            //Console.ReadLine();

            if (printDecode)
            {
                trace.TraceInformation("GetFamily(" + familyXrefName + ") = null" + DateTime.Now);
            }

            return(null);
        }