public DeleteIndividualDialog(GedcomIndividualRecord record)
		{
			this.Build();

			GedcomName name = record.GetName();
			
			AlertTextLabel.Markup = string.Format(AlertTextLabel.LabelProp, name.Name);
			
		}
		public GedcomFamilyRecord(GedcomDatabase database, GedcomIndividualRecord indi1, GedcomIndividualRecord indi2) : this()
		{
			Level = 0;
			Database = database;
			XRefID = database.GenerateXref("FAM");
			
			if (indi1 != null)
			{
				GedcomFamilyLink link = new GedcomFamilyLink();
				link.Database = database;
				link.Family = XRefID;
				link.Indi = indi1.XRefID;
				indi1.SpouseIn.Add(link);
				
				if (indi2 != null)
				{
					link = new GedcomFamilyLink();
					link.Database = database;
					link.Family = XRefID;
					link.Indi = indi2.XRefID;
					indi2.SpouseIn.Add(link);	
				}
				
				switch (indi1.Sex)
				{
					case GedcomSex.Female:
						Wife = indi1.XRefID;
						if (indi2 != null)
						{
							Husband = indi2.XRefID;
						}
						break;
					default:
						// got to put some where if not male or female,
						// go with same as male
						Husband = indi1.XRefID;
						if (indi2 != null)
						{
							Wife = indi2.XRefID;
						}
						break;
				}
			}
			
			database.Add(XRefID, this);
		}
Beispiel #3
0
		public static List<GedcomIndividualRecord> FindDuplicates(GedcomIndividualRecord indi, GedcomDatabase databaseB, float matchThreshold)
		{
			List<GedcomIndividualRecord> matches = new List<GedcomIndividualRecord>();
			
			foreach (GedcomIndividualRecord matchIndi in databaseB.Individuals)
			{
				// can't match self, databaseB could be the same database as indi.Database
				// so we can check this
				//if (matchIndi != indi)
				{
					float match = indi.IsMatch(matchIndi);
					
					if (match > matchThreshold)
					{
						matches.Add(matchIndi);	
						//System.Console.WriteLine(indi.Names[0].Name + " matches " + matchIndi.Names[0].Name + " at " + match + "%");
					}
				}
			}

			return matches;		
		}
Beispiel #4
0
		protected virtual void OnRemoveHusbandButton_Clicked(object sender, System.EventArgs e)
		{
			if (_husband != null)
			{
				SaveView();
				
				_famRecord.RemoveHusband(_husband);
				
				HusbandSpouseView.Record = null;
				
				_husband = null;
				
				// FIXME: check if there is anyone left in the family
			}
		}
Beispiel #5
0
	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();
	}
Beispiel #6
0
	protected virtual void OnNewIndividual_Activated (object sender, System.EventArgs e)
	{
		// Create new indi
		GedcomIndividualRecord indi = new GedcomIndividualRecord(_database);
			
		Record = indi;
		
		if (_currentView == SummaryViewView)
		{
			Gtk.RadioAction action = _viewActions[1] as Gtk.RadioAction;
			action.Activate();
		}
	}
		private void AppendIndividualDetails(GedcomIndividualRecord indi, XmlNode root, int generation)
		{
			if (!_processed.Contains(indi.XRefID))
			{
				_processed.Add(indi.XRefID);
							
				foreach (GedcomIndividualEvent indiEvent in indi.Events)
				{
					indiEvent.EventXRefID = _database.GenerateXref("EVENT");
					AppendEvent(indiEvent, root);	
					AppendSources(indiEvent, root);
				}
				AppendIndividual(indi, root);
								
				if (generation < _ancestorGenerations)
				{
					foreach (GedcomFamilyLink link in indi.ChildIn)
					{
						AppendFamilyDetails(link, root, generation + 1);
					}
				}
								
				if (generation > _decendantGenerations)
				{
					foreach (GedcomFamilyLink link in indi.SpouseIn)
					{
						AppendFamilyDetails(link, root, generation);
					}
				}
			}
		}
