Esempio n. 1
0
	protected virtual void OnFamilyGroupSheetReportWebPage_Activated(object sender, System.EventArgs e)
	{
		if (_currentView != null)
		{
			_currentView.SaveView();
				
			// view may have changed the record so get what the view thinks
			// the current record is
			_record = _currentView.Record;
		}
		
		GedcomIndividualReport report = new GedcomIndividualReport();
		
		report.Database = _database;
		report.Record = _record;
		report.AncestorGenerations = 1; // need to get the parents of the father/mother
		report.DecendantGenerations = - 2; // need 2 rather than 1 to pull in spouse for children
		report.BaseXsltName = "FamilyGroupReport";
		
		GedcomIndividualRecord indi = _record as GedcomIndividualRecord;
		if (indi != null)
		{
			GedcomFamilyRecord fam = indi.GetFamily();
			if (fam != null)
			{
				report.XrefID = fam.XRefID;
			}
		}
		
		string filename = report.CreateReport();
		
		FileSelectorDialog fileSelector = new FileSelectorDialog();
		fileSelector.Title = "Save Family Group Sheet Report As...";
		fileSelector.AddFilter("text/html", "HTML Files");
		fileSelector.AddFilter("application/pdf", "PDF Files");
		fileSelector.AddFilter("image/svg+xml", "SVG Files");
		fileSelector.SaveDialog = true;
		fileSelector.FileSelected += new EventHandler(ReportSave_FileSelected);
		fileSelector.UserData = filename;
		
		fileSelector.Run();
	}
Esempio n. 2
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();
		}
	}
Esempio n. 3
0
	protected virtual void OnWifesParents_Activated(object sender, System.EventArgs e)
	{
		GedcomIndividualRecord indi = _currentView.Wife;
		
		if (indi != null && indi.ChildIn.Count > 0)
		{
			GedcomFamilyLink link = indi.ChildIn[0];
			GedcomFamilyRecord fam = _database[link.Family] as GedcomFamilyRecord;
			if (fam != null)
			{
				if (!string.IsNullOrEmpty(fam.Husband))
				{
					indi = _database[fam.Husband] as GedcomIndividualRecord;		
				}
				else if (!string.IsNullOrEmpty(fam.Wife))
				{
					indi = _database[fam.Husband] as GedcomIndividualRecord;
				}
				else
				{
					// shouldn't be here
					throw new Exception("Family with no husband or wife");
				}
				
				if (indi != null)
				{
					Record = indi;	
				}
				else
				{
					System.Diagnostics.Debug.WriteLine("Husband/Wife in family points to non individual record");
				}
			}
			else
			{
				System.Diagnostics.Debug.WriteLine("Family link points to non family record");	
			}
		}
	}
Esempio n. 4
0
	protected virtual void OnDecendantsReportWebPage_Activated(object sender, System.EventArgs e)
	{
		if (_currentView != null)
		{
			_currentView.SaveView();
				
			// view may have changed the record so get what the view thinks
			// the current record is
			_record = _currentView.Record;
		}
		
		GedcomIndividualReport report = new GedcomIndividualReport();
		
		report.Database = _database;
		report.Record = _record;
		report.DecendantGenerations = - int.MaxValue;
		report.BaseXsltName = "Descendants";
		
		string filename = report.CreateReport();
		
		FileSelectorDialog fileSelector = new FileSelectorDialog();
		fileSelector.Title = "Save Decendants Report As...";
		fileSelector.AddFilter("text/html", "HTML Files");
		fileSelector.AddFilter("application/pdf", "PDF Files");
		fileSelector.AddFilter("image/svg+xml", "SVG Files");
		fileSelector.SaveDialog = true;
		fileSelector.FileSelected += new EventHandler(ReportSave_FileSelected);
		fileSelector.UserData = filename;
		
		fileSelector.Run();
	}
Esempio n. 5
0
	protected void OnDeleteIndividual(object sender, IndividualArgs e)
	{
		DeleteIndividualDialog deleteDialog = new DeleteIndividualDialog(e.Indi);
		
		if (sender is Gtk.Dialog)
		{
			deleteDialog.TransientFor = (Gtk.Window)sender;
		}
		else
		{
			deleteDialog.TransientFor = this;
		}
		
		deleteDialog.Modal = true;
		
		switch (deleteDialog.Run())
		{
			case (int)Gtk.ResponseType.Ok:
				e.Indi.Delete();
				
				// FIXME: select new individual
				if (e.Indi == _record)
				{
					_record = _database.Individuals[0];
					if (_currentView != null)
					{
						_currentView.Record = _record;
					}
				}
				// or just refresh the current view
				else
				{
					RefreshView();
				}
				break;
		}
		deleteDialog.Destroy();
	}
