コード例 #1
0
		public void AddMultimediaFile(string filename)
		{
			FileInfo info = new FileInfo(filename);
			
			GedcomMultimediaFile file = new GedcomMultimediaFile();
			file.Database = _database;
		
			file.Filename = filename;
			file.Format = info.Extension;
			
			_Files.Add(file);
		}
コード例 #2
0
		private void ReadMultimediaRecord()
		{
			GedcomMultimediaRecord multimediaRecord;
			
			multimediaRecord = _ParseState.Records.Peek() as GedcomMultimediaRecord;
				
			if (_level == multimediaRecord.ParsingLevel + 1)
			{
				switch (_tag)
				{
					case "FORM":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							GedcomMultimediaFile file;
							if (multimediaRecord.Files.Count > 0)
							{
								file = multimediaRecord.Files[multimediaRecord.Files.Count - 1];
							}
							else
							{
								file = new GedcomMultimediaFile();
								file.Database = Database;
								multimediaRecord.Files.Add(file);
							}
							file.Format = _lineValue;
						}
						break;
					case "TITL":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							multimediaRecord.Title = _lineValue;
						}
						break;
						
				
					case "FILE":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							GedcomMultimediaFile file = null;
							if (multimediaRecord.Files.Count > 0)
							{
								file = multimediaRecord.Files[multimediaRecord.Files.Count - 1];
								if (!string.IsNullOrEmpty(file.Filename))
								{
									file = null;
								}
							}
							if (file == null)
							{
								file = new GedcomMultimediaFile();
								file.Database = Database;
								multimediaRecord.Files.Add(file);
							}
							
							file.Filename = _lineValue;
						}
						break;
					case "REFN":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							multimediaRecord.UserReferenceNumber = _lineValue;
						}
						break;
					case "RIN":
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							multimediaRecord.AutomatedRecordID = _lineValue;	
						}
						break;
					case "CHAN":
						GedcomChangeDate date = new GedcomChangeDate(Database);
						date.Level = _level;
						_ParseState.Records.Push(date);
						break;
					case "NOTE":
					    AddNoteRecord(multimediaRecord);
						break;
					case "SOUR":
					    AddSourceCitation(multimediaRecord);				
						break;
				}
			}
			else if (_ParseState.PreviousTag != string.Empty)
			{
				if (_level == multimediaRecord.ParsingLevel + 2)
				{
					if (_ParseState.PreviousTag == "REFN" && _tag == "TYPE")
					{
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							multimediaRecord.UserReferenceType = _lineValue;	
						}
					}
					else if (_ParseState.PreviousTag == "FILE")
					{
						switch (_tag)
						{
							case "FORM":
								if (_lineValueType == GedcomLineValueType.DataType)
								{
									multimediaRecord.Files[multimediaRecord.Files.Count - 1].Format = _lineValue;	
								}
								break;
						}
					}
					else if (_ParseState.PreviousTag == "FORM")
					{
						if (_tag == "MEDI" &&
						    _lineValueType == GedcomLineValueType.DataType)
						{
							// FIXME: GedcomMultiMediaFile should use the enum?
							multimediaRecord.Files[multimediaRecord.Files.Count - 1].SourceMediaType  = _lineValue;
						}
					}
				}
				else if (_level == multimediaRecord.ParsingLevel + 3)
				{
					if (_ParseState.PreviousTag == "FILE" && _tag == "TYPE")
					{
						if (_lineValueType == GedcomLineValueType.DataType)
						{
							// FIXME: GedcomMultiMediaFile should use the enum?
							multimediaRecord.Files[multimediaRecord.Files.Count - 1].SourceMediaType = _lineValue;	
						}
					}
				}
			}
			else
			{
				// shouldn't be here
				Debug.WriteLine("Unknown state / tag parsing multimedia node: " + _tag + "\t at level: " + _level);
			}
		}