Beispiel #8
0
		private void FoundDuplicate(GedcomIndividualRecord indi, List<GedcomIndividualRecord> matches)
		{
			_duplicates.Add(indi.XRefID, matches);
		}
		public static int CompareByName(GedcomIndividualRecord indiA, GedcomIndividualRecord indiB)
		{
			int ret = -1;
			
			if (indiA != null && indiB != null)
			{
				string nameA;
				string nameB;

				GedcomName aName = indiA.GetName();
				GedcomName bName = indiB.GetName();

				if (aName != null)
				{
					nameA = aName.Name;
				}
				else
				{
					nameA = UnknownName;	
				}
				
				if (bName != null)
				{
					nameB = bName.Name;
				}
				else
				{
					nameB = UnknownName;	
				}
				
				ret = string.Compare(nameA,nameB);
			}
			else if (indiA != null)
			{
				ret = 1;	
			}
			
			return ret;
		}
		public bool AddChild(GedcomIndividualRecord indi)
		{
			bool added = false;
			
			if (indi != null && ! Children.Contains(indi.XRefID))
			{
				if (string.IsNullOrEmpty(XRefID))
				{
					XRefID = _database.GenerateXref("FAM");
					_database.Add(XRefID,this);						
				}
				
				if (!indi.ChildInFamily(XRefID))
				{
					GedcomFamilyLink link = new GedcomFamilyLink();
					link.Database = _database;
					link.Family = XRefID;
					link.Indi = indi.XRefID;
					link.Level = 1;
					indi.ChildIn.Add(link);
				}
				
				Children.Add(indi.XRefID);
				
				added = true;
			}
			
			return added;
		}
		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);
		}
Beispiel #12
0
        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("&nbsp;", " ").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("&nbsp;", " ").Trim();
                        string death = string.Empty;
                        if (ideath > 0)
                        {
                            born = line.Substring(iborn + 11, ideath - iborn - 11).Replace("<br>", "").Replace("&nbsp;", " ").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("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='./individual")||line.StartsWith("&nbsp;&nbsp;&nbsp;&nbsp;+<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;
        }
Beispiel #13
0
		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?
				}
			}	
		}
Beispiel #14
0
		private void FillView()
		{
			GedcomFamilyRecord fam = _famRecord;
			
			GedcomIndividualRecord husb = null;
			GedcomIndividualRecord wife = null;
			
			if (!string.IsNullOrEmpty(fam.Husband))
			{
				husb = _database[fam.Husband] as GedcomIndividualRecord;
				
				HusbandSpouseView.Record = husb;
			}
			else
			{
				HusbandSpouseView.Record = null;
			}
			
			if (!string.IsNullOrEmpty(fam.Wife))
			{
				wife = _database[fam.Wife] as GedcomIndividualRecord;
				
				WifeSpouseView.Record = wife;
			}
			else
			{
				WifeSpouseView.Record = null;
			}
			
			MarriageView.Record = fam;
			
			_childrenListModel = new ChildrenListModel();
			_childrenListModel.Database = _database;
			_childrenListModel.Record = fam;
			
			ChildrenTreeView.Model = _childrenListModel.Adapter;
			
			_husband = husb;
			_wife = wife;			
		}
Beispiel #15
0
		protected virtual void OnRemoveWifeButton_Clicked(object sender, System.EventArgs e)
		{
			if (_wife != null)
			{
				SaveView();
				
				_famRecord.RemoveWife(_wife);
				
				WifeSpouseView.Record = null;	
				
				_wife = null;
				
				// FIXME: check if there is anyone left in the family	
			}
		}
