public void gt_bind_record_note(object recPtr, object notePtr) { GDMRecord rec = recPtr as GDMRecord; if (rec == null) { return; } GDMNoteRecord noteRec = notePtr as GDMNoteRecord; rec.AddNote(noteRec); }
public void Test_StdGEDCOM_Notes() { using (var ctx = TestUtils.LoadResourceGEDCOMFile("test_stdgedcom_notes.ged")) { Assert.AreEqual(GEDCOMFormat.gf_Native, ctx.Tree.Format); GDMNoteRecord noteRec1 = ctx.Tree.XRefIndex_Find("N1") as GDMNoteRecord; Assert.IsNotNull(noteRec1); Assert.AreEqual("Test1\r\ntest2\r\ntest3", noteRec1.Lines.Text); GDMNoteRecord noteRec2 = ctx.Tree.XRefIndex_Find("N2") as GDMNoteRecord; Assert.IsNotNull(noteRec2); Assert.AreEqual("Test\r\ntest2\r\ntest3", noteRec2.Lines.Text); } }
public static GDMNotes FindNotes(this IGDMStructWithNotes _struct, GDMNoteRecord noteRec) { if (noteRec != null && _struct.HasNotes) { int num = _struct.Notes.Count; for (int i = 0; i < num; i++) { var notes = _struct.Notes[i]; if (notes.XRef == noteRec.XRef) { return(notes); } } } return(null); }
private void CheckBuffer(GDMLines buffer, GDMIndividualRecord curPerson) { if (buffer.IsEmpty()) { return; } if (curPerson != null) { CheckSpouses(buffer, curPerson); } GDMNoteRecord noteRec = fTree.CreateNote(); noteRec.Lines.Assign(buffer); if (curPerson != null) { curPerson.AddNote(noteRec); } buffer.Clear(); }
private bool ProcessRecordNoteAdd(bool redo) { IGEDCOMStructWithLists swl = fObj as IGEDCOMStructWithLists; GDMNoteRecord noteRec = fNewVal as GDMNoteRecord; bool result = (swl != null && noteRec != null); if (result) { if (redo) { GDMNotes notes = swl.AddNote(noteRec); fOldVal = notes; } else { GDMNotes notes = fOldVal as GDMNotes; swl.Notes.Delete(notes); } } return(result); }
private void ParseSimple() { string tmp = EditName.Text.ToLower(); string[] tokens = tmp.Split(' '); if (tokens.Length < 3) { ShowError(fLangMan.LS(FLS.LSID_NameInvalid)); return; } string fam = ConvertHelper.UniformName(tokens[0]); string nam = ConvertHelper.UniformName(tokens[1]); string pat = ConvertHelper.UniformName(tokens[2]); GDMIndividualRecord iRec = fBase.Context.CreatePersonEx(nam, pat, fam, fSimpleTempSex, false); if (CheckBirth.Checked) { fBase.Context.CreateEventEx(iRec, GEDCOMTagName.BIRT, GDMDate.CreateByFormattedStr(EditBirthDate.Text, true), EditBirthPlace.Text); } if (CheckDeath.Checked) { fBase.Context.CreateEventEx(iRec, GEDCOMTagName.DEAT, GDMDate.CreateByFormattedStr(EditDeathDate.Text, true), EditDeathPlace.Text); } if (!string.IsNullOrEmpty(MemoNote.Text)) { GDMNoteRecord noteRec = fBase.Context.Tree.CreateNote(); noteRec.SetNoteText(MemoNote.Text); iRec.AddNote(noteRec); } fBase.NotifyRecord(iRec, RecordAction.raAdd); InitSimpleControls(); }
// TODO: rollback changes when exception! private void ParseSource() { int srcYear; if (!int.TryParse(edSourceYear.Text, out srcYear)) { ShowError(fLangMan.LS(FLS.LSID_SourceYearInvalid)); return; } string srcName = cbSource.Text; string srcPage = edPage.Text; string place = edPlace.Text; GDMSourceRecord srcRec = null; if (!string.IsNullOrEmpty(srcName)) { srcRec = fBase.Context.FindSource(srcName); if (srcRec == null) { srcRec = fBase.Context.Tree.CreateSource(); srcRec.ShortTitle = srcName; } } GDMIndividualRecord iMain = null; int num = dataGridView1.Rows.Count; for (int r = 0; r < num; r++) { DataGridViewRow row = dataGridView1.Rows[r]; string lnk = CheckStr((string)row.Cells[0].Value); string nm = CheckStr((string)row.Cells[1].Value); string pt = CheckStr((string)row.Cells[2].Value); string fm = CheckStr((string)row.Cells[3].Value); string age = CheckStr((string)row.Cells[4].Value); string comment = CheckStr((string)row.Cells[5].Value); if (!string.IsNullOrEmpty(lnk)) { PersonLink link = GetLinkByName(lnk); if (link == PersonLink.plNone) { continue; } GDMSex sx = fBase.Context.DefineSex(nm, pt); GDMIndividualRecord iRec = fBase.Context.CreatePersonEx(nm, pt, fm, sx, false); if (!string.IsNullOrEmpty(age) && ConvertHelper.IsDigits(age)) { int birthYear = srcYear - int.Parse(age); fBase.Context.CreateEventEx(iRec, GEDCOMTagName.BIRT, "ABT " + birthYear.ToString(), ""); } if (!string.IsNullOrEmpty(place)) { GDMCustomEvent evt = fBase.Context.CreateEventEx(iRec, GEDCOMTagName.RESI, "", ""); evt.Place.StringValue = place; } if (!string.IsNullOrEmpty(comment)) { GDMNoteRecord noteRec = fBase.Context.Tree.CreateNote(); noteRec.SetNoteText(comment); iRec.AddNote(noteRec); } if (srcRec != null) { iRec.AddSource(srcRec, srcPage, 0); } fBase.NotifyRecord(iRec, RecordAction.raAdd); GDMFamilyRecord family = null; if (link == PersonLink.plPerson) { iMain = iRec; string evName = ""; if (rbSK_Met.Checked) { switch (cbEventType.SelectedIndex) { case 0: evName = GEDCOMTagName.BIRT; break; case 1: evName = GEDCOMTagName.DEAT; break; case 2: evName = GEDCOMTagName.MARR; break; } } if (evName == GEDCOMTagName.BIRT || evName == GEDCOMTagName.DEAT) { GDMCustomEvent evt = fBase.Context.CreateEventEx(iRec, evName, GDMDate.CreateByFormattedStr(edEventDate.Text, false), ""); evt.Place.StringValue = place; } else if (evName == GEDCOMTagName.MARR) { family = iRec.GetMarriageFamily(true); GDMCustomEvent evt = fBase.Context.CreateEventEx(family, evName, GDMDate.CreateByFormattedStr(edEventDate.Text, false), ""); evt.Place.StringValue = place; } } else { if (iMain == null) { throw new PersonScanException(fLangMan.LS(FLS.LSID_BasePersonInvalid)); } else { switch (link) { case PersonLink.plFather: case PersonLink.plMother: family = iMain.GetParentsFamily(true); family.AddSpouse(iRec); break; case PersonLink.plGodparent: iMain.AddAssociation(fLangMan.LS(FLS.LSID_PLGodparent), iRec); break; case PersonLink.plSpouse: family = iMain.GetMarriageFamily(true); family.AddSpouse(iRec); break; case PersonLink.plChild: family = iMain.GetMarriageFamily(true); family.AddChild(iRec); break; } } } } } InitSourceControls(); }
public void Test_ShowXInfo() { StringList summary = new StringList(); summary.Clear(); GKUtils.ShowFamilyInfo(fContext, null, null); GDMFamilyRecord famRec = fContext.Tree.XRefIndex_Find("F1") as GDMFamilyRecord; GKUtils.ShowFamilyInfo(fContext, famRec, summary); summary.Clear(); GKUtils.ShowGroupInfo(null, null); GDMGroupRecord grpRec = fContext.Tree.XRefIndex_Find("G1") as GDMGroupRecord; GKUtils.ShowGroupInfo(grpRec, summary); summary.Clear(); GKUtils.ShowMultimediaInfo(null, null); GDMMultimediaRecord mmRec = fContext.Tree.XRefIndex_Find("O1") as GDMMultimediaRecord; GKUtils.ShowMultimediaInfo(mmRec, summary); summary.Clear(); GKUtils.ShowNoteInfo(null, null); GDMNoteRecord noteRec = fContext.Tree.XRefIndex_Find("N1") as GDMNoteRecord; GKUtils.ShowNoteInfo(noteRec, summary); summary.Clear(); GKUtils.ShowPersonInfo(fContext, null, null); GDMIndividualRecord indRec = fContext.Tree.XRefIndex_Find("I1") as GDMIndividualRecord; GKUtils.ShowPersonInfo(fContext, indRec, summary); summary.Clear(); GKUtils.ShowSourceInfo(null, null); GDMSourceRecord srcRec = fContext.Tree.XRefIndex_Find("S1") as GDMSourceRecord; GKUtils.ShowSourceInfo(srcRec, summary); summary.Clear(); GKUtils.ShowRepositoryInfo(null, null); GDMRepositoryRecord repRec = fContext.Tree.XRefIndex_Find("R1") as GDMRepositoryRecord; GKUtils.ShowRepositoryInfo(repRec, summary); summary.Clear(); GKUtils.ShowResearchInfo(null, null); GDMResearchRecord resRec = fContext.Tree.XRefIndex_Find("RS1") as GDMResearchRecord; GKUtils.ShowResearchInfo(resRec, summary); summary.Clear(); GKUtils.ShowTaskInfo(null, null); GDMTaskRecord taskRec = fContext.Tree.XRefIndex_Find("TK1") as GDMTaskRecord; GKUtils.ShowTaskInfo(taskRec, summary); summary.Clear(); GKUtils.ShowCommunicationInfo(null, null); GDMCommunicationRecord commRec = fContext.Tree.XRefIndex_Find("CM1") as GDMCommunicationRecord; GKUtils.ShowCommunicationInfo(commRec, summary); summary.Clear(); GKUtils.ShowLocationInfo(null, null); GDMLocationRecord locRec = fContext.Tree.XRefIndex_Find("L1") as GDMLocationRecord; GKUtils.ShowLocationInfo(locRec, summary); }
public override void Fetch(GDMRecord aRec) { fRec = (aRec as GDMNoteRecord); }
public static void FillContext(IBaseContext context) { // a null result if the record is not defined GDMCustomEvent evt = context.CreateEventEx(null, GEDCOMTagName.BIRT, "xxxxx", "xxxxx"); Assert.IsNull(evt); // first individual (I1) GDMIndividualRecord iRec = context.CreatePersonEx("Ivan", "Ivanovich", "Ivanov", GDMSex.svMale, true); Assert.IsNotNull(iRec); evt = iRec.FindEvent(GEDCOMTagType.BIRT); Assert.IsNotNull(evt); evt.Date.ParseString("28 DEC 1990"); evt.Place.StringValue = "Ivanovo"; GDMCustomEvent evtd = context.CreateEventEx(iRec, GEDCOMTagName.DEAT, "28 DEC 2010", "Ivanovo"); Assert.IsNotNull(evtd); // second individual, wife (I2) GDMIndividualRecord iRec2 = context.CreatePersonEx("Maria", "Petrovna", "Ivanova", GDMSex.svFemale, true); evt = iRec2.FindEvent(GEDCOMTagType.BIRT); Assert.IsNotNull(evt); evt.Date.ParseString("17 MAR 1991"); evt.Place.StringValue = "Ivanovo"; iRec.AddAssociation("spouse", iRec2); // third individual, child (I3) GDMIndividualRecord iRec3 = context.CreatePersonEx("Anna", "Ivanovna", "Ivanova", GDMSex.svFemale, true); evt = iRec3.FindEvent(GEDCOMTagType.BIRT); Assert.IsNotNull(evt); evt.Date.ParseString("11 FEB 2010"); evt.Place.StringValue = "Ivanovo"; // their family GDMFamilyRecord famRec = context.Tree.CreateFamily(); Assert.IsNotNull(famRec); famRec.AddSpouse(iRec); famRec.AddSpouse(iRec2); famRec.AddChild(iRec3); context.CreateEventEx(famRec, GEDCOMTagName.MARR, "01 JAN 2000", "unknown"); // individual outside the family (I4) GDMIndividualRecord iRec4 = context.CreatePersonEx("Alex", "", "Petrov", GDMSex.svMale, true); evt = iRec4.FindEvent(GEDCOMTagType.BIRT); Assert.IsNotNull(evt); evt.Date.ParseString("15 JUN 1989"); evt.Place.StringValue = "Far Forest"; evt = context.CreateEventEx(iRec4, GEDCOMTagName.RESI, "12 FEB", "Far Forest"); Assert.IsNotNull(evt); // fifth (I5) GDMIndividualRecord iRec5 = context.CreatePersonEx("Anna", "", "Jones", GDMSex.svFemale, false); Assert.IsNotNull(iRec5); // sixth (I6) GDMIndividualRecord iRec6 = context.CreatePersonEx("Mary", "", "Jones", GDMSex.svFemale, false); Assert.IsNotNull(iRec6); evt = context.CreateEventEx(iRec6, GEDCOMTagName.BIRT, "12 FEB 1650", "Far Forest"); GDMFamilyRecord famRec2 = context.Tree.CreateFamily(); Assert.IsNotNull(famRec2); famRec2.AddSpouse(iRec3); //famRec2.AddSpouse(iRec4); famRec2.AddChild(iRec5); famRec2.AddChild(iRec6); // group for tests GDMGroupRecord groupRec = context.Tree.CreateGroup(); groupRec.GroupName = "GroupTest"; Assert.IsNotNull(groupRec, "group1 != null"); groupRec.AddMember(iRec); // location for tests GDMLocationRecord locRec = context.Tree.CreateLocation(); locRec.LocationName = "Test Location"; locRec.Map.Lati = 5.11111; locRec.Map.Long = 7.99999; Assert.IsNotNull(locRec, "locRec != null"); // repository for tests GDMRepositoryRecord repoRec = context.Tree.CreateRepository(); repoRec.RepositoryName = "Test repository"; Assert.IsNotNull(repoRec, "repoRec != null"); // research for tests GDMResearchRecord resRec = context.Tree.CreateResearch(); resRec.ResearchName = "Test research"; Assert.IsNotNull(resRec, "resRec != null"); // source for tests GDMSourceRecord srcRec = context.Tree.CreateSource(); srcRec.ShortTitle = "Test source"; Assert.IsNotNull(srcRec, "srcRec != null"); iRec.AddSource(srcRec, "p1", 0); // note for tests GDMNoteRecord noteRec = context.Tree.CreateNote(); noteRec.SetNoteText("Test note"); Assert.IsNotNull(noteRec, "noteRec != null"); iRec.AddNote(noteRec); // task for tests GDMTaskRecord tskRec = context.Tree.CreateTask(); tskRec.Goal = "Test task"; Assert.IsNotNull(tskRec, "tskRec != null"); // media for tests GDMMultimediaRecord mediaRec = context.Tree.CreateMultimedia(); mediaRec.FileReferences.Add(new GDMFileReferenceWithTitle()); GDMFileReferenceWithTitle fileRef = mediaRec.FileReferences[0]; fileRef.Title = "Test multimedia"; fileRef.LinkFile("sample.png"); Assert.IsNotNull(mediaRec, "mediaRec != null"); iRec.AddMultimedia(mediaRec); // communication for tests GDMCommunicationRecord commRec = context.Tree.CreateCommunication(); commRec.CommName = "Test communication"; Assert.IsNotNull(commRec, "commRec != null"); }
public object gt_create_note() { GDMNoteRecord nRec = fBase.Context.Tree.CreateNote(); return(nRec); }
public static bool EditRecord(IBaseWindow baseWin, GDMRecord rec) { bool result = false; switch (rec.RecordType) { case GDMRecordType.rtIndividual: GDMIndividualRecord ind = rec as GDMIndividualRecord; result = ModifyIndividual(baseWin, ref ind, null, TargetMode.tmNone, GDMSex.svUnknown); break; case GDMRecordType.rtFamily: GDMFamilyRecord fam = rec as GDMFamilyRecord; result = ModifyFamily(baseWin, ref fam, TargetMode.tmNone, null); break; case GDMRecordType.rtNote: GDMNoteRecord note = rec as GDMNoteRecord; result = ModifyNote(baseWin, ref note); break; case GDMRecordType.rtMultimedia: GDMMultimediaRecord mmRec = rec as GDMMultimediaRecord; result = ModifyMedia(baseWin, ref mmRec); break; case GDMRecordType.rtSource: GDMSourceRecord src = rec as GDMSourceRecord; result = ModifySource(baseWin, ref src); break; case GDMRecordType.rtRepository: GDMRepositoryRecord rep = rec as GDMRepositoryRecord; result = ModifyRepository(baseWin, ref rep); break; case GDMRecordType.rtGroup: GDMGroupRecord grp = rec as GDMGroupRecord; result = ModifyGroup(baseWin, ref grp); break; case GDMRecordType.rtResearch: GDMResearchRecord rsr = rec as GDMResearchRecord; result = ModifyResearch(baseWin, ref rsr); break; case GDMRecordType.rtTask: GDMTaskRecord tsk = rec as GDMTaskRecord; result = ModifyTask(baseWin, ref tsk); break; case GDMRecordType.rtCommunication: GDMCommunicationRecord comm = rec as GDMCommunicationRecord; result = ModifyCommunication(baseWin, ref comm); break; case GDMRecordType.rtLocation: GDMLocationRecord loc = rec as GDMLocationRecord; result = ModifyLocation(baseWin, ref loc); break; } return(result); }
public static GDMRecord AddRecord(IBaseWindow baseWin, GDMRecordType rt, Target target) { bool result = false; GDMRecord rec = null; switch (rt) { case GDMRecordType.rtIndividual: { // FIXME: legacy code, checkit if (target == null) { target = new Target(); target.TargetMode = TargetMode.tmParent; } GDMIndividualRecord indivRec = null; result = ModifyIndividual(baseWin, ref indivRec, target.TargetIndividual, target.TargetMode, target.NeedSex); rec = indivRec; break; } case GDMRecordType.rtFamily: { if (target == null) { target = new Target(); } TargetMode famTarget = (target.TargetMode != TargetMode.tmFamilyChild) ? TargetMode.tmNone : target.TargetMode; GDMFamilyRecord fam = null; result = ModifyFamily(baseWin, ref fam, famTarget, target.TargetIndividual); rec = fam; break; } case GDMRecordType.rtNote: { GDMNoteRecord note = null; result = ModifyNote(baseWin, ref note); rec = note; break; } case GDMRecordType.rtMultimedia: { GDMMultimediaRecord mmRec = null; result = ModifyMedia(baseWin, ref mmRec); rec = mmRec; break; } case GDMRecordType.rtSource: { GDMSourceRecord src = null; result = ModifySource(baseWin, ref src); rec = src; break; } case GDMRecordType.rtRepository: { GDMRepositoryRecord rep = null; result = ModifyRepository(baseWin, ref rep); rec = rep; break; } case GDMRecordType.rtGroup: { GDMGroupRecord grp = null; result = ModifyGroup(baseWin, ref grp); rec = grp; break; } case GDMRecordType.rtResearch: { GDMResearchRecord rsr = null; result = ModifyResearch(baseWin, ref rsr); rec = rsr; break; } case GDMRecordType.rtTask: { GDMTaskRecord tsk = null; result = ModifyTask(baseWin, ref tsk); rec = tsk; break; } case GDMRecordType.rtCommunication: { GDMCommunicationRecord comm = null; result = ModifyCommunication(baseWin, ref comm); rec = comm; break; } case GDMRecordType.rtLocation: { GDMLocationRecord loc = null; result = ModifyLocation(baseWin, ref loc); rec = loc; break; } } return((result) ? rec : null); }