private void btnAccept_Click(object sender, EventArgs e) { try { int idx = fSourcesList.IndexOf(cmbSource.Text); GEDCOMSourceRecord src = ((idx < 0) ? null : (fSourcesList.GetObject(idx) as GEDCOMSourceRecord)); if (src == null) { AppHost.StdDialogs.ShowError(LangMan.LS(LSID.LSID_DoNotSetSource)); DialogResult = DialogResult.None; } else { fSourceCitation.Value = src; fSourceCitation.Page = txtPage.Text; fSourceCitation.CertaintyAssessment = txtCertainty.SelectedIndex; DialogResult = DialogResult.Ok; } } catch (Exception ex) { Logger.LogWrite("SourceCitEditDlg.btnAccept_Click(): " + ex.Message); DialogResult = DialogResult.None; } }
public override void UpdateContents() { var dataOwner = fDataOwner as IGEDCOMStructWithLists; if (fSheetList == null || dataOwner == null) { return; } try { fSheetList.ClearItems(); foreach (GEDCOMSourceCitation cit in dataOwner.SourceCitations) { GEDCOMSourceRecord sourceRec = cit.Value as GEDCOMSourceRecord; if (sourceRec == null) { continue; } fSheetList.AddItem(cit, new object[] { sourceRec.Originator.Text.Trim(), sourceRec.FiledByEntry, cit.Page, LangMan.LS(GKData.CertaintyAssessments[cit.CertaintyAssessment]) }); } fSheetList.ResizeColumn(1); } catch (Exception ex) { Logger.LogWrite("SourceCitationsListModel.UpdateContents(): " + ex.Message); } }
private static void PostProcessPerson(IBaseWindow baseWin, GEDCOMIndividualRecord indivRec) { AppHost.NamesTable.ImportNames(indivRec); IListManager listMan = baseWin.GetRecordsListManByType(GEDCOMRecordType.rtIndividual); if (listMan == null) { return; } IndividualListFilter iFilter = (IndividualListFilter)listMan.Filter; if (iFilter.SourceMode == FilterGroupMode.Selected) { GEDCOMSourceRecord src = baseWin.Context.Tree.XRefIndex_Find(iFilter.SourceRef) as GEDCOMSourceRecord; if (src != null && AppHost.StdDialogs.ShowQuestionYN(LangMan.LS(LSID.LSID_IncludedSourceFilter))) { indivRec.AddSource(src, "", 0); } } if (iFilter.FilterGroupMode == FilterGroupMode.Selected) { GEDCOMGroupRecord grp = baseWin.Context.Tree.XRefIndex_Find(iFilter.GroupRef) as GEDCOMGroupRecord; if (grp != null && AppHost.StdDialogs.ShowQuestionYN(LangMan.LS(LSID.LSID_IncludedGroupFilter))) { grp.AddMember(indivRec); } } }
public object gt_create_source(string name) { GEDCOMSourceRecord srcRec = fBase.Context.Tree.CreateSource(); srcRec.FiledByEntry = name; return(srcRec); }
public override bool Accept() { try { int idx = fSourcesList.IndexOf(fView.Source.Text); GEDCOMSourceRecord src = ((idx < 0) ? null : (fSourcesList.GetObject(idx) as GEDCOMSourceRecord)); if (src == null) { AppHost.StdDialogs.ShowError(LangMan.LS(LSID.LSID_DoNotSetSource)); return(false); } else { fSourceCitation.Value = src; fSourceCitation.Page = fView.Page.Text; fSourceCitation.CertaintyAssessment = fView.Certainty.SelectedIndex; return(true); } } catch (Exception ex) { Logger.LogWrite("SourceCitEditDlgController.Accept(): " + ex.Message); return(false); } }
public override void Setup() { base.Setup(); fBase = new BaseWindowStub(); fSourceRecord = new GEDCOMSourceRecord(fBase.Context.Tree, fBase.Context.Tree, "", ""); fDialog = new SourceEditDlg(fBase); fDialog.Model = fSourceRecord; fDialog.Show(); }
public override void UpdateView() { GEDCOMSourceRecord src = (fSourceCitation.Value as GEDCOMSourceRecord); if (src != null) { fView.Source.Text = src.FiledByEntry; } fView.Page.Text = fSourceCitation.Page; fView.Certainty.SelectedIndex = fSourceCitation.CertaintyAssessment; }
public void gt_bind_record_source(object recPtr, object srcPtr, string page, int quality) { GEDCOMRecord rec = recPtr as GEDCOMRecord; if (rec == null) { return; } GEDCOMSourceRecord srcRec = srcPtr as GEDCOMSourceRecord; rec.AddSource(srcRec, page, quality); }
private void UpdateControls() { switch (fFilter.BranchCut) { case ChartFilter.BranchCutType.Persons: rbCutPersons.Checked = true; break; case ChartFilter.BranchCutType.Years: rbCutYears.Checked = true; break; case ChartFilter.BranchCutType.None: rbCutNone.Checked = true; break; } edYear.Enabled = (fFilter.BranchCut == ChartFilter.BranchCutType.Years); fPersonsList.Enabled = (fFilter.BranchCut == ChartFilter.BranchCutType.Persons); edYear.Value = fFilter.BranchYear; fPersonsList.ClearItems(); if (!string.IsNullOrEmpty(fTemp)) { string[] tmpRefs = fTemp.Split(';'); int num = tmpRefs.Length; for (int i = 0; i < num; i++) { string xref = tmpRefs[i]; GEDCOMIndividualRecord p = fBase.Context.Tree.XRefIndex_Find(xref) as GEDCOMIndividualRecord; if (p != null) { fPersonsList.AddItem(p, GKUtils.GetNameString(p, true, false)); } } } if (fFilter.SourceMode != FilterGroupMode.Selected) { cmbSource.SelectedIndex = (sbyte)fFilter.SourceMode; } else { GEDCOMSourceRecord srcRec = fBase.Context.Tree.XRefIndex_Find(fFilter.SourceRef) as GEDCOMSourceRecord; if (srcRec != null) { cmbSource.Text = srcRec.FiledByEntry; } } }
private void btnSourceAdd_Click(object sender, EventArgs e) { object[] anArgs = new object[0]; GEDCOMSourceRecord src = fBase.Context.SelectRecord(GEDCOMRecordType.rtSource, anArgs) as GEDCOMSourceRecord; if (src == null) { return; } fBase.Context.GetSourcesList(fSourcesList); RefreshSourcesList(""); cmbSource.Text = src.FiledByEntry; }
private void SetSourceCitation(GEDCOMSourceCitation value) { fSourceCitation = value; GEDCOMSourceRecord src = (fSourceCitation.Value as GEDCOMSourceRecord); if (src != null) { cmbSource.Text = src.FiledByEntry; } txtPage.Text = fSourceCitation.Page; txtCertainty.SelectedIndex = fSourceCitation.CertaintyAssessment; }
public void AddSource() { object[] anArgs = new object[0]; GEDCOMSourceRecord src = fBase.Context.SelectRecord(GEDCOMRecordType.rtSource, anArgs) as GEDCOMSourceRecord; if (src == null) { return; } fBase.Context.GetSourcesList(fSourcesList); RefreshSourcesList(""); fView.Source.Text = src.FiledByEntry; }
private void SetSourceRecord(GEDCOMSourceRecord value) { fSourceRecord = value; txtShortTitle.Text = fSourceRecord.FiledByEntry; txtAuthor.Text = fSourceRecord.Originator.Text.Trim(); txtTitle.Text = fSourceRecord.Title.Text.Trim(); txtPublication.Text = fSourceRecord.Publication.Text.Trim(); txtText.Text = fSourceRecord.Text.Text.Trim(); fRepositoriesList.ListModel.DataOwner = fSourceRecord; fNotesList.ListModel.DataOwner = fSourceRecord; fMediaList.ListModel.DataOwner = fSourceRecord; ActiveControl = txtShortTitle; }
public static bool ModifySource(IBaseWindow baseWin, ref GEDCOMSourceRecord sourceRec) { bool result; try { baseWin.Context.BeginUpdate(); GEDCOMTree tree = baseWin.Context.Tree; using (var dlg = AppHost.Container.Resolve <ISourceEditDlg>()) { dlg.InitDialog(baseWin); bool exists = sourceRec != null; if (!exists) { sourceRec = new GEDCOMSourceRecord(tree, tree, "", ""); sourceRec.InitNew(); } try { baseWin.Context.LockRecord(sourceRec); dlg.SourceRecord = sourceRec; result = (AppHost.Instance.ShowModalX(dlg, false)); } finally { baseWin.Context.UnlockRecord(sourceRec); } if (!exists) { if (result) { tree.AddRecord(sourceRec); } else { sourceRec.Dispose(); sourceRec = null; } } } } finally { baseWin.Context.EndUpdate(); } return(result); }
public void UpdateControls() { fView.SetCutModeRadio((int)fFilter.BranchCut); fView.YearNum.Enabled = (fFilter.BranchCut == ChartFilter.BranchCutType.Years); fView.PersonsList.Enabled = (fFilter.BranchCut == ChartFilter.BranchCutType.Persons); fView.YearNum.Text = fFilter.BranchYear.ToString(); fView.PersonsList.ClearItems(); if (!string.IsNullOrEmpty(fTemp)) { string[] tmpRefs = fTemp.Split(';'); int num = tmpRefs.Length; for (int i = 0; i < num; i++) { string xref = tmpRefs[i]; GEDCOMIndividualRecord p = fBase.Context.Tree.XRefIndex_Find(xref) as GEDCOMIndividualRecord; if (p != null) { fView.PersonsList.AddItem(p, GKUtils.GetNameString(p, true, false)); } } } if (fFilter.SourceMode != FilterGroupMode.Selected) { fView.SourceCombo.SelectedIndex = (sbyte)fFilter.SourceMode; } else { GEDCOMSourceRecord srcRec = fBase.Context.Tree.XRefIndex_Find(fFilter.SourceRef) as GEDCOMSourceRecord; if (srcRec != null) { fView.SourceCombo.Text = srcRec.FiledByEntry; } } }
public void Test_LMSource() { var listManager = new SourceListMan(fContext); Assert.IsNotNull(listManager); GEDCOMSourceRecord srcRec = fContext.Tree.XRefIndex_Find("S1") as GEDCOMSourceRecord; listManager.Fetch(srcRec); listManager.QuickFilter = "*"; Assert.IsTrue(listManager.CheckFilter()); listManager.QuickFilter = "*sourc*"; Assert.IsTrue(listManager.CheckFilter()); listManager.QuickFilter = "*xxxx*"; Assert.IsFalse(listManager.CheckFilter()); var lvMock = new ListViewMock(); listManager.UpdateColumns(lvMock); var listItem = new GKListItem("", null); listManager.UpdateItem(0, listItem, srcRec); }
private bool ProcessSourceRepositoryCitation(bool redo) { GEDCOMSourceRecord srcRec = fObj as GEDCOMSourceRecord; GEDCOMRepositoryRecord repRec = fNewVal as GEDCOMRepositoryRecord; if (srcRec == null || repRec == null) { return(false); } if (fType == OperationType.otSourceRepositoryCitationRemove) { redo = !redo; } if (redo) { srcRec.AddRepository(repRec); } else { srcRec.RemoveRepository(repRec); } return(true); }
public override void PrepareFilter() { IndividualListFilter iFilter = (IndividualListFilter)fFilter; filter_abd = GEDCOMDate.GetUDNByFormattedStr(iFilter.AliveBeforeDate, GEDCOMCalendar.dcGregorian); if (iFilter.GroupRef == "") { filter_grp = null; } else { filter_grp = fBaseContext.Tree.XRefIndex_Find(iFilter.GroupRef) as GEDCOMGroupRecord; } if (iFilter.SourceRef == "") { filter_source = null; } else { filter_source = fBaseContext.Tree.XRefIndex_Find(iFilter.SourceRef) as GEDCOMSourceRecord; } }
public override void UpdateView() { IndividualListFilter iFilter = (IndividualListFilter)fListMan.Filter; GlobalOptions options = GlobalOptions.Instance; fView.NameCombo.Clear(); fView.NameCombo.Add("*"); fView.NameCombo.AddStrings(options.NameFilters); fView.ResidenceCombo.Clear(); fView.ResidenceCombo.Add("*"); fView.ResidenceCombo.AddStrings(options.ResidenceFilters); fView.EventValCombo.Clear(); fView.EventValCombo.AddStrings(options.EventFilters); int lifeSel; if (iFilter.FilterLifeMode != FilterLifeMode.lmTimeLocked) { lifeSel = (int)iFilter.FilterLifeMode; fView.SetLifeEnabled(true); fView.AliveBeforeDate.Text = iFilter.AliveBeforeDate; } else { lifeSel = -1; fView.SetLifeEnabled(false); fView.AliveBeforeDate.Text = ""; } fView.SetLifeRadio(lifeSel); fView.SetSexRadio((int)iFilter.Sex); fView.NameCombo.Text = iFilter.Name; fView.ResidenceCombo.Text = iFilter.Residence; fView.EventValCombo.Text = iFilter.EventVal; fView.OnlyPatriarchsCheck.Checked = iFilter.PatriarchOnly; GEDCOMTree tree = Base.Context.Tree; var values = new StringList(); fView.GroupCombo.Clear(); int num = tree.RecordsCount; for (int i = 0; i < num; i++) { GEDCOMRecord rec = tree[i]; if (rec is GEDCOMGroupRecord) { values.AddObject((rec as GEDCOMGroupRecord).GroupName, rec); } } values.Sort(); fView.GroupCombo.AddItem(LangMan.LS(LSID.LSID_SrcAll), null); fView.GroupCombo.AddItem(LangMan.LS(LSID.LSID_SrcNot), null); fView.GroupCombo.AddItem(LangMan.LS(LSID.LSID_SrcAny), null); fView.GroupCombo.AddStrings(values); if (iFilter.FilterGroupMode != FilterGroupMode.Selected) { fView.GroupCombo.SelectedIndex = (int)iFilter.FilterGroupMode; } else { GEDCOMGroupRecord groupRec = tree.XRefIndex_Find(iFilter.GroupRef) as GEDCOMGroupRecord; if (groupRec != null) { fView.GroupCombo.Text = groupRec.GroupName; } } values = new StringList(); fView.SourceCombo.Clear(); for (int i = 0; i < tree.RecordsCount; i++) { GEDCOMRecord rec = tree[i]; if (rec is GEDCOMSourceRecord) { values.AddObject((rec as GEDCOMSourceRecord).FiledByEntry, rec); } } values.Sort(); fView.SourceCombo.AddItem(LangMan.LS(LSID.LSID_SrcAll), null); fView.SourceCombo.AddItem(LangMan.LS(LSID.LSID_SrcNot), null); fView.SourceCombo.AddItem(LangMan.LS(LSID.LSID_SrcAny), null); fView.SourceCombo.AddStrings(values); if (iFilter.SourceMode != FilterGroupMode.Selected) { fView.SourceCombo.SelectedIndex = (int)iFilter.SourceMode; } else { GEDCOMSourceRecord sourceRec = tree.XRefIndex_Find(iFilter.SourceRef) as GEDCOMSourceRecord; if (sourceRec != null) { fView.SourceCombo.Text = sourceRec.FiledByEntry; } } }
public static GEDCOMRecord AddRecord(IBaseWindow baseWin, GEDCOMRecordType rt, Target target) { bool result = false; GEDCOMRecord rec = null; switch (rt) { case GEDCOMRecordType.rtIndividual: { // FIXME: legacy code, checkit if (target == null) { target = new Target(); target.TargetMode = TargetMode.tmParent; } GEDCOMIndividualRecord indivRec = null; result = ModifyIndividual(baseWin, ref indivRec, target.TargetIndividual, target.TargetMode, target.NeedSex); rec = indivRec; break; } case GEDCOMRecordType.rtFamily: { if (target == null) { target = new Target(); } TargetMode famTarget = (target.TargetMode != TargetMode.tmFamilyChild) ? TargetMode.tmNone : target.TargetMode; GEDCOMFamilyRecord fam = null; result = ModifyFamily(baseWin, ref fam, famTarget, target.TargetIndividual); rec = fam; break; } case GEDCOMRecordType.rtNote: { GEDCOMNoteRecord note = null; result = ModifyNote(baseWin, ref note); rec = note; break; } case GEDCOMRecordType.rtMultimedia: { GEDCOMMultimediaRecord mmRec = null; result = ModifyMedia(baseWin, ref mmRec); rec = mmRec; break; } case GEDCOMRecordType.rtSource: { GEDCOMSourceRecord src = null; result = ModifySource(baseWin, ref src); rec = src; break; } case GEDCOMRecordType.rtRepository: { GEDCOMRepositoryRecord rep = null; result = ModifyRepository(baseWin, ref rep); rec = rep; break; } case GEDCOMRecordType.rtGroup: { GEDCOMGroupRecord grp = null; result = ModifyGroup(baseWin, ref grp); rec = grp; break; } case GEDCOMRecordType.rtResearch: { GEDCOMResearchRecord rsr = null; result = ModifyResearch(baseWin, ref rsr); rec = rsr; break; } case GEDCOMRecordType.rtTask: { GEDCOMTaskRecord tsk = null; result = ModifyTask(baseWin, ref tsk); rec = tsk; break; } case GEDCOMRecordType.rtCommunication: { GEDCOMCommunicationRecord comm = null; result = ModifyCommunication(baseWin, ref comm); rec = comm; break; } case GEDCOMRecordType.rtLocation: { GEDCOMLocationRecord loc = null; result = ModifyLocation(baseWin, ref loc); rec = loc; break; } } return((result) ? rec : null); }
public static bool EditRecord(IBaseWindow baseWin, GEDCOMRecord rec) { bool result = false; switch (rec.RecordType) { case GEDCOMRecordType.rtIndividual: GEDCOMIndividualRecord ind = rec as GEDCOMIndividualRecord; result = ModifyIndividual(baseWin, ref ind, null, TargetMode.tmNone, GEDCOMSex.svNone); break; case GEDCOMRecordType.rtFamily: GEDCOMFamilyRecord fam = rec as GEDCOMFamilyRecord; result = ModifyFamily(baseWin, ref fam, TargetMode.tmNone, null); break; case GEDCOMRecordType.rtNote: GEDCOMNoteRecord note = rec as GEDCOMNoteRecord; result = ModifyNote(baseWin, ref note); break; case GEDCOMRecordType.rtMultimedia: GEDCOMMultimediaRecord mmRec = rec as GEDCOMMultimediaRecord; result = ModifyMedia(baseWin, ref mmRec); break; case GEDCOMRecordType.rtSource: GEDCOMSourceRecord src = rec as GEDCOMSourceRecord; result = ModifySource(baseWin, ref src); break; case GEDCOMRecordType.rtRepository: GEDCOMRepositoryRecord rep = rec as GEDCOMRepositoryRecord; result = ModifyRepository(baseWin, ref rep); break; case GEDCOMRecordType.rtGroup: GEDCOMGroupRecord grp = rec as GEDCOMGroupRecord; result = ModifyGroup(baseWin, ref grp); break; case GEDCOMRecordType.rtResearch: GEDCOMResearchRecord rsr = rec as GEDCOMResearchRecord; result = ModifyResearch(baseWin, ref rsr); break; case GEDCOMRecordType.rtTask: GEDCOMTaskRecord tsk = rec as GEDCOMTaskRecord; result = ModifyTask(baseWin, ref tsk); break; case GEDCOMRecordType.rtCommunication: GEDCOMCommunicationRecord comm = rec as GEDCOMCommunicationRecord; result = ModifyCommunication(baseWin, ref comm); break; case GEDCOMRecordType.rtLocation: GEDCOMLocationRecord loc = rec as GEDCOMLocationRecord; result = ModifyLocation(baseWin, ref loc); break; } return(result); }
public void Test_Common() { Assert.IsNotNull(fContext.Culture); Assert.IsNull(fContext.Viewer); fContext.SetFileName("testfile.ged"); Assert.AreEqual("testfile.ged", fContext.FileName); // fContext.CollectEventValues(null); Assert.AreEqual(ShieldState.Maximum, fContext.ShieldState, "BaseContext.ShieldState.1"); fContext.SwitchShieldState(); Assert.AreEqual(ShieldState.Middle, fContext.ShieldState, "BaseContext.ShieldState.2"); fContext.SwitchShieldState(); Assert.AreEqual(ShieldState.None, fContext.ShieldState, "BaseContext.ShieldState.3"); fContext.SwitchShieldState(); Assert.AreEqual(ShieldState.Maximum, fContext.ShieldState, "BaseContext.ShieldState.4"); GEDCOMSourceRecord srcRec = fContext.FindSource("test source"); Assert.IsNull(srcRec); StringList sources = new StringList(); fContext.GetSourcesList(sources); Assert.AreEqual(1, sources.Count); Assert.IsNotNull(fContext.ValuesCollection); GEDCOMIndividualRecord iRec = fContext.Tree.XRefIndex_Find("I1") as GEDCOMIndividualRecord; Assert.IsNotNull(iRec); fContext.LockRecord(iRec); fContext.UnlockRecord(iRec); Assert.AreEqual(false, fContext.IsChildless(iRec)); Assert.IsNotNull(fContext.LangsList); Assert.AreEqual(0, fContext.LangsList.Count); fContext.CollectNameLangs(null); iRec.PersonalNames[0].Language.Value = GEDCOMLanguageID.AncientGreek; fContext.CollectNameLangs(iRec.PersonalNames[0]); Assert.AreEqual(1, fContext.LangsList.Count); // FIXME: move to other tests Assert.AreEqual(1990, iRec.GetChronologicalYear("BIRT")); Assert.AreEqual(1990, fContext.FindBirthYear(iRec)); Assert.AreEqual(2010, fContext.FindDeathYear(iRec)); Assert.IsFalse(fContext.DeleteRecord(null)); Assert.IsTrue(fContext.DeleteRecord(fContext.Tree.CreateIndividual())); Assert.IsTrue(fContext.DeleteRecord(fContext.Tree.CreateFamily())); Assert.IsTrue(fContext.DeleteRecord(fContext.Tree.CreateNote())); Assert.IsTrue(fContext.DeleteRecord(fContext.Tree.CreateMultimedia())); Assert.IsTrue(fContext.DeleteRecord(fContext.Tree.CreateSource())); Assert.IsTrue(fContext.DeleteRecord(fContext.Tree.CreateRepository())); Assert.IsTrue(fContext.DeleteRecord(fContext.Tree.CreateGroup())); Assert.IsTrue(fContext.DeleteRecord(fContext.Tree.CreateResearch())); Assert.IsTrue(fContext.DeleteRecord(fContext.Tree.CreateTask())); Assert.IsTrue(fContext.DeleteRecord(fContext.Tree.CreateCommunication())); Assert.IsTrue(fContext.DeleteRecord(fContext.Tree.CreateLocation())); Assert.Throws(typeof(ArgumentNullException), () => { fContext.GetStoreType(null); }); var mediaStore = fContext.GetStoreType(new GEDCOMFileReference(fContext.Tree, null, "", "file.txt")); Assert.AreEqual(MediaStoreType.mstReference, mediaStore.StoreType); mediaStore = fContext.GetStoreType(new GEDCOMFileReference(fContext.Tree, null, "", "stg:file.txt")); Assert.AreEqual(MediaStoreType.mstStorage, mediaStore.StoreType); mediaStore = fContext.GetStoreType(new GEDCOMFileReference(fContext.Tree, null, "", "arc:file.txt")); Assert.AreEqual(MediaStoreType.mstArchive, mediaStore.StoreType); fContext.CollectEventValues(null); fContext.BeginUpdate(); Assert.IsTrue(fContext.IsUpdated()); fContext.EndUpdate(); Assert.IsFalse(fContext.IsUpdated()); fContext.DoUndo(); fContext.DoRedo(); fContext.DoCommit(); fContext.DoRollback(); // FIXME: error during execution of tests under TravisCI (a problem with UI) //var patrGraph = PatriarchsMan.GetPatriarchsGraph(fContext, 1, true, false); //Assert.IsNotNull(patrGraph); // var evt = fContext.CreateEventEx(iRec, "FACT", "17 JAN 2013", "Ivanovo"); Assert.IsNotNull(evt); GEDCOMFamilyRecord fRec = fContext.Tree.CreateFamily(); Assert.IsNotNull(fRec); evt = fContext.CreateEventEx(fRec, "MARR", "28 DEC 2013", "Ivanovo"); Assert.IsNotNull(evt); }
private void GenStep(PedigreePerson parent, GEDCOMIndividualRecord iRec, int level, int familyOrder) { if (iRec == null) { return; } PedigreePerson res = new PedigreePerson(); res.Parent = parent; res.IRec = iRec; res.Level = level; res.ChildIdx = 0; res.FamilyOrder = familyOrder; fPersonList.Add(res); if (fOptions.PedigreeOptions.IncludeSources) { int num = iRec.SourceCitations.Count; for (int i = 0; i < num; i++) { GEDCOMSourceRecord sourceRec = iRec.SourceCitations[i].Value as GEDCOMSourceRecord; if (sourceRec == null) { continue; } string srcName = GKUtils.MergeStrings(sourceRec.Title); if (srcName == "") { srcName = sourceRec.FiledByEntry; } int j = fSourceList.IndexOf(srcName); if (j < 0) { j = fSourceList.Add(srcName); } res.Sources.Add((j + 1).ToString()); } } if (fKind == PedigreeKind.pkAscend) { if (iRec.ChildToFamilyLinks.Count > 0) { GEDCOMFamilyRecord family = iRec.ChildToFamilyLinks[0].Family; if (fBase.Context.IsRecordAccess(family.Restriction)) { GEDCOMIndividualRecord prnt; prnt = family.GetWife(); GenStep(res, prnt, level + 1, 1); prnt = family.GetHusband(); GenStep(res, prnt, level + 1, 1); } } } else { int num2 = iRec.SpouseToFamilyLinks.Count; for (int j = 0; j < num2; j++) { GEDCOMFamilyRecord family = iRec.SpouseToFamilyLinks[j].Family; if (!fBase.Context.IsRecordAccess(family.Restriction)) { continue; } family.SortChilds(); int num3 = family.Children.Count; for (int i = 0; i < num3; i++) { GEDCOMIndividualRecord child = family.Children[i].Value as GEDCOMIndividualRecord; GenStep(res, child, level + 1, i + 1); } } } }
public override void Fetch(GEDCOMRecord aRec) { fRec = (aRec as GEDCOMSourceRecord); }
private void PrepareData() { mainIndex = new StringList(); byIndex = new StringList(); dyIndex = new StringList(); bpIndex = new StringList(); dpIndex = new StringList(); deathCauses = new StringList(); occuIndex = new StringList(); reliIndex = new StringList(); sourcesIndex = new StringList(); GEDCOMRecord rec; var iEnum = fTree.GetEnumerator(GEDCOMRecordType.rtIndividual); while (iEnum.MoveNext(out rec)) { GEDCOMIndividualRecord iRec = (GEDCOMIndividualRecord)rec; string text = GKUtils.GetNameString(iRec, true, false); string st; mainIndex.AddObject(text, iRec); int evNum = iRec.Events.Count; for (int k = 0; k < evNum; k++) { GEDCOMCustomEvent evt = iRec.Events[k]; if (evt == null) { continue; } int srcNum2 = evt.SourceCitations.Count; for (int m = 0; m < srcNum2; m++) { GEDCOMSourceRecord src = evt.SourceCitations[m].Value as GEDCOMSourceRecord; if (src == null) { continue; } st = src.FiledByEntry; if (string.IsNullOrEmpty(st)) { st = src.Title.Text; } PrepareSpecIndex(sourcesIndex, st, iRec); } // The analysis places // st = ev.Detail.Place.StringValue; // if (!string.IsNullOrEmpty(st)) PrepareSpecIndex(places, st, iRec); if (evt.Name == "BIRT") { // Analysis on births PrepareEventYear(byIndex, evt, iRec); st = GKUtils.GetPlaceStr(evt, false); if (!string.IsNullOrEmpty(st)) { PrepareSpecIndex(bpIndex, st, iRec); } } else if (evt.Name == "DEAT") { // Analysis by causes of death PrepareEventYear(dyIndex, evt, iRec); st = GKUtils.GetPlaceStr(evt, false); if (!string.IsNullOrEmpty(st)) { PrepareSpecIndex(dpIndex, st, iRec); } st = evt.Cause; if (!string.IsNullOrEmpty(st)) { PrepareSpecIndex(deathCauses, st, iRec); } } else if (evt.Name == "OCCU") { // Analysis by occupation st = evt.StringValue; if (!string.IsNullOrEmpty(st)) { PrepareSpecIndex(occuIndex, st, iRec); } } else if (evt.Name == "RELI") { // Analysis by religion st = evt.StringValue; if (!string.IsNullOrEmpty(st)) { PrepareSpecIndex(reliIndex, st, iRec); } } } int srcNum = iRec.SourceCitations.Count; for (int k = 0; k < srcNum; k++) { GEDCOMSourceRecord src = iRec.SourceCitations[k].Value as GEDCOMSourceRecord; if (src == null) { continue; } st = src.FiledByEntry; if (string.IsNullOrEmpty(st)) { st = src.Title.Text; } PrepareSpecIndex(sourcesIndex, st, iRec); } } mainIndex.Sort(); BookCatalogs[(int)BookCatalog.Catalog_BirthYears].Index = byIndex; BookCatalogs[(int)BookCatalog.Catalog_DeathYears].Index = dyIndex; BookCatalogs[(int)BookCatalog.Catalog_BirthPlaces].Index = bpIndex; BookCatalogs[(int)BookCatalog.Catalog_DeathPlaces].Index = dpIndex; BookCatalogs[(int)BookCatalog.Catalog_DeathCauses].Index = deathCauses; BookCatalogs[(int)BookCatalog.Catalog_Occupations].Index = occuIndex; BookCatalogs[(int)BookCatalog.Catalog_Religion].Index = reliIndex; BookCatalogs[(int)BookCatalog.Catalog_Sources].Index = sourcesIndex; }
private void UpdateSpecific() { IndividualListFilter iFilter = (IndividualListFilter)fListMan.Filter; GlobalOptions options = GlobalOptions.Instance; txtName.Items.Clear(); txtName.Items.AddRange(options.NameFilters.ToArray()); txtName.Items.Insert(0, "*"); cmbResidence.Items.Clear(); cmbResidence.Items.AddRange(options.ResidenceFilters.ToArray()); cmbResidence.Items.Insert(0, "*"); cmbEventVal.Items.Clear(); cmbEventVal.Items.AddRange(options.EventFilters.ToArray()); int lifeSel; if (iFilter.FilterLifeMode != FilterLifeMode.lmTimeLocked) { lifeSel = (int)iFilter.FilterLifeMode; rgLife.Enabled = true; txtAliveBeforeDate.Text = iFilter.AliveBeforeDate; } else { lifeSel = -1; rgLife.Enabled = false; txtAliveBeforeDate.Text = ""; } switch (lifeSel) { case 0: rbAll.Checked = true; break; case 1: rbOnlyLive.Checked = true; break; case 2: rbOnlyDead.Checked = true; break; case 3: rbAliveBefore.Checked = true; break; } int sexSel = (int)iFilter.Sex; switch (sexSel) { case 0: rbSexAll.Checked = true; break; case 1: rbSexMale.Checked = true; break; case 2: rbSexFemale.Checked = true; break; } txtName.Text = iFilter.Name; cmbResidence.Text = iFilter.Residence; cmbEventVal.Text = iFilter.EventVal; chkOnlyPatriarchs.Checked = iFilter.PatriarchOnly; GEDCOMTree tree = Base.Context.Tree; cmbGroup.Items.Clear(); cmbGroup.Sorted = true; int num = tree.RecordsCount; for (int i = 0; i < num; i++) { GEDCOMRecord rec = tree[i]; if (rec is GEDCOMGroupRecord) { cmbGroup.Items.Add(new GKComboItem((rec as GEDCOMGroupRecord).GroupName, rec)); } } cmbGroup.Sorted = false; cmbGroup.Items.Insert(0, new GKComboItem(LangMan.LS(LSID.LSID_SrcAll), null)); cmbGroup.Items.Insert(1, new GKComboItem(LangMan.LS(LSID.LSID_SrcNot), null)); cmbGroup.Items.Insert(2, new GKComboItem(LangMan.LS(LSID.LSID_SrcAny), null)); if (iFilter.FilterGroupMode != FilterGroupMode.Selected) { cmbGroup.SelectedIndex = (int)iFilter.FilterGroupMode; } else { GEDCOMGroupRecord groupRec = tree.XRefIndex_Find(iFilter.GroupRef) as GEDCOMGroupRecord; if (groupRec != null) cmbGroup.Text = groupRec.GroupName; } cmbSource.Items.Clear(); cmbSource.Sorted = true; for (int i = 0; i < tree.RecordsCount; i++) { GEDCOMRecord rec = tree[i]; if (rec is GEDCOMSourceRecord) { cmbSource.Items.Add(new GKComboItem((rec as GEDCOMSourceRecord).FiledByEntry, rec)); } } cmbSource.Sorted = false; cmbSource.Items.Insert(0, new GKComboItem(LangMan.LS(LSID.LSID_SrcAll), null)); cmbSource.Items.Insert(1, new GKComboItem(LangMan.LS(LSID.LSID_SrcNot), null)); cmbSource.Items.Insert(2, new GKComboItem(LangMan.LS(LSID.LSID_SrcAny), null)); if (iFilter.SourceMode != FilterGroupMode.Selected) { cmbSource.SelectedIndex = (int)iFilter.SourceMode; } else { GEDCOMSourceRecord sourceRec = tree.XRefIndex_Find(iFilter.SourceRef) as GEDCOMSourceRecord; if (sourceRec != null) cmbSource.Text = sourceRec.FiledByEntry; } }
public void Test_ShowXInfo() { StringList summary = new StringList(); summary.Clear(); GKUtils.ShowFamilyInfo(fContext, null, null); GEDCOMFamilyRecord famRec = fContext.Tree.XRefIndex_Find("F1") as GEDCOMFamilyRecord; GKUtils.ShowFamilyInfo(fContext, famRec, summary); summary.Clear(); GKUtils.ShowGroupInfo(null, null); GEDCOMGroupRecord grpRec = fContext.Tree.XRefIndex_Find("G1") as GEDCOMGroupRecord; GKUtils.ShowGroupInfo(grpRec, summary); summary.Clear(); GKUtils.ShowMultimediaInfo(null, null); GEDCOMMultimediaRecord mmRec = fContext.Tree.XRefIndex_Find("O1") as GEDCOMMultimediaRecord; GKUtils.ShowMultimediaInfo(mmRec, summary); summary.Clear(); GKUtils.ShowNoteInfo(null, null); GEDCOMNoteRecord noteRec = fContext.Tree.XRefIndex_Find("N1") as GEDCOMNoteRecord; GKUtils.ShowNoteInfo(noteRec, summary); summary.Clear(); GKUtils.ShowPersonInfo(fContext, null, null); GEDCOMIndividualRecord indRec = fContext.Tree.XRefIndex_Find("I1") as GEDCOMIndividualRecord; GKUtils.ShowPersonInfo(fContext, indRec, summary); summary.Clear(); GKUtils.ShowSourceInfo(null, null); GEDCOMSourceRecord srcRec = fContext.Tree.XRefIndex_Find("S1") as GEDCOMSourceRecord; GKUtils.ShowSourceInfo(srcRec, summary); summary.Clear(); GKUtils.ShowRepositoryInfo(null, null); GEDCOMRepositoryRecord repRec = fContext.Tree.XRefIndex_Find("R1") as GEDCOMRepositoryRecord; GKUtils.ShowRepositoryInfo(repRec, summary); summary.Clear(); GKUtils.ShowResearchInfo(null, null); GEDCOMResearchRecord resRec = fContext.Tree.XRefIndex_Find("RS1") as GEDCOMResearchRecord; GKUtils.ShowResearchInfo(resRec, summary); summary.Clear(); GKUtils.ShowTaskInfo(null, null); GEDCOMTaskRecord taskRec = fContext.Tree.XRefIndex_Find("TK1") as GEDCOMTaskRecord; GKUtils.ShowTaskInfo(taskRec, summary); summary.Clear(); GKUtils.ShowCommunicationInfo(null, null); GEDCOMCommunicationRecord commRec = fContext.Tree.XRefIndex_Find("CM1") as GEDCOMCommunicationRecord; GKUtils.ShowCommunicationInfo(commRec, summary); summary.Clear(); GKUtils.ShowLocationInfo(null, null); GEDCOMLocationRecord locRec = fContext.Tree.XRefIndex_Find("L1") as GEDCOMLocationRecord; GKUtils.ShowLocationInfo(locRec, summary); }
// 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; GEDCOMSourceRecord srcRec = null; if (!string.IsNullOrEmpty(srcName)) { srcRec = fBase.Context.FindSource(srcName); if (srcRec == null) { srcRec = fBase.Context.Tree.CreateSource(); srcRec.FiledByEntry = srcName; } } GEDCOMIndividualRecord iMain = null; int num = dataGridView1.Rows.Count; for (int r = 0; r < num; r++) { DataGridViewRow row = dataGridView1.Rows[r]; string lnk = (string)row.Cells[0].Value; string nm = (string)row.Cells[1].Value; string pt = (string)row.Cells[2].Value; string fm = (string)row.Cells[3].Value; string age = (string)row.Cells[4].Value; string comment = (string)row.Cells[5].Value; if (!string.IsNullOrEmpty(lnk)) { PersonLink link = GetLinkByName(lnk); GEDCOMSex sx = fBase.Context.DefineSex(nm, pt); GEDCOMIndividualRecord iRec = fBase.Context.CreatePersonEx(nm, pt, fm, sx, false); if (!string.IsNullOrEmpty(age) && SysUtils.IsDigits(age)) { int birthYear = srcYear - int.Parse(age); fBase.Context.CreateEventEx(iRec, "BIRT", "ABT " + birthYear.ToString(), ""); } if (!string.IsNullOrEmpty(place)) { GEDCOMCustomEvent evt = fBase.Context.CreateEventEx(iRec, "RESI", "", ""); evt.Place.StringValue = place; } if (!string.IsNullOrEmpty(comment)) { GEDCOMNoteRecord noteRec = fBase.Context.Tree.CreateNote(); noteRec.SetNoteText(comment); iRec.AddNote(noteRec); } if (srcRec != null) { iRec.AddSource(srcRec, srcPage, 0); } fBase.NotifyRecord(iRec, RecordAction.raAdd); GEDCOMFamilyRecord family = null; if (link == PersonLink.plPerson) { iMain = iRec; string evName = ""; if (rbSK_Met.Checked) { switch (cbEventType.SelectedIndex) { case 0: evName = "BIRT"; break; case 1: evName = "DEAT"; break; case 2: evName = "MARR"; break; } } if (evName == "BIRT" || evName == "DEAT") { GEDCOMCustomEvent evt = fBase.Context.CreateEventEx(iRec, evName, GEDCOMDate.CreateByFormattedStr(edEventDate.Text, false), ""); evt.Place.StringValue = place; } else if (evName == "MARR") { family = iRec.GetMarriageFamily(true); GEDCOMCustomEvent evt = fBase.Context.CreateEventEx(family, evName, GEDCOMDate.CreateByFormattedStr(edEventDate.Text, false), ""); evt.Place.StringValue = place; } } else if (link > PersonLink.plPerson) { 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 static void FillContext(IBaseContext context) { // a null result if the record is not defined GEDCOMCustomEvent evt = context.CreateEventEx(null, "BIRT", "xxxxx", "xxxxx"); Assert.IsNull(evt); // first individual GEDCOMIndividualRecord iRec = context.CreatePersonEx("Ivan", "Ivanovich", "Ivanov", GEDCOMSex.svMale, true); Assert.IsNotNull(iRec); evt = iRec.FindEvent("BIRT"); Assert.IsNotNull(evt); evt.Date.ParseString("28 DEC 1990"); evt.Place.StringValue = "Ivanovo"; GEDCOMCustomEvent evtd = context.CreateEventEx(iRec, "DEAT", "28 DEC 2010", "Ivanovo"); Assert.IsNotNull(evtd); // second individual, wife GEDCOMIndividualRecord iRec2 = context.CreatePersonEx("Maria", "Petrovna", "Ivanova", GEDCOMSex.svFemale, true); evt = iRec2.FindEvent("BIRT"); Assert.IsNotNull(evt); evt.Date.ParseString("17 MAR 1990"); evt.Place.StringValue = "Ivanovo"; iRec.AddAssociation("spouse", iRec2); // third individual, child GEDCOMIndividualRecord iRec3 = context.CreatePersonEx("Anna", "Ivanovna", "Ivanova", GEDCOMSex.svFemale, true); evt = iRec3.FindEvent("BIRT"); Assert.IsNotNull(evt); evt.Date.ParseString("11 FEB 2010"); evt.Place.StringValue = "Ivanovo"; // their family GEDCOMFamilyRecord famRec = context.Tree.CreateFamily(); Assert.IsNotNull(famRec); famRec.AddSpouse(iRec); famRec.AddSpouse(iRec2); famRec.AddChild(iRec3); context.CreateEventEx(famRec, "MARR", "01 JAN 2000", "unknown"); // individual outside the family GEDCOMIndividualRecord iRec4 = context.CreatePersonEx("Alex", "", "Petrov", GEDCOMSex.svMale, true); evt = iRec4.FindEvent("BIRT"); Assert.IsNotNull(evt); evt.Date.ParseString("15 JUN 1989"); evt.Place.StringValue = "Far Forest"; evt = context.CreateEventEx(iRec4, "RESI", "12 FEB", "Far Forest"); Assert.IsNotNull(evt); // fifth GEDCOMIndividualRecord iRec5 = context.CreatePersonEx("Anna", "", "Jones", GEDCOMSex.svFemale, false); Assert.IsNotNull(iRec5); // group for tests GEDCOMGroupRecord groupRec = context.Tree.CreateGroup(); groupRec.GroupName = "GroupTest"; Assert.IsNotNull(groupRec, "group1 != null"); groupRec.AddMember(iRec); // location for tests GEDCOMLocationRecord 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 GEDCOMRepositoryRecord repoRec = context.Tree.CreateRepository(); repoRec.RepositoryName = "Test repository"; Assert.IsNotNull(repoRec, "repoRec != null"); // research for tests GEDCOMResearchRecord resRec = context.Tree.CreateResearch(); resRec.ResearchName = "Test research"; Assert.IsNotNull(resRec, "resRec != null"); // source for tests GEDCOMSourceRecord srcRec = context.Tree.CreateSource(); srcRec.FiledByEntry = "Test source"; Assert.IsNotNull(srcRec, "srcRec != null"); iRec.AddSource(srcRec, "p1", 0); // note for tests GEDCOMNoteRecord noteRec = context.Tree.CreateNote(); noteRec.SetNoteText("Test note"); Assert.IsNotNull(noteRec, "noteRec != null"); iRec.AddNote(noteRec); // task for tests GEDCOMTaskRecord tskRec = context.Tree.CreateTask(); tskRec.Goal = "Test task"; Assert.IsNotNull(tskRec, "tskRec != null"); // media for tests GEDCOMMultimediaRecord mediaRec = context.Tree.CreateMultimedia(); mediaRec.AddTag("FILE", "", null); GEDCOMFileReferenceWithTitle fileRef = mediaRec.FileReferences[0]; fileRef.Title = "Test multimedia"; fileRef.LinkFile("sample.png"); Assert.IsNotNull(mediaRec, "mediaRec != null"); iRec.AddMultimedia(mediaRec); // communication for tests GEDCOMCommunicationRecord commRec = context.Tree.CreateCommunication(); commRec.CommName = "Test communication"; Assert.IsNotNull(commRec, "commRec != null"); }
public object gt_find_source(string name) { GEDCOMSourceRecord srcRec = fBase.Context.FindSource(name); return(srcRec); }