Beispiel #16
0
		private void Rebuild(Gtk.Table table, uint[][][] positions, GedcomIndividualRecord activePerson, GedcomFamilyLink[] lst)
		{
			foreach (Gtk.Widget child in table.Children)
			{
				child.Destroy();
			}
			table.Resize(1,1);
			
			uint xmax = 0;
			uint ymax = 0;
			
			for (int i = 0; i < positions.Length; i ++)
			{
				uint x = positions[i][0][0] + 1;
				uint y = positions[i][0][1] + 1;
				uint w = positions[i][0][2];
				uint h = positions[i][0][3];
				
				GedcomFamilyLink famLink = (GedcomFamilyLink)lst[i];
				if (famLink == null)
				{	
					PedigreeBox pw = new PedigreeBox(null, 0, null);
					
					if (i > 0 && lst[((i+1)/2)-1] != null)
					{
						GedcomFamilyLink missingFamLink = (GedcomFamilyLink)lst[((i+1)/2)-1];
						
						// missing parent button
						pw.ForceMouseOver = true;
					}
					// FIXME: both conditions do the same thing, double checking
					// the gramps code it doesn't appear to be a mistake in porting
					if (positions[i][0][2] > 1)
					{
						table.Attach(pw,x, x+w, y, y+h, Gtk.AttachOptions.Fill, Gtk.AttachOptions.Fill, 0, 0);
					}
					else
					{
						table.Attach(pw,x, x+w, y, y+h, Gtk.AttachOptions.Fill, Gtk.AttachOptions.Fill, 0, 0);
					}
					
					xmax = (uint)Math.Max(xmax, x + w);
					ymax = (uint)Math.Max(ymax, y + h);
				}
				else
				{
					GedcomIndividualRecord indi = (GedcomIndividualRecord)_database[famLink.Indi];
					
					if (_showImages && i < ((positions.Length - 1) / 2) && positions[i][0][3] > 1)
					{
						
					}
					
					PedigreeBox pw = new PedigreeBox(indi, positions[i][0][3], null);
					pw.SelectIndividual += PedigreeBox_SelectIndividual;
					
					if (positions[i][0][3] < 7)
					{
						pw.TooltipMarkup = pw.FormatPerson(11, true);
					}
					
					if (positions[i][0][2] > 1)
					{
						table.Attach(pw, x, x+w, y, y+h, Gtk.AttachOptions.Expand | Gtk.AttachOptions.Fill, Gtk.AttachOptions.Expand | Gtk.AttachOptions.Fill, 0, 0);
					}
					else
					{
						table.Attach(pw, x, x+w, y, y+h, Gtk.AttachOptions.Fill, Gtk.AttachOptions.Fill, 0, 0);
					}
					
					xmax = (uint)Math.Max(xmax, x + w);
					ymax = (uint)Math.Max(ymax, y + h);
				}
				
				// connection lines
				if (positions[i].Length > 1)
				{
					// separate boxes for father and mother
					x = positions[i][1][0] + 1;
					y = positions[i][1][1] + 1;
					w = 1;
					h = positions[i][1][2];
					
					Gtk.DrawingArea line = new Gtk.DrawingArea();
					line.ExposeEvent += Line_Expose;
					bool rela = false;
					if (famLink != null && (famLink.Pedigree == PedegreeLinkageType.Birth || famLink.Pedigree == PedegreeLinkageType.Unknown))
					{
						line.AddEvents((int)Gdk.EventMask.ButtonPressMask);
						rela = true;
					}
					Utility.Pair<int, bool> lineData = new Pair<int,bool>();
					lineData.First = i * 2 + 1;
					lineData.Second = rela;
					_lines[line] = lineData;
					
					table.Attach(line, x, x + w, y, y + h, Gtk.AttachOptions.Fill, Gtk.AttachOptions.Fill, 0, 0);
					
					xmax = (uint)Math.Max(xmax, x + w);
					ymax = (uint)Math.Max(ymax, y + h);
					
					x = positions[i][2][0] + 1;
					y = positions[i][2][1] + 1;
					w = 1;
					h = positions[i][2][2];
					
					line = new Gtk.DrawingArea();
					line.ExposeEvent += Line_Expose;
					rela = false;
					if (famLink != null && (famLink.Pedigree == PedegreeLinkageType.Birth || famLink.Pedigree == PedegreeLinkageType.Unknown))
					{
						line.AddEvents((int)Gdk.EventMask.ButtonPressMask);
						rela = true;
					}
					lineData = new Pair<int,bool>();
					lineData.First = i * 2 + 2;
					lineData.Second = rela;
					_lines[line] = lineData;
					
					table.Attach(line, x, x + w, y, y + h, Gtk.AttachOptions.Fill, Gtk.AttachOptions.Fill, 0, 0);
					
					xmax = (uint)Math.Max(xmax, x + w);
					ymax = (uint)Math.Max(ymax, y + h);
				}
				
				// marriage data
				if (_showMarriageData && positions[i].Length > 3)
				{
					string  text = string.Empty;
					if (famLink != null && (famLink.Pedigree == PedegreeLinkageType.Birth || famLink.Pedigree == PedegreeLinkageType.Unknown))
					{
						text = "foo";
					}
					Gtk.Label label = new Gtk.Label(text);
					label.Justify = Gtk.Justification.Left;
					label.LineWrap = true;
					label.SetAlignment(0.1F, 0.5F);
					
					x = positions[i][3][0] + 1;
					y = positions[i][3][1] + 1;
					w = positions[i][3][2];
					h = positions[i][3][3];
					
					table.Attach(label, x, x + w, y, y + h, Gtk.AttachOptions.Fill, Gtk.AttachOptions.Fill, 0, 0);
				}
			}
			
			// nav arrows
			if (lst[0] != null)
			{
				Gtk.Button arrowButton = new Gtk.Button();
				arrowButton.Add(new Gtk.Arrow(Gtk.ArrowType.Left, Gtk.ShadowType.In));
				
				arrowButton.Sensitive = (_dummyFam.Children.Count > 0);
				arrowButton.Clicked += ArrowButton_Click;
				if (arrowButton.Sensitive)
				{
					arrowButton.TooltipText = "Jump to child...";
				}
				
				uint ymid = (uint)Math.Floor(ymax / 2.0F);
				table.Attach(arrowButton, 0, 1, ymid, ymid + 1, 0, 0, 0, 0);
				
				// father
				arrowButton = new Gtk.Button();
				arrowButton.Add(new Gtk.Arrow(Gtk.ArrowType.Right, Gtk.ShadowType.In));
				arrowButton.Sensitive = (lst[1] != null);
				arrowButton.Clicked += FatherButton_Click;
				if (arrowButton.Sensitive)
				{
					arrowButton.TooltipText = "Jump to father";
				}
				
				ymid = (uint)Math.Floor(ymax / 4.0F);
				table.Attach(arrowButton, xmax, xmax + 1, ymid - 1, ymid + 2, 0, 0, 0, 0);
				
				// mother
				arrowButton = new Gtk.Button();
				arrowButton.Add(new Gtk.Arrow(Gtk.ArrowType.Right, Gtk.ShadowType.In));
				arrowButton.Sensitive = (lst[2] != null);
				arrowButton.Clicked += MotherButton_Click;
				if (arrowButton.Sensitive)
				{
					arrowButton.TooltipText = "Jump to mother";
				}
				
				ymid = (uint)Math.Floor(ymax / 4.0F * 3);
				table.Attach(arrowButton, xmax, xmax + 1, ymid - 1, ymid + 2, 0, 0, 0, 0);
				
				
				// dummy widgets to allow pedigree to be centred
				Gtk.Label l = new Gtk.Label(string.Empty);
				table.Attach(l, 0, 1, 0, 1, Gtk.AttachOptions.Expand | Gtk.AttachOptions.Fill, Gtk.AttachOptions.Expand | Gtk.AttachOptions.Fill, 0, 0);
				l = new Gtk.Label(string.Empty);
				table.Attach(l, xmax, xmax + 1, ymax, ymax + 1, Gtk.AttachOptions.Expand | Gtk.AttachOptions.Fill, Gtk.AttachOptions.Expand | Gtk.AttachOptions.Fill, 0, 0);
	
				table.ShowAll();
			}
		}	
