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(); }
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(); } }
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) "); }
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; } } } } } } }
public bool Validate(FamilyTreeStoreBaseClass familyTree, ref ValidationData validationData, String callerXrefId = null) // IList<IndividualClass> individualList) { bool allFound = true; bool callerFound = (callerXrefId == null); //ValidationData validationData = new ValidationData(); //trace.TraceInformation("Validate: " + this.GetXrefName()); if (familyChildList != null) { foreach (FamilyXrefClass person in familyChildList) { String xrefName = person.GetXrefName(); bool found = false; if (callerXrefId == xrefName) { callerFound = true; } FamilyClass family; //family = (FamilyClass)familyTree.familyList[person.GetXrefName()]; family = familyTree.GetFamily(person.GetXrefName()); found = (family != null); if (!found) { // if (trace.Switch.Level.HasFlag(SourceLevels.Information)) { Print(); trace.TraceInformation(" Family-child not found: " + xrefName); } allFound = false; //return false; } else { //trace.TraceInformation("Found family-child : " + xrefName); } validationData.familyNo++; } } if (familySpouseList != null) { foreach (FamilyXrefClass person in familySpouseList) { String xrefName = person.GetXrefName(); bool found = false; if (callerXrefId == xrefName) { callerFound = true; } FamilyClass family; family = familyTree.GetFamily(person.GetXrefName()); found = (family != null); if (!found) { // if (trace.Switch.Level.HasFlag(SourceLevels.Information)) { Print(); trace.TraceInformation(" Spouse not found: " + xrefName); } allFound = false; //return false; } else { //trace.TraceInformation("Found spouse: " + xrefName); } validationData.individualNo++; } } if (noteXrefList != null) { foreach (NoteXrefClass noteXref in noteXrefList) { String xrefName = noteXref.GetXrefName(); bool found = false; if (callerXrefId == xrefName) { callerFound = true; } NoteClass note; note = familyTree.GetNote(noteXref.GetXrefName()); found = (note != null); if (!found) { if (trace.Switch.Level.HasFlag(SourceLevels.Information)) { Print(); trace.TraceInformation(" Note not found: " + xrefName); } allFound = false; //return false; } else { //trace.TraceInformation("Found spouse: " + xrefName); } validationData.noteNo++; } } //trace.TraceInformation("Validate: " + this.GetXrefName() + " = " + allFound); return(allFound && callerFound); }
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; } }