Example #1
0
		protected virtual void OnNewEventGroupButton_Clicked(object sender, System.EventArgs e)
		{
			GedcomRecordedEvent recordedEvent = new GedcomRecordedEvent();
			recordedEvent.Database = Database;
			
			GedcomSourceRecord source = (GedcomSourceRecord)_record;
			source.EventsRecorded.Add(recordedEvent);
			
			_eventGroups.ItemInserted();
		}
		private void ReadSourceRecord()
		{
			GedcomSourceRecord sourceRecord;
									
			sourceRecord = _ParseState.Records.Peek() as GedcomSourceRecord;
			
			if (_level == sourceRecord.ParsingLevel + 1)
			{

				// hack, at this level won't have CONT/CONC so end any building we
				// are doing
				if (sourceRecord.TitleText != null)
				{
					sourceRecord.Title = sourceRecord.TitleText.ToString();
					sourceRecord.TitleText = null;
				}
				else if (sourceRecord.OriginatorText != null)
				{
					sourceRecord.Originator = sourceRecord.OriginatorText.ToString();
					sourceRecord.OriginatorText = null;
				}
				else if (sourceRecord.PublicationText != null)
				{
					sourceRecord.PublicationFacts = sourceRecord.PublicationText.ToString();
					sourceRecord.PublicationText = null;
				}
				else if (sourceRecord.TextText != null)
				{
					sourceRecord.Text = sourceRecord.TextText.ToString();
					sourceRecord.TextText = null;
				}
			
				switch (_tag)
				{
					case "DATA":
						// info held in child nodes
						break;
					case "AUTH":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							sourceRecord.OriginatorText = new StringBuilder(_lineValue);
						}
						break;
					case "TITL":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							sourceRecord.TitleText = new StringBuilder(_lineValue);
						}
						break;
					case "ABBR":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							sourceRecord.FiledBy = _lineValue;
						}
						break;
					case "PUBL":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							sourceRecord.PublicationText = new StringBuilder(_lineValue);
						}
						break;
					case "TEXT":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							int capacity = _lineValue.Length;
							if (!string.IsNullOrEmpty(sourceRecord.Text))
							{
								capacity += sourceRecord.Text.Length;
								capacity += Environment.NewLine.Length;
							}
							
							sourceRecord.TextText = new StringBuilder(capacity);
							
							if (string.IsNullOrEmpty(sourceRecord.Text))
							{
								sourceRecord.TextText.Append(_lineValue);
							}
							else
							{
								sourceRecord.TextText.Append(sourceRecord.Text);
								sourceRecord.TextText.Append(Environment.NewLine);
								sourceRecord.TextText.Append(_lineValue);	
							}
						}
						break;
					case "REPO":
						GedcomRepositoryCitation citation = new GedcomRepositoryCitation();
						citation.Level = _level;
						if (_lineValueType == GedcomLineValueType.PointerType)
						{
							citation.Repository = _lineValue;
							_missingReferences.Add(_lineValue);
						}
						sourceRecord.RepositoryCitations.Add(citation);
					
						_ParseState.Records.Push(citation);
						break;
					case "REFN":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							sourceRecord.UserReferenceNumber = _lineValue;
						}
						break;
					case "RIN":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							sourceRecord.AutomatedRecordID = _lineValue;	
						}
						break;
					case "CHAN":
						GedcomChangeDate date = new GedcomChangeDate(Database);
						date.Level = _level;
						_ParseState.Records.Push(date);
						break;
					case "NOTE":
					    AddNoteRecord(sourceRecord);
						break;
					case "OBJE":
						AddMultimediaRecord(sourceRecord);
						break;

				}
			}
			else if ( (!string.IsNullOrEmpty(_ParseState.PreviousTag)) &&
			            _level == sourceRecord.Level + 2) // _ParseState.PreviousLevel + 2)
			{
				if (_ParseState.PreviousTag == "REFN" && _tag == "TYPE")
				{
					if (_lineValueType == GedcomLineValueType.DataType)
					{
						sourceRecord.UserReferenceType = _lineValue;	
					}
				}
				else if (sourceRecord.OriginatorText != null) // (_ParseState.PreviousTag == "AUTH")
				{
					switch (_tag)
					{
						case "CONT":
							sourceRecord.OriginatorText.Append(Environment.NewLine);
							sourceRecord.OriginatorText.Append(_lineValue);
							break;
						case "CONC":
							sourceRecord.OriginatorText.Append(_lineValue);
							break;
					}
				}
				else if (sourceRecord.TitleText != null) // (_ParseState.PreviousTag == "TITL")
				{
					switch (_tag)
					{
						case "CONT":
							sourceRecord.TitleText.Append(Environment.NewLine);
							sourceRecord.TitleText.Append(_lineValue);
							break;
						case "CONC":
							sourceRecord.TitleText.Append(_lineValue);
							break;
					}
				}
				else if (sourceRecord.PublicationText != null) // (_ParseState.PreviousTag == "PUBL")
				{
					switch (_tag)
					{
						case "CONT":
							sourceRecord.PublicationText.Append(Environment.NewLine);
							sourceRecord.PublicationText.Append(_lineValue);
							break;
						case "CONC":
							sourceRecord.PublicationText.Append(_lineValue);
							break;
					}
				}
				else if (sourceRecord.TextText != null) //(_ParseState.PreviousTag == "TEXT")
				{
					switch (_tag)
					{
						case "CONT":
							sourceRecord.TextText.Append(Environment.NewLine);
							sourceRecord.TextText.Append(_lineValue);
							break;
						case "CONC":
							sourceRecord.TextText.Append(_lineValue);
							break;
					}
				}
				else //if (_ParseState.PreviousTag == "DATA")
				{
					switch (_tag)
					{
						case "AGNC":
							if (_lineValueType == GedcomLineValueType.DataType)
							{
								sourceRecord.Agency = _lineValue;	
							}
							break;
						case "EVEN":
							if (_lineValueType == GedcomLineValueType.DataType)
							{
								GedcomRecordedEvent recordedEvent = new GedcomRecordedEvent();
								
								sourceRecord.EventsRecorded.Add(recordedEvent);
								
								string[] events = _lineValue.Split(new char[]{','}, StringSplitOptions.RemoveEmptyEntries);
								foreach (string e in events)
								{
									string ev = e.Trim();
									GedcomEvent.GedcomEventType eventType;
									
									if (ev == "EVEN")
									{
										eventType = GedcomEvent.GedcomEventType.GenericEvent;
										recordedEvent.Types.Add(eventType);
									}
									else if (ev == "FACT")
									{
										eventType = GedcomEvent.GedcomEventType.GenericFact;
										recordedEvent.Types.Add(eventType);
									}
									else
									{
										try
										{
											eventType = EnumHelper.Parse<GedcomEvent.GedcomEventType>(ev,true);
											recordedEvent.Types.Add(eventType);	
										}
										catch
										{
											try
											{
												eventType = EnumHelper.Parse<GedcomEvent.GedcomEventType>(ev + "Fact",true);
												recordedEvent.Types.Add(eventType);
											}
											catch
											{
												// FIXME: shouldn't lose data like this
											}
										}
									}									
								}
							}
							break;
						case "NOTE":
						    string xref = AddNoteRecord(sourceRecord);
						    // belongs in data records, not top level record notes
						    sourceRecord.Notes.Remove(xref);
						    sourceRecord.DataNotes.Add(xref);
							break;
					}
				}
			}
			else if ( (!string.IsNullOrEmpty(_ParseState.PreviousTag)) &&
			            _level == sourceRecord.Level + 3) //_ParseState.PreviousLevel + 3)
			{
//				if (_ParseState.PreviousTag == "EVEN")
//				{
					GedcomRecordedEvent recordedEvent = sourceRecord.EventsRecorded[sourceRecord.EventsRecorded.Count - 1];
					switch (_tag)
					{
						case "DATE":
							GedcomDate date = new GedcomDate(Database);
							date.Level = _level;
							_ParseState.Records.Push(date);
							recordedEvent.Date = date;
							_level ++;
							ReadDateRecord();
							_level --;
							_ParseState.Records.Pop();
							break;
						case "PLAC":
							GedcomPlace place = new GedcomPlace();
							place.Level = _level;
						
							recordedEvent.Place = place; 
														
							if (_lineValueType == GedcomLineValueType.DataType)
							{
								place.Name = Database.PlaceNameCollection[_lineValue];
							}
							else
							{
								// invalid, provide a name anyway
								place.Name = "Unknown";
								Debug.WriteLine("invalid place node, no name at level: " + _level);
							}
							_ParseState.Records.Push(place);
							break;
					}
//				}
			}
			else
			{
				// shouldn't be here
				Debug.WriteLine("Unknown state / tag parsing note node: " + _tag + "\t at level: " + _level);
			}
		}
Example #3
0
		protected void OnEventGroupSelection_Changed(object sender, System.EventArgs e)
		{
			Gtk.TreeSelection selection = EventGroupTreeView.Selection;
			
			if (_recordedEvent != null)
			{
				SaveView();
			}
			
			Gtk.TreeModel model;
			Gtk.TreeIter iter;
			
			GedcomRecordedEvent recordedEvent = null;
			
			if (selection.GetSelected(out model, out iter))
			{
				recordedEvent = (GedcomRecordedEvent)model.GetValue(iter, 0);
			}
						
			RecordedEvent = recordedEvent;
		}