Beispiel #17
0
        /// <summary>
        /// Add the given individual to the surnames list
        /// </summary>
        /// <param name="indi">
        /// A <see cref="GedcomIndividualRecord"/>
        /// </param>
        protected virtual void BuildSurnameList(GedcomIndividualRecord indi)
        {
            foreach (GedcomName name in indi.Names)
            {
                // FIXME: not right, need to include prefix + suffix
                string surname = name.Surname;

                if (!_surnames.ContainsKey(surname))
                {
                    _surnames[surname] = 1;
                }
                else
                {
                    _surnames[surname] = 1 + (int)_surnames[surname];
                }
            }
        }
		public GedcomIndividualRecord AddNewChild()
		{
			GedcomIndividualRecord husband = null; 
			GedcomIndividualRecord wife = null;
			
			if (!string.IsNullOrEmpty(_Husband))
			{
				husband = _database[_Husband] as GedcomIndividualRecord;
			}
			if (!string.IsNullOrEmpty(_Wife))
			{
				wife = _database[_Wife] as GedcomIndividualRecord;
			}
			
			string surname = "unknown";
			
			if (husband != null)
			{
				GedcomName husbandName = husband.GetName();
				if (husbandName != null)
				{
					surname = husbandName.Surname;
				}
			}
			else if (wife != null)
			{
				GedcomName wifeName = wife.GetName();
				if (wifeName != null)
				{
					surname = wifeName.Surname;
				}
			}
			
			GedcomIndividualRecord indi = new GedcomIndividualRecord(_database, surname);
						
			// don't care about failure here, won't happen as indi isn't null
			// and they aren't already in the family
			AddChild(indi);
			
			return indi;
		}
		// % match
		public float IsMatch(GedcomIndividualRecord indi)
		{
			float match = 0F;
			
			// check name
			float nameMatch = 0F;
			foreach (GedcomName indiName in indi.Names)
			{
				foreach (GedcomName name in Names)
				{
					float currentNameMatch = name.IsMatch(indiName);
		
					nameMatch = Math.Max(nameMatch, currentNameMatch);
				}
			}

			// 0% name match would be pointless checking other details			
			if (nameMatch != 0)
			{			
				// check gender
                //float genderMatch = 0;
                //if (Sex == indi.Sex)
                //{
                //    genderMatch = 100.0F;
                //}
				
				// check dob
				float dobMatch = 0F;
				GedcomEvent birth = Birth;
				GedcomEvent indiBirth = indi.Birth;
				if (birth != null && indiBirth != null)
				{
					dobMatch = birth.IsDateMatch(indiBirth);
				}
				else //if (birth == null && indiBirth == null)
				{
					dobMatch = 100.0F;
				}
				
			
				// check dod
				float dodMatch = 0F;
				GedcomEvent death = Death;
				GedcomEvent indiDeath = indi.Death;
				if (death != null && indiDeath != null)
				{
					dodMatch = death.IsMatch(indiDeath);
                    //If Death Date is equal then that is good also. Give it some boost
                    if (dobMatch < dodMatch)
                        dobMatch = dodMatch;
				}
				else //if (death == null && indiDeath == null)
				{
					dodMatch = 100.0F;
				}
				
				// check parents ?
				
				//System.Console.WriteLine("name: " + nameMatch + "\tdob: " + dobMatch + "\tdod: " + dodMatch);
								
				//match = (nameMatch + genderMatch + dobMatch + dodMatch) / 4.0F;
                match = (nameMatch + dobMatch * 0.1F) / 1.1F;
			}
						
						
			return match;
		}
		public void RemoveChild(GedcomIndividualRecord child)
		{
			Children.Remove(child.XRefID);
					
			GedcomFamilyLink link;
			if (child.ChildInFamily(XRefID, out link))
			{
				child.ChildIn.Remove(link);
			}	
		}
