// TODO: refactor private static void CheckRecord_RepairTag(GDMTree tree, GEDCOMFormat format, GDMTagWithLists tag) { for (int i = tag.MultimediaLinks.Count - 1; i >= 0; i--) { GDMMultimediaLink mmLink = tag.MultimediaLinks[i]; if (mmLink.IsPointer && mmLink.Value == null) { tag.MultimediaLinks.DeleteAt(i); } } for (int i = tag.Notes.Count - 1; i >= 0; i--) { GDMNotes note = tag.Notes[i]; if (note.IsPointer && note.Value == null) { tag.Notes.DeleteAt(i); } } for (int i = tag.SourceCitations.Count - 1; i >= 0; i--) { GDMSourceCitation sourCit = tag.SourceCitations[i]; if (sourCit.IsPointer && sourCit.Value == null) { tag.SourceCitations.DeleteAt(i); } } }
private static void CheckTagWithLists(GDMTree tree, GEDCOMFormat format, GDMTagWithLists tag) { int num = tag.MultimediaLinks.Count; for (int i = 0; i < num; i++) { GDMMultimediaLink mmLink = tag.MultimediaLinks[i]; if (!mmLink.IsPointer) { TransformMultimediaLink(tree, mmLink); } } num = tag.Notes.Count; for (int i = 0; i < num; i++) { GDMNotes note = tag.Notes[i]; if (!note.IsPointer) { TransformNote(tree, note); } } num = tag.SourceCitations.Count; for (int i = 0; i < num; i++) { GDMSourceCitation sourCit = tag.SourceCitations[i]; if (!sourCit.IsPointer) { TransformSourceCitation(tree, sourCit); } } }
private static void CheckRecord(IBaseContext baseContext, GDMTree tree, GDMRecord rec, GEDCOMFormat format, int fileVer) { if (format != GEDCOMFormat.gf_Native) { int num = rec.MultimediaLinks.Count; for (int i = 0; i < num; i++) { GDMMultimediaLink mmLink = rec.MultimediaLinks[i]; if (!mmLink.IsPointer) { TransformMultimediaLink(tree, mmLink); } } num = rec.Notes.Count; for (int i = 0; i < num; i++) { GDMNotes note = rec.Notes[i]; if (!note.IsPointer) { TransformNote(tree, note); } } num = rec.SourceCitations.Count; for (int i = 0; i < num; i++) { GDMSourceCitation sourCit = rec.SourceCitations[i]; if (!sourCit.IsPointer) { TransformSourceCitation(tree, sourCit); } } } switch (rec.RecordType) { case GDMRecordType.rtIndividual: CheckIndividualRecord(baseContext, tree, format, rec as GDMIndividualRecord); break; case GDMRecordType.rtFamily: CheckFamilyRecord(baseContext, tree, format, rec as GDMFamilyRecord); break; case GDMRecordType.rtGroup: CheckGroupRecord(rec as GDMGroupRecord); break; case GDMRecordType.rtSource: CheckSourceRecord(rec as GDMSourceRecord); break; case GDMRecordType.rtMultimedia: CheckMultimediaRecord(rec as GDMMultimediaRecord, format, fileVer); break; } }
public override void Modify(object sender, ModifyEventArgs eArgs) { var dataOwner = fDataOwner as IGDMStructWithSourceCitations; if (fBaseWin == null || fSheetList == null || dataOwner == null) { return; } GDMSourceCitation aCit = eArgs.ItemData as GDMSourceCitation; bool result = false; switch (eArgs.Action) { case RecordAction.raAdd: case RecordAction.raEdit: result = BaseController.ModifySourceCitation(fBaseWin, fUndoman, dataOwner, ref aCit); break; case RecordAction.raDelete: if (AppHost.StdDialogs.ShowQuestionYN(LangMan.LS(LSID.LSID_DetachSourceQuery))) { result = fUndoman.DoOrdinaryOperation(OperationType.otRecordSourceCitRemove, fDataOwner, aCit); } break; case RecordAction.raMoveUp: case RecordAction.raMoveDown: { int idx = dataOwner.SourceCitations.IndexOf(aCit); switch (eArgs.Action) { case RecordAction.raMoveUp: dataOwner.SourceCitations.Exchange(idx - 1, idx); break; case RecordAction.raMoveDown: dataOwner.SourceCitations.Exchange(idx, idx + 1); break; } result = true; } break; } if (result) { if (eArgs.Action == RecordAction.raAdd) { eArgs.ItemData = aCit; } fBaseWin.Context.Modified = true; eArgs.IsChanged = true; } }
public override void Setup() { base.Setup(); fBase = new BaseWindowStub(); fSourceCitation = new GDMSourceCitation(null); fDialog = new SourceCitEditDlg(fBase); fDialog.SourceCitation = fSourceCitation; fDialog.Show(); }
// Marks the given source citation as (un)restricted public static void RestrictSource(GDMSourceCitation sc, bool visible) { if (sc != null) { GDMSourceRecord sr = sc.Value as GDMSourceRecord; if (sr != null) { sr.SetVisibility(visible); } } }
// Marks the given source citation as (un)restricted public static void RestrictSource(GDMTree tree, GDMSourceCitation sc, bool visible) { if (tree != null && sc != null) { var sourceRec = tree.GetPtrValue <GDMSourceRecord>(sc); if (sourceRec != null) { GMHelper.SetVisibility(sourceRec, visible); } } }
public override void Setup() { TestUtils.InitGEDCOMProviderTest(); WFAppHost.ConfigureBootstrap(false); fBase = new BaseWindowStub(); fSourceCitation = new GDMSourceCitation(); fDialog = new SourceCitEditDlg(fBase); fDialog.SourceCitation = fSourceCitation; fDialog.Show(); }
private static void TransformSourceCitation(GDMTree tree, GDMSourceCitation sourCit) { GDMSourceRecord sourRec = tree.CreateSource(); StringList description = sourCit.Description; string page = sourCit.Page; int certaintyAssessment = sourCit.CertaintyAssessment; sourRec.Text.Lines.Assign(description); sourCit.Clear(); sourCit.Value = sourRec; sourCit.Page = page; sourCit.CertaintyAssessment = certaintyAssessment; }
public GDMSourceCitation AddSource(GDMSourceRecord sourceRec, string page, int quality) { GDMSourceCitation cit = null; if (sourceRec != null) { cit = new GDMSourceCitation(this); cit.Value = sourceRec; cit.Page = page; cit.CertaintyAssessment = quality; fSourceCitations.Add(cit); } return(cit); }
public static GDMSourceCitation AddSource(this IGDMStructWithSourceCitations _struct, GDMSourceRecord sourceRec, string page, int quality) { GDMSourceCitation cit = null; if (sourceRec != null) { cit = new GDMSourceCitation(); cit.XRef = sourceRec.XRef; cit.Page = page; cit.CertaintyAssessment = quality; _struct.SourceCitations.Add(cit); } return(cit); }
private static void CheckTagWithSourceCitations(GDMTree tree, GEDCOMFormat format, IGDMStructWithSourceCitations tag) { for (int i = tag.SourceCitations.Count - 1; i >= 0; i--) { GDMSourceCitation sourCit = tag.SourceCitations[i]; if (!sourCit.IsPointer) { TransformSourceCitation(tree, sourCit); } else { if (sourCit.Value == null) { tag.SourceCitations.DeleteAt(i); } } } }
private void CheckTagWithSourceCitations(IGDMStructWithSourceCitations tag) { for (int i = tag.SourceCitations.Count - 1; i >= 0; i--) { GDMSourceCitation sourCit = tag.SourceCitations[i]; if (!sourCit.IsPointer) { TransformSourceCitation(sourCit); } else { var sourRec = fTree.GetPtrValue <GDMSourceRecord>(sourCit); if (sourRec == null) { tag.SourceCitations.DeleteAt(i); } } } }
private void TransformSourceCitation(GDMSourceCitation sourCit) { GDMSourceRecord sourRec = fTree.CreateSource(); sourRec.Title.Lines.Assign(sourCit.Description); sourRec.Text.Lines.Assign(sourCit.Text.Lines); // transfers notes and multimedia from the citation to the source record sourRec.AssignList(sourCit.Notes, sourRec.Notes); sourRec.AssignList(sourCit.MultimediaLinks, sourRec.MultimediaLinks); sourCit.Description.Clear(); sourCit.Text.Clear(); sourCit.Notes.Clear(); sourCit.MultimediaLinks.Clear(); sourCit.XRef = sourRec.XRef; CheckTagWithNotes(sourRec); CheckTagWithMultimediaLinks(sourRec); }
public static bool ModifySourceCitation(IBaseWindow baseWin, ChangeTracker undoman, IGDMStructWithSourceCitations _struct, ref GDMSourceCitation cit) { bool result; try { baseWin.Context.BeginUpdate(); GDMTree tree = baseWin.Context.Tree; using (var dlg = AppHost.ResolveDialog <ISourceCitEditDlg>(baseWin)) { bool exists = cit != null; if (!exists) { cit = new GDMSourceCitation(); } dlg.SourceCitation = cit; result = AppHost.Instance.ShowModalX(dlg, false); if (!exists) { if (result) { result = undoman.DoOrdinaryOperation(OperationType.otRecordSourceCitAdd, (GDMObject)_struct, cit); } else { cit.Dispose(); } } } } finally { baseWin.Context.EndUpdate(); } return(result); }
private bool ProcessRecordSourceCit(bool redo) { IGEDCOMStructWithLists swl = fObj as IGEDCOMStructWithLists; GDMSourceCitation sourceCit = fNewVal as GDMSourceCitation; if (swl == null || sourceCit == null) { return(false); } if (fType == OperationType.otRecordSourceCitRemove) { redo = !redo; } if (redo) { swl.SourceCitations.Add(sourceCit); } else { swl.SourceCitations.Extract(sourceCit); // bugfix(no delete!) } return(true); }
// Returns a string to use in the list of references at the bottom of the page public static string MakeLinkText(GDMTree tree, GDMSourceCitation sourCit, int sourceCount) { var sourRec = tree.GetPtrValue <GDMSourceRecord>(sourCit); return(string.Concat(sourceCount.ToString(), ". ", /*m_sSourceDescription*/ sourRec.ShortTitle)); }
// Returns a string to use in the list of references at the bottom of the page public static string MakeLinkText(this GDMSourceCitation sourCit, uint uSourceCount) { var sourRec = sourCit.Value as GDMSourceRecord; return(string.Concat(uSourceCount.ToString(), ". ", /*m_sSourceDescription*/ sourRec.ShortTitle)); }
public static string MakeLinkNumber(this GDMSourceCitation sourCit, uint uSourceCount, bool bComma) { string sComma = bComma ? "," : ""; return(string.Concat("<span class=\"reference\">", sComma, uSourceCount.ToString(), "</span>")); }
public static string MakeLinkNumber(GDMSourceCitation sourCit, int sourceCount, bool hasComma) { string comma = hasComma ? "," : ""; return(string.Concat("<span class=\"reference\">", comma, sourceCount.ToString(), "</span>")); }
public static GDMSourceRecord GetPtrValue(this GDMTree tree, GDMSourceCitation ptr) { return(tree.GetPtrValue <GDMSourceRecord>(ptr)); }