Esempio n. 6
0
		protected virtual void OnAddWifeButton_Clicked(object sender, System.EventArgs e)
		{
			if (SelectNewSpouse != null)
			{
				SaveView();
								
				IndividualArgs args = new IndividualArgs();
				SelectNewSpouse(this, args);
				
				if (args.Indi != null)
				{				
					if (_wife == _record)
					{
						_record = args.Indi;	
					}
					
					_famRecord.ChangeWife(args.Indi);
				}
								
				FillView();
			}
		}
Esempio n. 7
0
		/// <summary>
		/// Add the given record to the database with the given XRef
		/// </summary>
		/// <param name="xrefID">
		/// A <see cref="System.String"/>
		/// </param>
		/// <param name="record">
		/// A <see cref="GedcomRecord"/>
		/// </param>
		public virtual void Add(string xrefID, GedcomRecord record)
		{	
			_Table.Add(xrefID,record);
			
			if (record is GedcomIndividualRecord)
			{
                GedcomIndividualRecord indi = (GedcomIndividualRecord)record;

				int pos = _Individuals.BinarySearch(indi);
				if (pos < 0)
				{
					pos = ~pos;
				}
				_Individuals.Insert(pos, indi);
			}
			else if (record is GedcomFamilyRecord)
			{
				_Families.Add((GedcomFamilyRecord)record);	
			}
			else if (record is GedcomSourceRecord)
			{
				GedcomSourceRecord source = (GedcomSourceRecord)record;
				
				int pos = _Sources.BinarySearch(source);
				if (pos < 0)
				{
					pos = ~pos;
				}
				_Sources.Insert(pos, source);	
			}
			else if (record is GedcomRepositoryRecord)
			{
				GedcomRepositoryRecord repo = (GedcomRepositoryRecord)record;
				
				int pos = _Repositories.BinarySearch(repo);
				if (pos < 0)
				{
					pos = ~pos;
				}
				_Repositories.Insert(pos, repo);
			}
			else if (record is GedcomMultimediaRecord)
			{
				_Media.Add((GedcomMultimediaRecord)record);
			}
			else if (record is GedcomNoteRecord)
			{
				_Notes.Add((GedcomNoteRecord)record);
			}
			else if (record is GedcomSubmitterRecord)
			{
				_Submitters.Add((GedcomSubmitterRecord)record);
			}
			
			record.Database = this;
		}
Esempio n. 8
0
	private void RefreshView()
	{
		// force refresh of current, FIXME: yuk
		GedcomRecord rec;
		
		// current view may have switch record
		if (_currentView != null)
		{
			rec = _currentView.Record;	
		}
		else
		{
			rec = _record;	
		}
		
		_record = null;
		Record = rec;	
	}
Esempio n. 9
0
		private void AddMultimediaRecord(GedcomRecord record)
		{
			if (_lineValueType == GedcomLineValueType.PointerType)
			{
				record.Multimedia.Add(_lineValue);	
				_missingReferences.Add(_lineValue);
			}
			else
			{
				GedcomMultimediaRecord multimedia = new GedcomMultimediaRecord();
				multimedia.Level = 0; // new top level multimedia, always 0
				multimedia.ParsingLevel = _level;
				multimedia.XRefID = Database.GenerateXref("OBJE");
											
				record.Multimedia.Add(multimedia.XRefID);
				_ParseState.Records.Push(multimedia);
			}
		}
Esempio n. 10
0
		private string AddSubmitterRecord(GedcomRecord record)
		{
			string xref;
			
			if (_lineValueType == GedcomLineValueType.PointerType)
			{
				xref = _lineValue;
				_missingReferences.Add(xref);
			}
			else
			{
				GedcomSubmitterRecord submitter = new GedcomSubmitterRecord();
				submitter.Level = 0; // always level 0
				submitter.ParsingLevel = _level + 1;
				submitter.XRefID = Database.GenerateXref("S");
				_ParseState.Records.Push(submitter);

				xref = submitter.XRefID;
			}
			
			return xref;
		}
Esempio n. 11
0
		private string AddNoteRecord(GedcomRecord record)
		{
			string xref = string.Empty;
			
			if (_lineValueType == GedcomLineValueType.PointerType)
			{
				if (!_removedNotes.Contains(_lineValue))
				{
					record.Notes.Add(_lineValue);
					xref = _lineValue;
					_missingReferences.Add(_lineValue);
				}
			}
			else
			{
				GedcomNoteRecord note = new GedcomNoteRecord();
				note.Level = 0; // new top level note, always 0 (not true, 1 in header, fixed up later)
				note.ParsingLevel = _level;
				note.XRefID = Database.GenerateXref("NOTE");
				
				if (_lineValue != string.Empty)
				{
					note.ParsedText.Append(_lineValue);
				}
				
				_ParseState.Records.Push(note);
				
				record.Notes.Add(note.XRefID);
				xref = note.XRefID;
			}	
			
			return xref;
		}
