protected void OnSpouseSelect(object sender, SpouseSelectArgs e) { IndividualListDialog listDialog = new IndividualListDialog(); SpouseListModel listModel = new SpouseListModel(); if (sender is Gtk.Dialog) { listDialog.TransientFor = (Gtk.Window)sender; } else { listDialog.TransientFor = this; } listModel.Database = _database; listModel.Record = e.Indi; listDialog.Title = "Select Spouse"; listDialog.List.ListModel = listModel; listDialog.Database = _database; listDialog.Record = e.Indi; listDialog.Modal = true; int response = listDialog.Run(); if (response == (int)Gtk.ResponseType.Apply) { if (listDialog.Record != e.Indi) { e.SelectedSpouse = listDialog.Record as GedcomIndividualRecord; e.Family = listModel.GetFamily(e.SelectedSpouse.XRefID); } } else if (response == (int)Gtk.ResponseType.Ok) { // Create new indi GedcomIndividualRecord indi = new GedcomIndividualRecord(_database); GedcomFamilyRecord fam = new GedcomFamilyRecord(_database, e.Indi, indi); e.SelectedSpouse = indi; e.Family = fam; } listDialog.Destroy(); }
protected void AppendFamily(GedcomFamilyRecord family, XmlNode root) { family.GenerateXML(root); }
/// <summary> /// Gets a "fake" family record that contains all of this individuals children. /// The record will only contain children /// </summary> /// <returns> /// A <see cref="GedcomFamilyRecord"/> /// </returns> public GedcomFamilyRecord GetAllChildren() { GedcomFamilyRecord fam = new GedcomFamilyRecord(); foreach (GedcomFamilyRecord famRec in _database.Families) { if (_XrefID == famRec.Husband || _XrefID == famRec.Wife) { foreach (string childID in famRec.Children) { fam.Children.Add(childID); } } } return fam; }
private GedcomIndividualRecord GetGedIndi(string indi, string family, string nKitNbr, string pre, string sex, GedcomIndividualRecord sindi=null,GedcomIndividualRecord schild=null) { if (htIndi.Contains(indi)) { foreach (GedcomIndividualRecord ggir in _gd1.Individuals) { try { if (ggir.XRefID.Equals(indi)) return ggir; } catch { } } return null; } else htIndi.Add(indi, indi); string fatherid = String.Empty; string motherid = String.Empty; string npre = "http://www.gedmatch.com/individual_detail.php?id_family=" + family + "&id_ged=" + indi; foreach (char ichar in Path.GetInvalidFileNameChars()) indi.Replace(ichar, '_'); GetHTML(npre, WorkIndiDir + family + "\\GM_INDI_" + nKitNbr + "_" + indi + ".html", pre); StreamReader reader = new StreamReader(WorkIndiDir + family + "\\GM_INDI_" + nKitNbr + "_" + indi + ".html"); string line = reader.ReadLine(); GedcomIndividualRecord record=null; GedcomFamilyRecord ngfr = null; bool union = false; while (line != null) { //Check for Name if (line.StartsWith("<br><font size=+3><b>")) { int ine = line.IndexOf("</b>"); int ige = line.IndexOf("'>"); int iborn = line.IndexOf("Born:"); int ib = line.IndexOf("</b>"); int ideath = line.IndexOf("Died:"); string name = line.Substring(21, ine - 21).Replace(" ", " ").Trim(); record = new GedcomIndividualRecord(_gd1); GedcomName gn = new GedcomName(); gn.Database = _gd1; gn.Split(name); gn.Level = 1; gn.PreferedName = true; record.Names.Add(gn); record.XRefID = indi; record.Sex = GedcomSex.Undetermined; if (sex.Equals("M")) { record.Sex = GedcomSex.Male; } if (sex.Equals("F")) { record.Sex = GedcomSex.Female; } try { string born = line.Substring(iborn + 11).Replace("<br>", "").Replace(" ", " ").Trim(); string death = string.Empty; if (ideath > 0) { born = line.Substring(iborn + 11, ideath - iborn - 11).Replace("<br>", "").Replace(" ", " ").Trim(); death = line.Substring(ideath); } try { GedcomDate bd = new GedcomDate(born); bd.Database = _gd1; bd.Date1 = born.Substring(0, born.IndexOf(",")); bd.Level = record.Level + 2; GedcomIndividualEvent gieb = new GedcomIndividualEvent(); gieb.Database = _gd1; gieb.Date = bd; //record.Birth.Date = bd; GedcomAddress gab = new GedcomAddress(); gab.Database = _gd1; gab.AddressLine = born.Substring(born.IndexOf(",") + 1); gieb.Address = gab; //record.Birth.Address = gab; gieb.EventType = GedcomEvent.GedcomEventType.BIRT; gieb.IndiRecord = record; gieb.Level = record.Level + 1; record.Events.Add(gieb); } catch { } if (death.Equals(string.Empty)) { GedcomDate dd = new GedcomDate(death); dd.Database = _gd1; dd.Date1 = death.Substring(0, death.IndexOf(",")); dd.Level = record.Level + 2; GedcomIndividualEvent gieb = new GedcomIndividualEvent(); gieb.Database = _gd1; gieb.Date = dd; //record.Birth.Date = bd; GedcomAddress gab = new GedcomAddress(); gab.Database = _gd1; gab.AddressLine = born.Substring(death.IndexOf(",") + 1); gieb.Address = gab; //record.Birth.Address = gab; gieb.EventType = GedcomEvent.GedcomEventType.DEAT; gieb.IndiRecord = record; gieb.Level = record.Level+1; record.Events.Add(gieb); } } catch {} //GedcomFamilyRecord ngfr=null; //if (sindi != null) //{ // ngfr = new GedcomFamilyRecord(_gd1, record, sindi); // //sindi.SpouseIn.Add( //} //if (schild != null) //{ // //GedcomFamilyLink gfl = new GedcomFamilyLink(); // //gfl.Database = _gd1; // if (ngfr != null) // { // //gfl.XRefID = ngfr.XRefID; // ngfr.AddChild(schild); // } // else // { // ngfr = new GedcomFamilyRecord(_gd1, record, null); // ngfr.AddChild(schild); // } //} } //Check for if (line.StartsWith("<br>Father: ")) { try { int ifam = line.IndexOf("id_family="); int ig = line.IndexOf("&id_ged"); int ige = line.IndexOf("'>"); if (ifam > 0 && ig > 0) { string nfamily = line.Substring(ifam + 10, ig - ifam - 10); string nindi = line.Substring(ig + 8, ige - ig - 8); GetGedIndi(nindi, nfamily, nKitNbr, npre, "M", null, record); } } catch { } } if (line.StartsWith("<br>Mother: ")) { try { int ifam = line.IndexOf("id_family="); int ig = line.IndexOf("&id_ged"); int ige = line.IndexOf("'>"); if (ifam > 0 && ig > 0) { string nfamily = line.Substring(ifam + 10, ig - ifam - 10); string nindi = line.Substring(ig + 8, ige - ig - 8); GetGedIndi(nindi, nfamily, nKitNbr, npre, "F", null, record); } int iss = line.IndexOf("<br>Union with:"); if (iss > 0) line = line.Substring(iss); } catch { } } //Check for Spouse if (line.StartsWith("<br>Union with:") || line.StartsWith("<br><br>Union with: ") || union) { int ifam = line.IndexOf("id_family="); int ig = line.IndexOf("&id_ged"); int ige = line.IndexOf("'>"); if (ifam > 0 && ig > 0) { string nfamily = line.Substring(ifam + 10, ig - ifam - 10); string nindi = line.Substring(ig + 8, ige - ig - 8); string nsex = "U"; if (sex.Equals("M")) { nsex = "F"; } if (sex.Equals("F")) { nsex = "M"; } GedcomIndividualRecord spouse = GetGedIndi(nindi, nfamily, nKitNbr, npre, nsex); //ToDo Figure out if we already created the family with OTHER spouse ngfr = new GedcomFamilyRecord(_gd1, record, spouse); union = false; } else union = true; } bool gotchild = false; while (line.StartsWith("<br>Children: ") || (gotchild && (line.StartsWith(" <a href='./individual")||line.StartsWith(" +<a href='./individual")))) { union = false; int ifam = line.IndexOf("id_family="); int ig = line.IndexOf("&id_ged"); int ige = line.IndexOf("'>"); if (ifam > 0 && ig > 0) { string nfamily = line.Substring(ifam + 10, ig - ifam - 10); string nindi = line.Substring(ig + 8, ige - ig - 8); string nsex = "U"; GedcomIndividualRecord child = GetGedIndi(nindi, nfamily, nKitNbr, npre, nsex); if (ngfr == null) { //Add child to Group } else { ngfr.AddChild(child); } line = reader.ReadLine(); } gotchild = true; } //Add Children line = reader.ReadLine(); } reader.Close(); return record; }
private void Parser_TagFound(object sender, EventArgs e) { _level = _Parser.Level; _xrefID = _Parser.XrefID; _tag = TagMap(_Parser.Tag); _lineValue = _Parser.LineValue; _lineValueType = _Parser.LineValueType; GedcomRecord current = null; // pop previous levels from the stack current = PopStack(_level); if (current == null) { switch (_tag) { case "FAM": // must have an xref id to have a family record // otherwise it can't be referenced anywhere if (!string.IsNullOrEmpty(_xrefID)) { current = new GedcomFamilyRecord(); } break; case "INDI": // must have an xref id to have an individual record // otherwise it can't be referenced anywhere if (!string.IsNullOrEmpty(_xrefID)) { current = new GedcomIndividualRecord(); } break; case "OBJE": // must have an xref id to have a multimedia record // otherwise it can't be referenced anywhere if (!string.IsNullOrEmpty(_xrefID)) { current = new GedcomMultimediaRecord(); } break; case "NOTE": // must have an xref id to have a note record // otherwise it can't be referenced anywhere if (!string.IsNullOrEmpty(_xrefID)) { GedcomNoteRecord note = new GedcomNoteRecord(); current = note; // set initial note text if needed if (_lineValueType == GedcomLineValueType.DataType) { note.ParsedText.Append(_lineValue); } else if (_lineValue != string.Empty) { // pointer to a note, this should not occur // as we should be at level 0 here Debug.WriteLine("Spurious Note pointer: " + _xrefID + "\t at level: " + _level); } } break; case "REPO": // must have an xref id to have a repository record // otherwise it can't be referenced anywhere if (!string.IsNullOrEmpty(_xrefID)) { current = new GedcomRepositoryRecord(); } break; case "SOUR": // must have an xref id to have a source record // otherwise it can't be referenced anywhere if (!string.IsNullOrEmpty(_xrefID)) { current = new GedcomSourceRecord(); } break; case "SUBM": // must have an xref id to have a submitter record // otherwise it can't be referenced anywhere if (!string.IsNullOrEmpty(_xrefID)) { current = new GedcomSubmitterRecord(); } break; case "HEAD": // header record current = new GedcomHeader(); break; case "SUBN": // Submission record if (!string.IsNullOrEmpty(_xrefID)) { current = new GedcomSubmissionRecord(); } break; case "TRLR": break; default: // Unknown tag Debug.WriteLine("Unknown: " + _tag + " at level: " + _level); break; } // if we created a new record push it onto the stack if (current != null) { if (!string.IsNullOrEmpty(_xrefID)) { current.XRefID = _xrefID; } current.Database = _ParseState.Database; current.Level = _level; _ParseState.Records.Push(current); } } else { switch (current.RecordType) { case GedcomRecordType.Header: ReadHeaderRecord(); break; case GedcomRecordType.Family: ReadFamilyRecord(); break; case GedcomRecordType.Individual: ReadIndividualRecord(); break; case GedcomRecordType.Multimedia: ReadMultimediaRecord(); break; case GedcomRecordType.Note: ReadNoteRecord(); break; case GedcomRecordType.Repository: ReadRepositoryRecord(); break; case GedcomRecordType.Source: ReadSourceRecord(); break; case GedcomRecordType.Submitter: ReadSubmitterRecord(); break; case GedcomRecordType.Submission: ReadSubmissionRecord(); break; // Non top level records case GedcomRecordType.Event: ReadEventRecord(); break; case GedcomRecordType.FamilyEvent: ReadEventRecord(); break; case GedcomRecordType.IndividualEvent: ReadEventRecord(); break; case GedcomRecordType.Place: ReadPlaceRecord(); break; case GedcomRecordType.SourceCitation: ReadSourceCitationRecord(); break; case GedcomRecordType.FamilyLink: ReadFamilyLinkRecord(); break; case GedcomRecordType.Association: ReadAssociationRecord(); break; case GedcomRecordType.Name: ReadNameRecord(); break; case GedcomRecordType.Date: ReadDateRecord(); break; case GedcomRecordType.RepositoryCitation: ReadRepositoryCitation(); break; case GedcomRecordType.CustomRecord: ReadEventRecord(); break; } } _ParseState.AddPreviousTag(_tag, _level); }
private void GotoParents(GedcomFamilyRecord fam) { if (fam != null) { SaveView(); GedcomIndividualRecord husb = null; GedcomIndividualRecord wife = null; ClearView(); if (!string.IsNullOrEmpty(fam.Husband)) { husb = _database[fam.Husband] as GedcomIndividualRecord; } if (!string.IsNullOrEmpty(fam.Wife)) { wife = _database[fam.Wife] as GedcomIndividualRecord; } if (husb != null) { _record = husb; _famRecord = fam; _wife = wife; FillView(); } else if (wife != null) { _record = wife; _famRecord = fam; _husband = husb; FillView(); } else { // FIXME hmm, no parents set, but got family, do what? } } }
protected virtual void OnWifeFamiliesButton_Clicked(object sender, System.EventArgs e) { SpouseSelectArgs args = new SpouseSelectArgs(); args.Indi = _wife; args.Spouse = _husband; SaveView(); if (SpouseSelect != null) { SpouseSelect(this,args); if (args.SelectedSpouse != null) { if (_record == _husband) { _record = args.SelectedSpouse; } _famRecord = args.Family; _husband = args.SelectedSpouse; FillView(); } } }
private void CreateSiblingEdges(GraphNode<GedcomIndividualRecord> node, GedcomFamilyRecord family) { GedcomIndividualRecord indi = node.Data; foreach (string childID in family.Children) { if (childID != indi.XRefID) { GedcomIndividualRecord child = _database[childID] as GedcomIndividualRecord; if (child != null) { GraphNode<GedcomIndividualRecord> sibling = new GraphNode<GedcomIndividualRecord>(); sibling.Data = child; node.Edges.Add(sibling); } else { System.Diagnostics.Debug.WriteLine("child in family points to non individual record"); } } } foreach (GraphNode<GedcomIndividualRecord> sibling in node.Edges) { sibling.Edges.Add(node); foreach (GraphNode<GedcomIndividualRecord> sibling2 in node.Edges) { if (sibling2 != sibling) { sibling.Edges.Add(sibling2); } } } }
private void CreateDecendantEdges(GraphNode<GedcomIndividualRecord> node, GedcomFamilyRecord family) { GedcomIndividualRecord indi = node.Data; foreach (string childID in family.Children) { // should never happen, best to check anyway if (childID != indi.XRefID) { GedcomIndividualRecord child = _database[childID] as GedcomIndividualRecord; if (child != null) { GraphNode<GedcomIndividualRecord> decendant = CreateNode(child, GraphType.Decendants); node.Edges.Add(decendant); } else { System.Diagnostics.Debug.WriteLine("child in family points to non individual record"); } } } }
private void CreateAncestorEdges(GraphNode<GedcomIndividualRecord> node, GedcomFamilyRecord family) { GedcomIndividualRecord husb = null; GedcomIndividualRecord wife = null; if (!string.IsNullOrEmpty(family.Husband)) { husb = _database[family.Husband] as GedcomIndividualRecord; if (husb == null) { System.Diagnostics.Debug.WriteLine("Husband points to non individual record"); } } if (!string.IsNullOrEmpty(family.Wife)) { wife = _database[family.Wife] as GedcomIndividualRecord; if (wife == null) { System.Diagnostics.Debug.WriteLine("Wife points to non individual record"); } } if (husb != null) { GraphNode<GedcomIndividualRecord> father = CreateNode(husb, GraphType.Ancestors); node.Edges.Add(father); } if (wife != null) { GraphNode<GedcomIndividualRecord> mother = CreateNode(wife, GraphType.Ancestors); node.Edges.Add(mother); } }