Beispiel #21
0
		protected virtual void OnDuplicateList_RecordChanged(object sender, EventArgs e)
		{
			_indi = (GedcomIndividualRecord)DuplicateList.Record;
			
			DetailsBox.Sensitive = (_indi != null);
			
			int matches = 0;
			_matches = null;
			_currentMatch = 0;
			
			float percent = 0;
			
			if (_indi != null)
			{
				_matches = (List<GedcomIndividualRecord>)_duplicates[_indi.XRefID];
				matches = _matches.Count;
				_currentMatch = 1;
				PersonBDuplicateView.Record = _matches[0];
				
				percent = _indi.IsMatch(_matches[0]); 
				
				BackButton.Sensitive = false;
				ForwardButton.Sensitive = (matches > 1);
			}
			
			DuplicatesLabel.Text = string.Format("Potential Duplicate {0} of {1}: {2}%", _currentMatch, matches, percent);
			
			PersonADuplicateView.Record = _indi;
		}
		public void ChangeWife(GedcomIndividualRecord indi)
		{
			GedcomIndividualRecord husband = null; 
			GedcomIndividualRecord wife = null;
			
			if (!string.IsNullOrEmpty(_Husband))
			{
				husband = _database[_Husband] as GedcomIndividualRecord;
			}
			if (!string.IsNullOrEmpty(_Wife))
			{
				wife = _database[_Wife] as GedcomIndividualRecord;
			}
			
			if (string.IsNullOrEmpty(XRefID))
			{
				XRefID = _database.GenerateXref("FAM");
				_database.Add(XRefID,this);
			}
			
			if (wife != null)
			{
				GedcomFamilyLink link;
				if (wife.SpouseInFamily(XRefID,out link))
				{
					wife.SpouseIn.Remove(link);	
				}
			}
			
			wife = indi;
			_Wife = string.Empty;
			
			if (husband != null)
			{
				_Husband = husband.XRefID;
				
				if (!husband.SpouseInFamily(XRefID))
				{						
					GedcomFamilyLink link = new GedcomFamilyLink();
					link.Database = _database;
					link.Family = XRefID;
					link.Indi = _Husband;
					husband.SpouseIn.Add(link);
				}	
			}
			
			if (wife != null)
			{
				_Wife = wife.XRefID;
				
				if (!wife.SpouseInFamily(XRefID))
				{						
					GedcomFamilyLink link = new GedcomFamilyLink();
					link.Database = _database;
					link.Family = XRefID;
					link.Indi = _Wife;
					wife.SpouseIn.Add(link);
				}	
			}	
		}