Esempio n. 12
0
		private void AddSourceCitation(GedcomRecord record)
		{
			GedcomSourceCitation sourceCitation = new GedcomSourceCitation();
			sourceCitation.Level = _level;
			sourceCitation.Database = _ParseState.Database;
		
			if (_lineValueType == GedcomLineValueType.PointerType)
			{
				sourceCitation.Source = _lineValue;	
				_missingReferences.Add(_lineValue);
			}
			else
			{
				GedcomSourceRecord source = new GedcomSourceRecord();
				source.Level = 0; // new top level source, always 0
				source.ParsingLevel = _level;
				source.XRefID = Database.GenerateXref("SOUR");
				
				if (_lineValue != string.Empty)
				{
					source.Title = _lineValue;	
				}
				
				sourceCitation.Source = source.XRefID;
				
				_ParseState.Database.Add(source.XRefID,source);
			}
			
			record.Sources.Add(sourceCitation);
			_ParseState.Records.Push(sourceCitation);
			
			_sourceCitations.Add(sourceCitation);
		}
Esempio n. 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?
				}
			}	
		}
Esempio n. 14
0
	private void DoSwitchPage(uint pageNum, bool toggleAction)
	{
		if (pageNum >= 0)
		{
			if (_currentView != null)
			{
				_currentView.SaveView();
				
				// view may have changed the record so get what the view thinks
				// the current record is
				_record = _currentView.Record;
			}
			
			// make views that don't go off the current individual record
			// to update when we switch tabs
			SourceViewView.SaveView();
			RepositoryViewView.SaveView();
			// FIXME: as multimedia objects can be edited via the scrapbook dialog
			// saving all the time here isn't right as the record may have changed
			MultimediaViewView.SaveView();
		
			// same as above but for notes
			NotesViewView.Save();
			
			// _currentView is only for gedcom views
			// we have other views such as source view, multimedia view etc.
			// which while part of the gedcom file don't represent an
			// individual or family
			if (pageNum < _views.Length)
			{
				IGedcomView view = _views[pageNum];
				
				view.Database = _database;
				view.Record = _record;
				
				_currentView = view;			
			}
			
			switch (pageNum)
			{
			
				case PedigreePage:
					// FIXME: yuk
					
					PedigreeViewView.Database = _database;
					PedigreeViewView.Record = _record;
					_currentView = PedigreeViewView;
					break;
				case SourcesPage:
					SourceViewView.Sensitive = (SourceViewView.Record != null); 
					break;
				case RepositoryPage:
					RepositoryViewView.Sensitive = (RepositoryViewView.Record != null);
					break;
				case MultimediaPage:
					MultimediaViewView.Sensitive = (MultimediaViewView.Record != null);
					break;
				case DuplicatesPage:
					// page 7 is for duplicates, it doesn't
					// take a record at all, so set _currentView to null
					this.DuplicateViewView.DatabaseA = _database;
					this.DuplicateViewView.DatabaseB = _database;
					_currentView = null;
					break;
				case NotePage:
					NotesViewView.Sensitive = (NotesViewView.Record != null);
					break;
			}
			
			// FIXME: yuk
			if (pageNum != DuplicatesPage && toggleAction)
			{
				Gtk.RadioAction action = _viewActions[pageNum] as Gtk.RadioAction;
				action.Activate();
			}
		}
	}
Esempio n. 15
0
		/// <summary>
		/// Remove the given record with the given XRef from the database
		/// </summary>
		/// <param name="xrefID">
		/// A <see cref="System.String"/>
		/// </param>
		/// <param name="record">
		/// A <see cref="GedcomRecord"/>
		/// </param>
		internal virtual void Remove(string xrefID, GedcomRecord record)
		{
			if (_Table.Contains(xrefID))
			{
				_Table.Remove(xrefID);
				
				if (record is GedcomIndividualRecord)
				{
                    GedcomIndividualRecord indi = (GedcomIndividualRecord)record;

					_Individuals.Remove(indi);
					
					// remove names from surname cache
                    foreach (GedcomName name in indi.Names)
                    {
                        // FIXME: not right, need to include prefix + suffix
                        string surname = name.Surname;

                        if (_surnames.ContainsKey(surname))
                        {
                            int count = (int)_surnames[surname];
                            count--;
                            if (count > 0)
                            {
                                _surnames[surname] = count;
                            }
                            else
                            {
                                _surnames.Remove(surname);
                            }
                        }
                    }
				}
				else if (record is GedcomFamilyRecord)
				{
					_Families.Remove((GedcomFamilyRecord)record);	
				}
				else if (record is GedcomSourceRecord)
				{
					_Sources.Remove((GedcomSourceRecord)record);	
				}
				else if (record is GedcomRepositoryRecord)
				{
					_Repositories.Remove((GedcomRepositoryRecord)record);	
				}
				else if (record is GedcomMultimediaRecord)
				{
					_Media.Remove((GedcomMultimediaRecord)record);
				}
				else if (record is GedcomNoteRecord)
				{
					_Notes.Remove((GedcomNoteRecord)record);
				}
				else if (record is GedcomSubmitterRecord)
				{
					_Submitters.Remove((GedcomSubmitterRecord)record);
				}
				
				// FIXME: should we set this to null? part of the deletion
				// methods may still want to access the database
				//record.Database = null;
			}
		}
Esempio n. 16
0
	private void SetGedcomDatabase(GedcomDatabase database)
	{
		_database = null;
		_record = null;
	
		_database = database;
			
		_record = _database.Individuals[0];
				
		if (_currentView != null)
		{
			_currentView.Database = _database;
					
			_currentView.Record = _record;
		}
		
		ViewNotebook.Sensitive = true;
		Merge.Sensitive = true;
		Save.Sensitive = true;
		SaveAs.Sensitive = true;
		PropertiesAction.Sensitive = true;
		
		// get all report related actions, make sensitive
		foreach (Gtk.Action action in _reportsGroup.ListActions())
		{
			action.Sensitive = true;
		}
		
		// get all tools related actions, make sensitive
		foreach (Gtk.Action action in _toolsGroup.ListActions())
		{
			action.Sensitive = true;
		}
		
		// get all view related actions, make sensitive
		foreach (Gtk.Action action in _viewGroup.ListActions())
		{
			action.Sensitive = true;	
		}		
		
		NewIndividual.Sensitive = true;
		NewMedia.Sensitive = true;
		NewRepository.Sensitive = true;
		NewSource.Sensitive = true;
		NewNote.Sensitive = true;
	}
Esempio n. 17
0
		protected void OnSelection_Changed(object sender, System.EventArgs e)
		{
			Gtk.TreeSelection selection = RepositoryTreeView.Selection;
			
			Gtk.TreeModel model;
			Gtk.TreeIter iter;
			if (selection.GetSelected(out model, out iter))
			{
				_record = (GedcomRecord)model.GetValue(iter, 0);
			}
			else
			{
				_record = null;	
			}
			
			if (RecordChanged != null)
			{
				RecordChanged(this, EventArgs.Empty);	
			}
		}
Esempio n. 18
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();
		}
	}
		private void AppendSources(GedcomRecord record, XmlNode root)
		{
			foreach (GedcomSourceCitation citation in record.Sources)
			{
				string sourceId = citation.Source;
				if (!_processed.Contains(sourceId))
				{
					_processed.Add(sourceId);
					
					GedcomSourceRecord source = _database[sourceId] as GedcomSourceRecord;
					if (source != null)
					{
						source.GenerateXML(root);
					}
					else
					{
						throw new Exception("Source citation references non existant source");
					}
				}
			}
		}
Esempio n. 20
0
	protected virtual void OnHusbandsParents_Activated(object sender, System.EventArgs e)
	{
		GedcomIndividualRecord indi = _currentView.Husband;
		
		if (indi != null && indi.ChildIn.Count > 0)
		{
			GedcomFamilyLink link = indi.ChildIn[0];
			GedcomFamilyRecord fam = _database[link.Family] as GedcomFamilyRecord;
			if (fam != null)
			{
				if (!string.IsNullOrEmpty(fam.Husband))
				{
					indi = _database[fam.Husband] as GedcomIndividualRecord;		
				}
				else if (!string.IsNullOrEmpty(fam.Wife))
				{
					indi = _database[fam.Wife] as GedcomIndividualRecord;
				}
				else
				{
					// FIXME: shouldn't be here, or should we?  why can't there
					// be a family record with children but parents not known?
					// create a parent as unknown /unknown/  ?
					
					throw new Exception("Family with no husband or wife");
				}
				
				if (indi != null)
				{
					Record = indi;	
				}
				else
				{
					System.Diagnostics.Debug.WriteLine("Husband/Wife in family points to non individual record");
				}
			}
			else
			{
				System.Diagnostics.Debug.WriteLine("Family link points to non family record");	
			}
		}
	}
Esempio n. 21
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();
				}
			}
		}