Beispiel #23
0
		protected override bool Filter(GedcomIndividualRecord indi)
		{
			return ((indi == null) || _spouses.Contains(indi.XRefID));	
		}
		public void RemoveWife(GedcomIndividualRecord indi)
		{
			GedcomFamilyLink link;
			
			if (_Wife == indi.XRefID)
			{
				_Wife = string.Empty;	
			}
			
			if (indi.SpouseInFamily(XRefID, out link))
			{
				indi.SpouseIn.Remove(link);
			}
		}
Beispiel #25
0
	protected virtual void OnNewDatabase_Activated(object sender, System.EventArgs e)
	{
		GedcomDatabase database;
		
		database = new GedcomDatabase();
		
		// create an initial person as we need one to work properly
		GedcomIndividualRecord indi = new GedcomIndividualRecord(database);
		
		database.Name = "Unsaved";
		
		SetGedcomDatabase(database);
	}
		protected void AppendIndividual(GedcomIndividualRecord indi, XmlNode root)
		{
			indi.GenerateXML(root);
		}
Beispiel #27
0
	protected void OnListIndividuals_Response(object sender, Gtk.ResponseArgs e)
	{
		IndividualListDialog listDialog = sender as IndividualListDialog;
		bool selected = false;
		
		if (e.ResponseId == Gtk.ResponseType.Apply)
		{
			if (listDialog.Record != null)
			{
				Record = listDialog.Record;
				selected = true;
			}
			
		}
		else if (e.ResponseId == Gtk.ResponseType.Ok)
		{
			// Create new indi
			GedcomIndividualRecord indi = new GedcomIndividualRecord(_database);
			
			Record = indi;
			selected = true;
		}
		
		listDialog.Destroy();
		
		if (_currentView == SummaryViewView && selected)
		{
			Gtk.RadioAction action = _viewActions[1] as Gtk.RadioAction;
			action.Activate();
		}
	}
Beispiel #28
0
		private void FindTree(GedcomIndividualRecord indi, int i, int depth, GedcomFamilyLink[] lst)
		{
			if (depth <= 5 && indi != null)
			{				
				List<GedcomFamilyLink> families = indi.ChildIn;
				if (families == null || families.Count == 0)
				{
					// indi doesn't exist as a child in any family, create
					// a dummy link record
					GedcomFamilyLink famLink = new GedcomFamilyLink();
					famLink.Indi = indi.XRefID;
					famLink.Pedigree = PedegreeLinkageType.Unknown;
					famLink.Database = _database;
					lst[i] = famLink;
				}
				else
				{
					GedcomFamilyLink famLink = families[0];
										
					lst[i] = famLink;
					
					GedcomFamilyRecord famRec = (GedcomFamilyRecord)_database[famLink.Family];
					
					if (!string.IsNullOrEmpty(famRec.Husband))
					{
						indi = (GedcomIndividualRecord)_database[famRec.Husband];
						FindTree(indi, (2*i)+1, depth + 1, lst);
					}
					if (!string.IsNullOrEmpty(famRec.Wife))
					{
						indi = (GedcomIndividualRecord)_database[famRec.Wife];
						FindTree(indi, (2*i)+2, depth + 1, lst);
					}
				}
			}
		}
Beispiel #29
0
	protected void OnSelectNewSpouse(object sender, IndividualArgs e)
	{
		IndividualListDialog listDialog = new IndividualListDialog();
		
		IndividualListModel listModel = new IndividualListModel();
		
		if (sender is Gtk.Dialog)
		{
			listDialog.TransientFor = (Gtk.Window)sender;
		}
		else
		{
			listDialog.TransientFor = this;
		}
		
		listModel.Database = _database;
		
		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)
		{
			e.Indi = listDialog.Record as GedcomIndividualRecord;	
		}
		else if (response == (int)Gtk.ResponseType.Ok)
		{
			// Create new indi
			GedcomIndividualRecord indi = new GedcomIndividualRecord(_database);
			
			e.Indi = indi;
		}
		
		listDialog.Destroy();
	}
Beispiel #30
0
		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();
				}
			}
		}